Create account / Log in

Simple IF statement

Suggestions for additional features for the module editor and Vassal engine.

Moderators: uckelman, Tim M

Simple IF statement

Postby wootersl » May 3rd, 2012, 3:27 pm

A simple IF statement function would be nice that could be used in a global processing area. So you can do simple changes to any item.

For example, I have a piece that I want to check a global variable to determine what layer to show.

I know there are probably long ways to accomplish this. But almost everything must rely on a keystroke. I just think a simple IF statement function would help do a lot of things more simply.
User avatar
wootersl
 
Posts: 69
Joined: December 30th, 2007, 3:37 am

Re: Simple IF statement

Postby uckelman » May 3rd, 2012, 5:13 pm

Thus spake wootersl:
> A simple IF statement function would be nice that could be used in a
> global processing area. So you can do simple changes to any item.
>
> For example, I have a piece that I want to check a global variable to
> determine what layer to show.
>
> I know there are probably long ways to accomplish this. But almost
> everything must rely on a keystroke. I just think a simple IF statement
> function would help do a lot of things more simply.

This will be possible with scripting in V4.

--
J.
User avatar
uckelman
Site Admin
 
Posts: 8593
Joined: December 10th, 2007, 9:48 am
Location: Durham, England

Re: Simple IF statement

Postby irishwulf » May 4th, 2012, 4:50 am

Perhaps I'm not sure exactly what you want to do, but in 3.1 conditional logic is handled with Trigger Action:
Set label to 'Destroyed' if HP < 6:
1) Fire <check_hp_keystroke>
2) On <check_hp_keystroke>, Trigger Action with matching properties: CurrentHP < 6
3) For that Trigger Action, in 'Perform these keystrokes', fire <update_label_keystroke>

In 3.2, there is an 'If' callback for BeanShell expressions. So you could set your label as something like:
{ If(CurrentHP < 6, "Destroyed", "") }
At least that is how I remember the syntax. How often is CurrentHP automatically checked for this text label? I don't remember! Possibly just once, when you first create the piece! You will probably still have to nudge it every time you change the CurrentHP. Not many things in Vassal 3 are very good at actively listening for changes.

-Seth
irishwulf
 
Posts: 243
Joined: December 17th, 2011, 4:29 am


Return to Feature Requests

Who is online

Users browsing this forum: No registered users and 1 guest

cron