Create account / Log in

Using Alert()

Issues with the Vassal engine.

Moderators: uckelman, Tim M

Re: Using Alert()

Postby Brent Easton » June 30th, 2020, 6:09 am

Yep. It's the side effect of the Alert() function we are interested in, not the action of the actual command. It's not going to generate a Command to send to other players since the DP value doesn't change, but that's fine, since they don't see the Alert box anyway. So it's a pretty good solution.
User avatar
Brent Easton
 
Posts: 3168
Joined: December 21st, 2007, 3:06 am
Location: Berry, NSW, Australia

Re: Using Alert()

Postby m3tan » June 30th, 2020, 7:04 am

I've pretty much figured out how to place an alert anywhere a Beanshell expression is allowed. The trick is that Alert has a null value so you can add it to pretty much anything without impacting the rest of the expression. Combined with the recently discovered ? function and you can do some pretty neat stuff like:

{(Resources==0)?0+Alert("You have insufficient resources"):-1}

The possibilities go on and on...
User avatar
m3tan
 
Posts: 189
Joined: August 12th, 2018, 11:49 pm

Re: Using Alert()

Postby m3tan » June 30th, 2020, 3:50 pm

I'd also add that Alert() can handle expressions. Since I'm using them extensively, I created a generic Alert prototype to assemble them quickly and without typos. I just need to insert the prototype then define three variables called Restrict, Message, and Value that are typically Calculated Properties or Markers. The Prototype then uses the expression:

{(Restrict==true)?0+Alert(Message):Value}

Message contains any concatenated text I want.
User avatar
m3tan
 
Posts: 189
Joined: August 12th, 2018, 11:49 pm

Re: Using Alert()

Postby barbanera » June 30th, 2020, 4:36 pm

Pretty interesting thread, much to learn and experiment with.

So far my Alert usage was doing things like:

1) a Trigger trait fires on some command when some condition is met, issuing a reportError command

2) the reportError command is just firing a Report Action trait set to display $Error$

3) Error is a calculated property set to "Alert("Stupid! Stupid!") or something such

Pretty convoluted, I gather.
barbanera
 
Posts: 395
Joined: January 12th, 2012, 2:27 pm

Re: Using Alert()

Postby marktb1961 » July 16th, 2020, 10:59 am

"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?"


Guessing you got the answer to this already. This is based solely on my experience and interpretation:-

The Active Player (only) sees the alert.

Also, the alert must be acknowledged before the Active Player's session will proceed.

I've been finding Alert() it very usable/useful, typically as a component of conditional statements using "?".

Here's a simple example of an Alert placed in a Trigger conditional expression. The Trigger Key executes this test along with
other triggers that fire for the other values of gblDeckChoice. The conditional tests would be further development for situations where commands need to fire within the trigger itself.

{(gblDeckChoice<1 || gblDeckChoice>3) ? Alert("Deck Setup Error. Try restarting & report error to maintainer."):0 }
Platform used:
Vassal 3.4.2
MacOS Catalina
MacBook Pro (13-inch, 2016)
User avatar
marktb1961
 
Posts: 200
Joined: October 4th, 2018, 2:36 pm
Location: Liverpool, England

Re: Using Alert()

Postby m3tan » July 17th, 2020, 3:15 pm

Mark,

I can confirm all the behavior you describe. I'd also add that the placement of the Alert within traits has a UI aesthetic. The alerts can feel disjointed if they appear midstream in a process, like after a piece is removed, but before it has been replaced. Thus sometimes triggers are not the best place to insert Alerts. In that case, I'll create a Dynamic Property called Alert (although name is irrelevant) and place it wherever I want.
User avatar
m3tan
 
Posts: 189
Joined: August 12th, 2018, 11:49 pm

Re: Using Alert()

Postby marktb1961 » July 17th, 2020, 7:43 pm

m3tan wrote:Mark,

I can confirm all the behavior you describe. I'd also add that the placement of the Alert within traits has a UI aesthetic. The alerts can feel disjointed if they appear midstream in a process, like after a piece is removed, but before it has been replaced. Thus sometimes triggers are not the best place to insert Alerts. In that case, I'll create a Dynamic Property called Alert (although name is irrelevant) and place it wherever I want.


Thanks for the tip. I think the trigger in the example (above) is ok as it is an alternative path and not an interrupt within a process but I had noticed the issue elsewhere, so I will consider Dynamic Property as an alternative.
Platform used:
Vassal 3.4.2
MacOS Catalina
MacBook Pro (13-inch, 2016)
User avatar
marktb1961
 
