I have a 4x space exploration game, and I have a deck of planets that are in ascending numerical order. Can someone please help me program vassal to number each planet, as they are drawn, fetch a correspondingly numbered unit, and make a menu command to send the the unit back to its homeworld.
I’ve been working on this forever and I’m having so much trouble.
Perhaps, even better, if you could post a link to your module?
I think what you need is similar to what I did in Littoral Commander: Indo-Pacific (version 2.0.0-beta). There, when a card is placed in a hand (Key command when piece ends movement on this map - see Map Window), a corresponding piece is placed on top of it ( Place Marker). The piece can then be placed on the map. The cards have counters on them to keep track of “Hit points”. If that goes to zero, then both the card and the piece are removed from play. This is accomplished via Attachment trait. The card can send commands to the piece, and vice versa.
I think you need to post a copy of your module to really make sense of what you have and what it is you are trying to do.
Please also outline, in terms of the module, what you want to achieve. Which piece is placed where, and which other piece do you expect to appear, be moved, or similar.
It seems to me, that what you want is
You place a Planet piece in the zone PlayAreaand its previous location was not the zone MainMap.
You then want to assign it a number (where does that number come from? A Global/Map Property? How is that number incremented?)
When the Planet piece is put in the PlayArea you want to place - using Place Marker trait - a Marker piece on that planet piece.
You want the Marker piece to get the number of the planet, just assigned to the Planet piece.
You want the Marker to have a Send to Location trait that will send it “home” (what ever that means).
For point 2 above, you want to set Key Command to apply to all units ending movement on this map on the Map Window that contains the ZonePlayArea. Let’s say the command is set to the named command endOnMap.
Then, you add the following traits to you Planet pieces
Property: {CurrentZone == "PlayArea" && OldZone != "MainMap"} (check that logic, in particular the OldZone comparison - is there a zone called MainMap?)
Destination: Any counter, selected by properties or Nearest counter, selected by properties
Expression: {PlanetNumber == $HomePlanet$} ($...$ referes to values in source piece)
If you want to be able to send commands from the planet to the marker, or vice versa, you can create Attachment relation between the two. This is quite powerful, because the pieces are coupled very tightly and can efficiently send commands between them.
Note, in a sense, you do not need the global property PlanetCounter. Instead, you can use the planets UniqueID property, and the placed markers ParentID property. And then, in your Send to Location the expression can simply be {UniqueID=="$ParentID$"}
as outlined in the Place Marker documentation. E.g.,
Property: {CurrentZone == "PlayArea" && OldZone != "MainMap"} (check that logic, in particular the OldZone comparison - is there a zone called MainMap?)
My plan was to tag the planet when it is placed on the main map with each newly placed planet ascending order. Then numbers that have a unit associated with it will place that marker with a send to location (their numbered Homeworld). and that marker would have a menu command to send it to it’s homeworld.
There is a MainMap zone with a global property for increment planet counter.
I’m sorry that I’m kind of lost. I really appreciate your help, but I’ll try again.
You need to share this with others - currently access is denied - see here.
Do I understand you use case correctly:
There are pieces on the map which has a specific home planet, identified by some unique (serial) number.
You place a planet on the map, and that planet gets a unique (serial) number assigned to it automatically.
All the pieces that has the same unique home planet identifier are sent to the newly placed planet.
If so, you can use some of the above logic:
You want to set Key Command to apply to all units ending movement on this map on the Map Window that contains the ZonePlayArea . Let’s say the command is set to the named command endOnMap .
Then, you add the following traits to you Planet pieces
Property: {CurrentZone == "PlayArea" && OldZone != "MainMap"} (check that logic, in particular the OldZone comparison - is there a zone called MainMap?)
Select By: Specific Map (May be you want a different location select)
Value: {"Main Map"} (Check this is the correct name)
Restrict range: false (you can set this to true, but then you should disable the above By Location, and you need to think about the appropriate range for the command).
What happens is
You place a planet piece on the map.
This triggers that the command endOnMap is sent to the planet piece
Because the planet is in the zone PlayArea, the endOnMap command executes 3 other commands:
Increment the global planet counter
Grab the current global planet counter as the value for the planets ID (PlanetNumber)
Issue the command goHome to all pieces on the map that has the property HomePlanet and for which the HomePlanet value is equal to the planets PlanetNumber property value.
Destination: Any counter, selected by properties or Nearest counter, selected by properties
Expression: {PlanetNumber == $HomePlanet$} ($...$ referes to values in source piece)
Hopefully these ideas can help you along - if not exactly what you need, then perhaps serve as an inspiration.
Also, remember to flag the post, including your own - if applicable, that solve your problem as solution. That really help others find solutions to their challenges. Only you @awaxy, as the OP can do that. Thanks.