Introduction of a waiting time

Hi to all.

Is it possible to introduce a waiting time between the execution of one trigger action and the following one, or, alternatively, to introduce a stop before executing the next trigger action? All trigger actions are performed in rapid succession and it is only possible to see the final total effect and not the intermediate ones.

Tank you for your support on this matter.

Panther_2010

I did try to do this, but had no success. I was only able to hang the UI for a time with no refresh.

What is your aim? To implement some sort of animation?

You could do an “empty” trigger action with an associated report trait that contains an Alert. E.g., your primary trigger is A, which should do B and C, but you want a pause between B and C.

A -> B -> C 

So let’s introduce another trigger action D between B and C, and a report trait R that reacts to D

A -> B -> D (triggers R) -> C

and R contains an Alert line in the report attribute. This should make the trigger chain stop after D and wait for the user to dismiss the Alert pop-up. The D trigger action has no actionKeys.

Anyways, my 2 ¢ - haven’t tried it.

Yours,
Christian

1 Like

That works, and Alert() is the only way to do it.

In one of my modules, flipping over exploration tokens has one of a few effects that each require some bookkeeping, and the token is immediately discarded. Instead of relegating everything to a report, I had an alert pause so the face up token could be seen, and the effects announced. When the player clicks OK, everything is resolved.

Whether this is better than just cutting out the additional click and reporting what happened is debatable, but it works.

Couple of random blind and probably off-the-mark ideas…

What if Alert() were cloned and the message parts replaced by the delay functionality ?

Is this any help or are you beyond that ?

The case I was investigating was trying to make it happen between actions in a single trigger. Having delays between different triggers is a different issue.

@Benkyo are you saying that running a series of different triggers, an Alert() in a later trigger reveals the changes from the Triggers up to that point?

@panther_2010, which where you looking for? Delay (with refresh) between triggers or between Key Commands in a single trigger?

What if Alert() were cloned and the message parts replaced by the delay functionality ?

If Alert() is working in some cases to refresh the UI, then it’s because it is displaying a UI element, the message. The problem I had was that a simple delay does not affect the UI, so it never updates.

I just checked, and no. In my case, a single trigger

  1. changed two layer traits, revealing the other side of the piece
  2. set a dynamic property the value of which was an Alert()
  3. did the bookeeping
  4. discarded the piece

None of those involved further triggers.

The effect is the alert popup while the piece is shown after the layer changes. The bookkeeping and the discard happens after the alert is acknowledged.

Ok Thanks Ben.

That has given me another idea to try.

Ok, Found a super hacky solution, but it seems to work.

Added functions

Sleep(ms) to Sleep for a bit. Screen refreshes
Alert(text, ms) to close an Alert Box automatically after a delay.

Test build is the ‘Delay’ build in Builds of vassalengine/vassal.

2 Likes

First of all I must thank all of you for the answers to my question.

The Brent’s super hacky solution is simply great!

I need to have a delay (with refresh) a) between triggers and b) between groups of triggers within a loop.

Thank you!

:grinning:

Hello everyone,

I recently needed to create an animation to make my dice “roll.” Until now, I was only using a “Layer Trait” with 2 colours to indicate that the die had been rolled. However, this approach works moderately well with a game that has many dice of different colours.

So, I am sharing with you what I did to create this animation.

What I need

Before describing the functionality, here is a list of my requirements:

  • I need to have an animation on one or more dice to indicate that they are rolling.
  • This animation should only apply to the selected dice.
  • This animation can be triggered via a menu button, or through a “Menu Command” or “Key Command.”
  • The animation should not be too long, and all dice should animate simultaneously (rather than one after the other).
  • I would like to have a message in the “Chat Log” displaying the result.

How I represent a dice

Firstly, I represent the different faces of my die with a “Layer Trait”. I have a “Named Command” to increment (“Increment”) and another to randomise (“Randomize”). The “Level name” must correspond to the displayed face of the die.


This “Layer Trait” is in the “Dice Red” prototype definition, which use the “Dice” prototype definition.

The “Dice” prototype definition has these traits:


The “Basic Name” trait is included here to ensure that the “Basic Name” is equal to “Dice”. This value will be used to create a “Pre-select (Fast Match)” in a “Global Key Command”.

The logic in the pieces

Trigger the action from the dice

There is then a “Trigger Action” that provides the user with an option to roll one or more dice. This “Trigger Action” will actually initiate these different “Key Commands”:

  • CheckAndSetGlobalProperty
  • DecrementGlobalProperty
  • CheckAndStartLoop

CheckAndSetGlobalProperty

“CheckAndSetGlobalProperty” is used in the following “Trigger Action”, which checks that the “Global Property” “NumberDiceSelected” is equal to 0. If this is the case, the “Key Command” “SetGlobalProperty” is triggered.

“SetGlobalProperty” is used in the “Set Global Property Trait” to set the number of selected dice into “NumberDiceSelected”.


NumberDiceSelected

In summary: if the user selects multiple dice and triggers the “Roll” action, the number of selected dice is placed in “NumberDiceSelected” if it is equal to 0 (which means it has not yet been defined).

Note: I would like to remind you that when the user selects multiple pieces and triggers an action on them, Vassal will call that action on each of the selected pieces.

DecrementGlobalProperty

“DecrementGlobalProperty” is used to decrement “NumberDiceSelected” (as shown in the “SetGlobalProperty” image).

CheckAndStartLoop

“CheckAndStartLoop” serves a similar purpose to “CheckAndSetGlobalProperty”. It checks if “NumberDiceSelected” is equal to 0; if so, it triggers the “Key Command” “StartLoopPiece”.

“StartLoopPiece” is simply used to trigger the “Global Hotkey” “StartLoop”, which will initiate the animation loop.
StartLoopPiece

Summary

For each piece selected by the user, the “Roll” action will be triggered. The first piece triggered will set “NumberDiceSelected”, and then each subsequent piece will decrement “NumberDiceSelected” until the last piece triggers the loop.

Construct the message for the “Chat Log”

Each time “Randomize” is called, we will concatenate the “Global Property” “RollMessage” with the “PieceName” property that corresponds to the value of the die.


RollMessage

The logic in the module

A portion of the logic that enables the animation is defined at the module level.
Loop Folder

Loop management

The “Action Button” “Roll” will be triggered when a user presses it or when “StartLoop” has been initiated. It will first trigger the “Hotkey” “LoopStart” (not to be confused with “StartLoop”), then it will trigger the “Hotkeys” “Loop” and “Sleep” 10 times (chosen arbitrarily), and finally, it will trigger the “Hotkey” “LoopEnd”.

LoopStart

“LoopStart” is used by a “Change-property Toolbar Button” attached to “RollMessage” to reset “RollMessage”.

Loop

“Loop” is used in a “Global Key Command” that will trigger “Increment” on each of the selected dice.

Sleep

“Sleep” is used in a “Global Key Command” that will trigger the “Global Key Command” “SleepPiece” on a piece that has the “Basic Name” “SleepPiece”. This piece is placed outside the play area (-1000, -1000) and contains a “Dynamic Property” “SleepPiece” that holds the “Key Command” “SleepPiece”, allowing the use of the “Sleep” function for 50 ms (chosen arbitrarily).


LoopEnd

“LoopEnd” is used once in a “Global Key Command” that will trigger “Randomize” on each of the selected dice. It is then used a second time in another “Global Key Command” that will display the result message in the “Chat Log”.





And there you go, it is quite complex, but it works well. Please feel free to let me know if you have any suggestions for improvements!

1 Like