Create account / Log in

Using Alert()

Issues with the Vassal engine.

Moderators: uckelman, Tim M

Re: Using Alert()

Postby shilinski » May 30th, 2020, 8:50 am

m3tan wrote:I was able to get this working, but don't have a second computer handy. Do you know who sees these alerts? Is it the active player? Everybody? Or is it map-based?

Good question. I ran a test, and only the player who issued a command to cause it got the message, so you can't suddenly broadcast to everyone "winner! winner! chicken dinner!"
shilinski
 
Posts: 170
Joined: December 22nd, 2007, 8:46 am
Location: Laurel, Maryland

Re: Using Alert()

Postby m3tan » May 30th, 2020, 8:58 am

Bummer. I was hoping to use it for interrupts, preempts, op fire etc...

I wonder if there is a way to GKC it to something that everyone would see...
User avatar
m3tan
 
Posts: 189
Joined: August 12th, 2018, 11:49 pm

Re: Using Alert()

Postby Brent Easton » May 30th, 2020, 11:25 am

Good question. I ran a test, and only the player who issued a command to cause it got the message, so you can't suddenly broadcast to everyone "winner! winner! chicken dinner!"


Strange. That should not happen if both clients are running the same version of the module, the same beanshell should get executed against the same properties on both clients and issue the Alert to each player on their own machine.
User avatar
Brent Easton
 
Posts: 3168
Joined: December 21st, 2007, 3:06 am
Location: Berry, NSW, Australia

Re: Using Alert()

Postby jrwatts » May 30th, 2020, 12:06 pm

Brent Easton wrote:
Good question. I ran a test, and only the player who issued a command to cause it got the message, so you can't suddenly broadcast to everyone "winner! winner! chicken dinner!"


Strange. That should not happen if both clients are running the same version of the module, the same beanshell should get executed against the same properties on both clients and issue the Alert to each player on their own machine.


Perhaps it's intentional? In any case, please don't change that behavior--we use Alert() in the Terraforming Mars modules to provide additional instruction when a player has to place a tile which has special placement restrictions. It would be rather annoying if the Alert pop-ups were visible to all the players.
jrwatts
 
Posts: 88
Joined: April 29th, 2020, 10:30 pm

Re: Using Alert()

Postby Brent Easton » May 30th, 2020, 12:39 pm

Aha. I know what is happening and no, we won't be changing the existing behavior.

Technical blah: The reason the Alert box is not being seen by other players is that the Alert box does not generate a Command as such, it is just the side effect of the execution of a piece of Beanshell during the creation of a Command in the source client (Assuming the Beanshell is even executing during creation of Command, which is not necessarily true). However, the generated Command has already incorporated the results of the Beanshell execution so that the destination clients don't actually run the Beanshell at their end, they just use the results of the Beanshell calculations sent through from the source to directly update their state.

So, in a nutshell, if we want a Dialog popup that will be seen by other players, the behavior has to be incorporated into a Command that is sent through sendAndLog() and a Beanshell function inside the Expression Evaluator is not the place to do it. It really has to built into a new Trait. Good starter project for you m3tan :)
User avatar
Brent Easton
 
Posts: 3168
Joined: December 21st, 2007, 3:06 am
Location: Berry, NSW, Australia

Re: Using Alert()

Postby Cattlesquat » May 31st, 2020, 3:01 am

Good starter project for you m3tan


"Baby's First Custom Class!!!!"
User avatar
Cattlesquat
 
Posts: 890
Joined: December 2nd, 2019, 4:57 pm
Location: Baltimore, Maryland, USA

Re: Using Alert()

Postby m3tan » May 31st, 2020, 2:53 pm

Cattlesquat wrote:
Good starter project for you m3tan


"Baby's First Custom Class!!!!"


