Create account / Log in

Trigger referencing property ref other property value

Talk about module design ideas and techniques.

Moderators: uckelman, Tim M

Trigger referencing property ref other property value

Postby Benkyo » April 20th, 2021, 2:21 am

OK, I'm sure this should be relatively simple, but I hope someone can spell it out for me anyway.

PlayerSide: possible values Red Blue Yellow etc. (this determines which hand you can view)
Red: possible values Player2, Player3, etc. (this indicates which seat at the table is associated with which colour)
Blue: possible values Player2 etc.
Yellow: possible values Player2 etc.

Got a global key command "Rest", which I want to only target a RestControl.

RestControl traits have some triggers, and a given trigger should only activate based on the following check: the PlayerSide that clicked rest corresponds to which value among Player2, Player3, etc., via the GPs Red, Blue, etc. That determines which pieces will be affected by more triggered global key commands.

I think I need some combination of GetProperty() and maybe $$ signs, but my sleep-deprived brain is coming up with only things that don't work.
Benkyo
 
Posts: 389
Joined: March 13th, 2013, 11:02 pm

Re: Trigger referencing property ref other property value

Postby Cattlesquat » April 26th, 2021, 8:53 pm

If the property PlayerSide contains the string Red, and the property Red contains the string Russians, then:

* GetProperty("PlayerSide") would return "Red"
* GetProperty("Red") would return "Russians"
* GetProperty(PlayerSide) would return "Russians"

The last one of those is an example of how to doing the kind of indirect reference it sounds like you need.

If you needed to go ANOTHER level of indirection, imagine that a property Russians contained Communists, then:

* GetProperty(GetProperty(PlayerSide)) would return "Communists"

Brian
User avatar
Cattlesquat
 
Posts: 1141
Joined: December 2nd, 2019, 4:57 pm
Location: Baltimore, Maryland, USA

Re: Trigger referencing property ref other property value

Postby rprasadusa » May 5th, 2021, 3:00 pm

Related (I think) question: players in the game will each have a specific color (Red, Blue, etc.). How to I set up a text label to display the playerName for each color?
rprasadusa
 
Posts: 11
Joined: September 6th, 2020, 6:03 pm

Re: Trigger referencing property ref other property value

Postby marktb1961 » May 5th, 2021, 7:33 pm

I guess you have realised that you will need a means of associating each label with its player, hence the question.

One relatively simple way would be to make each text label an Action Button.
Have the players click on their side's label when they join the game.
The Action Button should trigger setting a Dynamic Property that will store the playerName, making it available to display to the other players.

The Text Label will display the value of the Dynamic Property.

You might use a Command Restriction so that only the Red side player can click on the Red side button etc.

If the initial value of the DP (let's call it "dName") is null you could use something like this Beanshell as the Text in the Text label -
{ dName == "" ? (playerSide=="Red" ? "Click Here" : "") : dName }
So this would prompt the Red player (only) to click on that label.

You can use basic HTML to format the text label &/ or superimpose it on an image/piece.

By careful putting Beanshell into text labels; Vassal tolerates it but is prone to infinite loops is the beanshell is invalid.

Hope that helps.

Mark
Platform: Vassal 3.5.6, MacOS Big Sur on iMac (27", mid-2020)
User avatar
marktb1961
 
Posts: 602
Joined: October 4th, 2018, 2:36 pm
Location: Liverpool, England

Re: Trigger referencing property ref other property value

Postby rprasadusa » May 8th, 2021, 6:27 pm

Thanks! That mostly works for me, except I couldn't get the text label itself to be clickable. Instead, I had to add a graphic icon, which can be clicked. But that's good enough!
rprasadusa
 
Posts: 11
Joined: September 6th, 2020, 6:03 pm

Re: Trigger referencing property ref other property value

Postby jrwatts » May 8th, 2021, 8:42 pm

FYI, Action Buttons default to being 40x40 pixels (IIRC) at the center of the piece; you need to change the dimensions if you want the entire piece (text label, in this case) to be clickable. I've found it works fine to make the Action Button bigger than the piece; it won't actually extend past the edges no matter how large you set it.
jrwatts
 
Posts: 331
Joined: April 29th, 2020, 10:30 pm

Re: Trigger referencing property ref other property value

Postby rprasadusa » May 9th, 2021, 10:36 am

I'd already tried that at button size 40x200 and failed to successfully click all over it! I assumed it was the funny beanshell text format that was screwing Vassal up.
rprasadusa
 
Posts: 11
Joined: September 6th, 2020, 6:03 pm


Return to Module Design

Who is online

Users browsing this forum: No registered users and 3 guests