Posts: 200
Joined: October 4th, 2018, 2:36 pm
Location: Liverpool, England

Re: Using Alert()

Postby marktb1961 » August 2nd, 2020, 10:41 pm

Might be worth mentioning that Alert() can be a useful debugging tool. I am using it at the moment to trace the path of a loop through a sequence of Triggers.

Also, surprisingly (to me), all the output up to the point of the Alert() is also completed. Without the Alert() the output would just be held back until the entire operation completes.
Platform used:
Vassal 3.4.2
MacOS Catalina
MacBook Pro (13-inch, 2016)
User avatar
marktb1961
 
Posts: 200
Joined: October 4th, 2018, 2:36 pm
Location: Liverpool, England

Re: Using Alert()

Postby m3tan » August 3rd, 2020, 1:55 am

marktb1961 wrote:Might be worth mentioning that Alert() can be a useful debugging tool. I am using it at the moment to trace the path of a loop through a sequence of Triggers.

Also, surprisingly (to me), all the output up to the point of the Alert() is also completed. Without the Alert() the output would just be held back until the entire operation completes.

Yup. That makes it useful as a debugging tool which I certainly used it for that, but I'd prefer if it didn't cause Vassal to come to a screeching halt. It would be a great way to distract players while you execute a ton of GKCs in the background. Sadly, if anything, it accentuates the delays if you put Alert in the wrong place...
User avatar
m3tan
 
Posts: 189
Joined: August 12th, 2018, 11:49 pm

Re: Using Alert()

Postby Brent Easton » August 3rd, 2020, 2:41 am

So, you'd like an extra argument to the Alert function to be able to create non-modal dialogs (Ones that don't halt progress and stuff still happens in the background)? You would want to be extremely careful in their use or you will end up with a hundred dialog boxes on top of each other before you know it. Obviously would not be useful for debugging.

The current

Alert ("A message")

would continue to function as it is, but your could use the alternate

Alert ("A message that appears while stuff still happens", false)

where the second parameter specifies whether to halt Vassal execution or not.

Is that it in a nutshell?

What about a parameter to auto-disappear the box after so many seconds?

Don't hold back :)
User avatar
Brent Easton
 
Posts: 3168
Joined: December 21st, 2007, 3:06 am
Location: Berry, NSW, Australia

Re: Using Alert()

Postby Benkyo » August 3rd, 2020, 2:55 am

FWIW, I would love to see that functionality in the user-set Dynamic Property pop-up boxes. For example, I have an automated set-up that first asks which player sides are in the game, setting a dynamic property selected from a list for which setup definitely needs to pause, then asks the user to name each player, during which time it would be much better if setup proceeded regardless of the name input.
Benkyo
 
Posts: 256
Joined: March 13th, 2013, 11:02 pm

Re: Using Alert()

Postby m3tan » August 3rd, 2020, 3:45 am

Brent Easton wrote:So, you'd like an extra argument to the Alert function to be able to create non-modal dialogs (Ones that don't halt progress and stuff still happens in the background)? You would want to be extremely careful in their use or you will end up with a hundred dialog boxes on top of each other before you know it.

What about a parameter to auto-disappear the box after so many seconds?

Don't hold back :)


I come from the world of UI design so I guess I'm especially cognizant of these types of things. How would you end up with tons of dialog boxes on top of each other? To prevent that, don't let the player do anything else unless he clicks OK. I'd prefer it that way anyway. Just don't halt the processing in the background. Then Alert becomes a great way to mask slow modules...

The timer is a nice-to-have, but again in the world of UI, we prefer to force them to click OK - even though end users still don't read the pop-up half the time anyway...
User avatar
m3tan
 
Posts: 189
Joined: August 12th, 2018, 11:49 pm

Re: Using Alert()

Postby Brent Easton » August 3rd, 2020, 4:00 am

but I'd prefer if it didn't cause Vassal to come to a screeching halt.


If you allow Alert() boxes to not halt Vassal, then a later Alert() box will pop up another one over the top of the first before you close it. If you are using non-modal Alert() boxes to debug, and 100 units pop them up in response to a GKC, then you will have 100 Alert() boxing appearing at the same time on top of each other. I am just saying you would need to be careful in the use of the non-modal boxes and use the standard Modal boxes for debugging.
User avatar
Brent Easton
 
Posts: 3168
Joined: December 21st, 2007, 3:06 am
Location: Berry, NSW, Australia

Previous

Return to Technical Support & Bugs

Who is online

Users browsing this forum: No registered users and 4 guests

cron