Create account / Log in

Tracking a non active piece traits question

Topics related to Vassal game modules.

Moderators: uckelman, Tim M

Tracking a non active piece traits question

Postby ChuckS » April 27th, 2021, 8:48 pm

I've got a simply Frigate vs Submarine module I am working on to try and understand how to track when the sub is submerged. Can I use the layer names to track a unit that is not selected somehow so that when the frigate moves that move will trigger a check of what layer name the sub has active? So piece name . layer name == "submerged" something along that.

Sorry it's been 30 years since I wrote code of any type.
ChuckS
 
Posts: 135
Joined: August 16th, 2016, 4:37 pm

Re: Tracking a non active piece traits question

Postby jrwatts » April 27th, 2021, 11:49 pm

Try the Help button on the Layer trait--it will give you most of the information you need. In particular, at the bottom of the help text it tells you that "<layer_name>_Name returns the name of the currently-active level". Note that this property is not accessible from outside the piece, so you would also need a Global Property (GP), and whenever the submarine's level changes, use a Set Global Property trait to change that GP to match the new level name. This, in turn, means you will want to disable the menu commands for altering the layer's level, and instead add Trigger Actions that will call the Key Command for altering the level and then call the Set Global Property immediately afterward.

Now your Frigate piece can check that GP to find the submarine's state.

There are multiple other ways of doing this, too, but that's the first one that came to mind (for another example, instead of using Trigger Actions to immediately set the GP whenever the layer's level changes, you could instead use a Global Key Command from the Frigate piece to trigger the Set Global Property just before the Frigate piece checks the value).
jrwatts
 
Posts: 334
Joined: April 29th, 2020, 10:30 pm

Re: Tracking a non active piece traits question

Postby ChuckS » April 28th, 2021, 1:59 am

Thanks! I was thinking I would have to resort to global variables to do this. I was hoping to avoid having to set it up for each ship as I want to build this double blind with no need of a moderator and drive the reveals on each player board based on range to target and speed of the target and the listening unit. Then once found have a target unit placed on the finding players map with a variable amount of altered distance again based on distance, speed of each unit etc. That way the Frigate team is just as blind at times as the sub team would be when submerged.
ChuckS
 
Posts: 135
Joined: August 16th, 2016, 4:37 pm

Re: Tracking a non active piece traits question

Postby jrwatts » April 28th, 2021, 7:31 am

If you're using a hex or square grid, my alternate idea would work fairly well with that (assuming there's only a single submarine piece; if there are multiple submarines, things get trickier!)--you can have a frigate piece send a Global Key Command to other pieces within a certain range, so then the sub would only update the GP if it's within range to receive the GKC. You would, however, also need some sort of way of telling whether or not the GP had actually changed. One way would be to have a second, "flag" GP, that you set to false from the frigate piece before sending the GKC, and then the submarine piece sets to true when it receives the GKC...if it's still false after sending the GKC, the sub wasn't in range.
jrwatts
 
Posts: 334
Joined: April 29th, 2020, 10:30 pm


Return to Module General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests