Create account / Log in

Action button modifying global property

Talk about module design ideas and techniques.

Moderators: uckelman, Tim M

Action button modifying global property

Postby Jym » May 23rd, 2014, 9:49 pm

So, I have a global property -say "Foo"- and I need a global action button on the toolbar that changes it.

The way I am doing it currently is:
* create a counter with a marker trait "foo_controller = true"
* add a "Set global property" trait to that counter in order to modify my global property, eg "incrementFoo" does +1 to Foo.
* add extra layers of protection to that counter (invisible, does not stack, cannot be moved, undeletable, …) so that players don't accidentally screw it.
* create a "global key command" button that send "incrementFoo" to all counters with "foo_controller = true".

That does work but it seems a bit too complicated. I'm not sure why I need to create a local thing (counter) in order to modify global stuff. Moreover, I need to heavily protect the counter as accidentally deleting it would ruin everything (and having a second one would also be bad).
And from a computational point of view, since the "matching property" test of the global key command may depend on Dynamic properties, I guess that every time I click the button, Vassal has to go through all the game pieces to find the proper ones. That obviously takes way more time than needed to perform the task (ie, linear time rather than constant).

So, is there a direct way to have an action button directly modifying a global property? Or a simpler/more efficient way to do it than what I described?
Jym
 
Posts: 13
Joined: January 16th, 2013, 9:15 pm

Re: Action button modifying global property

Postby zmpouf » August 13th, 2014, 3:33 pm

Look for the Change-Property Toolbar Button. It is u sub-component of the Global Property
zmpouf
 
Posts: 24
Joined: August 22nd, 2011, 1:51 pm

Re: Action button modifying global property

Postby Jym » August 28th, 2014, 11:23 pm

Thanks. Just what I needed.
Jym
 
Posts: 13
Joined: January 16th, 2013, 9:15 pm


Return to Module Design

Who is online

Users browsing this forum: No registered users and 9 guests

cron