Yeah not happening anytime soon. ;-) I have 2 games I need to build Vassal modules for and my programming background led me unrealistic timeframes as to how quickly I could finish them. I recognize now that Brent and others have done a standup job of morphing Vassal to do things it was never intended to do, but this whole BeanShell vs. Classic learning curve has probably put me at 100 hours for stuff I could have accomplished in 20 hours if it wasn't a total newb. I figured it would have divided my normal output by about 2-3X, but it's been about 5X. The real pain was going back and completely rewriting stuff that I thought would work, once I found out the hard way it wouldn't...
User avatar
m3tan
 
Posts: 189
Joined: August 12th, 2018, 11:49 pm

Re: Using Alert()

Postby sunnywilson09 » June 7th, 2020, 11:28 am

I have had no problem with putting global properties at different levels as long as I obey the scoping rules it forces. I suppose selectively restricting commands would work, but I'm not looking for a different solution to my credits problem. I am looking for an answer on alert(), and the credits problem is just an example to better illustrate what I want to do.
sunnywilson09
 
Posts: 2
Joined: June 7th, 2020, 11:27 am

Re: Using Alert()

Postby sunnywilson09 » June 7th, 2020, 8:47 pm

An expression is converted into a small program fragment and 'compiled' which returns a list of undeclared variables. The undeclared variables will be references to Vassal properties. At run-time when the expression is evaluated, the undeclared variables are created as temporary variables and set to the value of the corresponding Vassal property before evaluation.

Writing values back into Vassal properties is beyond the scope of the 'Expression evaluation' use case and Vassal is (mostly) not built to handle it.

Regards
sunnywilson09
 
Posts: 2
Joined: June 7th, 2020, 11:27 am

Re: Using Alert()

Postby Benkyo » June 29th, 2020, 11:57 pm

Can alert include $$ strings, or global properties in some way? Or should I use ? : with unique alerts?
Benkyo
 
Posts: 256
Joined: March 13th, 2013, 11:02 pm

Re: Using Alert()

Postby jrwatts » June 30th, 2020, 2:37 am

$$ strings work just fine.
jrwatts
 
Posts: 88
Joined: April 29th, 2020, 10:30 pm

Re: Using Alert()

Postby Benkyo » June 30th, 2020, 4:19 am

Oh wow, I do like alerts. Old me would have just assumed a player would look to the reports to see what happened, but now I think that alerts are a very nice way to avoid player confusion due to a set sequence of consequences being resolved instantly. For example, you can pause mid-trigger to tell a player exactly what will happen next, just after a visual layer change on a piece and just before the piece gets deleted.
Benkyo
 
Posts: 256
Joined: March 13th, 2013, 11:02 pm

Re: Using Alert()

Postby Benkyo » June 30th, 2020, 5:14 am

Just one question: What is the best low-impact way to trigger an Alert() from a key command, independent of a calculation? Currently I have a pointless "send to location" trait with the destination being a Zone {0+Alert("text here")} to trigger the Alert, but is there a better way to do it?
Benkyo
 
Posts: 256
Joined: March 13th, 2013, 11:02 pm

Re: Using Alert()

Postby Brent Easton » June 30th, 2020, 5:57 am

That's probably the most inconvenient part of this, actually getting the Alerts to trigger at the right time.

Possibly using a Dynamic Property. You can set up different commands to set the value directly and the value to set could then just be {Alert("a message")}. Then you can set up all of your alerts in one place with different Named Key Commands and fire them off when needed from triggers.
User avatar
Brent Easton
 
Posts: 3168
Joined: December 21st, 2007, 3:06 am
Location: Berry, NSW, Australia

Re: Using Alert()

Postby Benkyo » June 30th, 2020, 6:02 am

I see, thanks. So there's no need for the new value to be a value? Each key command would just change the dynamic property from null to null?
Benkyo
 
Posts: 256
Joined: March 13th, 2013, 11:02 pm

PreviousNext

Return to Technical Support & Bugs

Who is online

Users browsing this forum: No registered users and 2 guests