I need some help

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.

What code have you written so far?

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.

Yours,
Christian

Thanks so much for the reply. I don’t really know what I’m doing here but this is what I’ve been trying. Please help

My planet counter has:

Triggeraction =>FetchUnit { CurrentZone == “PlayArea” }

Place Marker - FetchUnit

Prototype: PlanetCounter Which includes

Dynamic Property - PlanetNumber == SetNumber ($PlanetCounter$)

TriggerAction PlanetPlaced (CurrentZone == “PlayArea” && OldZone != “MainMap”)

TriggerAction PlanetPlaced => SetNumber

Global Key Command - - IncrementGlobal

my marker has

Keycommand FetchUnit

Menu command SendHome

Set Dynamic properties in marker: Homeworld $PlanetNumber$

Send to Location - SendHome (property match PlanetNumber && UnitNumber)

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

  1. You place a Planet piece in the zone PlayArea and its previous location was not the zone MainMap.
  2. You then want to assign it a number (where does that number come from? A Global/Map Property? How is that number incremented?)
  3. When the Planet piece is put in the PlayArea you want to place - using Place Marker trait - a Marker piece on that planet piece.
  4. You want the Marker piece to get the number of the planet, just assigned to the Planet piece.
  5. 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 Zone PlayArea. Let’s say the command is set to the named command endOnMap.

Then, you add the following traits to you Planet pieces

  • Trigger Action
    • Key: endOnMap
    • Property: {CurrentZone == "PlayArea" && OldZone != "MainMap"} (check that logic, in particular the OldZone comparison - is there a zone called MainMap?)
    • Action keys: [incrementPlanetCounter, grabPlanetCounter, placeMarker]
  • Set Global Property
    • Name: PlanetCounter
    • Commands:
      • Key: incrementPlanetCounter
      • Type: Direct
      • Expression: {PlanetCounter+1}
  • Dynamic Property
    • Name: PlanetNumber
    • Commands:
      • Key: grabPlanetCounter
      • Type: Direct
      • Expression: {PlanetCounter}
  • Place Marker
    • Key: placeMarker
    • Select: Marker (adjust for actual marker piece path)
    • Set Dynamic Properties in marker
      • Name: HomePlanet
      • Expression: {$PlanetNumber$} ($...$ referes to values in source piece)

In your Marker piece, define traits

  • Dynamic Property
    • Name: HomePlanet (do not make this PlanetNumber - may cause problems for the below Send to Location trait).
  • Send to Location
    • Menu: Go Home
    • 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.,

In your Planet pieces

  • Trigger Action
    • Key: endOnMap
    • Property: {CurrentZone == "PlayArea" && OldZone != "MainMap"} (check that logic, in particular the OldZone comparison - is there a zone called MainMap?)
    • Action keys: [placeMarker]
  • Place Marker
    • Key: placeMarker
    • Select: Marker (adjust for actual marker piece path)

In your Marker piece, define traits

  • Send to Location
    • Menu: Go Home
    • Destination: Any counter, selected by properties or Nearest counter, selected by properties
    • Expression: {UniqueID == "$ParentID"} ($...$ referes to values in source piece)

Pretty simple :smiley:

Yours,
Christian

I pruned the file to cut out less relevant parts https://drive.google.com/file/d/1YGEpolalxFBXQJmX0tIBE3Tp5Gop7d5U/view?usp=drive_link

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 Zone PlayArea . Let’s say the command is set to the named command endOnMap .

Then, you add the following traits to you Planet pieces

  • Trigger Action
    • Key: endOnMap
    • Property: {CurrentZone == "PlayArea" && OldZone != "MainMap"} (check that logic, in particular the OldZone comparison - is there a zone called MainMap?)
    • Action keys: [incrementPlanetCounter, grabPlanetCounter, callBackHome]
  • Set Global Property
    • Name: PlanetCounter
    • Commands:
      • Key: incrementPlanetCounter
      • Type: Direct
      • Expression: {PlanetCounter+1}
  • Dynamic Property
    • Name: PlanetNumber
    • Commands:
      • Key: grabPlanetCounter
      • Type: Direct
      • Expression: {PlanetCounter}
  • Global Key Command
    • Key: callBackHome
    • Global Key: goHome
    • Fast select:
      • By property: true
        • Property: HomePlanet
        • Value: $PlanetNumber$
        • Comparison: Equal
      • By Location: true
        • 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

  1. You place a planet piece on the map.
  2. This triggers that the command endOnMap is sent to the planet piece
  3. Because the planet is in the zone PlayArea, the endOnMap command executes 3 other commands:
    1. Increment the global planet counter
    2. Grab the current global planet counter as the value for the planets ID (PlanetNumber)
    3. 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.

In your Marker piece, define traits

  • Marker (or perhaps Dynamic Property)
    • Name: HomePlanet (do not make this PlanetNumber - may cause problems for the below Send to Location trait).
    • Value: ... (the number the of the planet to send to)
  • Send to Location
    • Menu: Go Home
    • Key: goHome
    • 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.

Yours,
Christian

Ok I tried this, and you explain it really well, but it still doesn’t work in my module.

I know this is a big request, but could you make an example and send it to me?

Better if you share your module and give precise instructions on what a player should do and what you would like to see happen.

Yours,
Christian