Create account / Log in

Restric movement

Issues with the Vassal engine.

Moderators: uckelman, Tim M

Restric movement

Postby Sevijuanillo » December 21st, 2020, 2:04 am

Hello, how can I make a piece not move (drag and drop) until a condition is met, for example until an turn x arrives, and then it can move as one more.
I have not found how to do it, checking the command "restrict" or in "does not stack" but I do not know how I can do it, and here in the forum I have not found a similar situation either.
Thanks
Sevijuanillo
 
Posts: 8
Joined: April 24th, 2020, 10:26 am

Re: Restric movement

Postby jrwatts » December 21st, 2020, 4:14 am

I can't think of any way to prevent the piece from being dragged and dropped before a condition is met, but what you can do is add a "Keystroke to apply when a piece is moved here" to any map board it might be moved to, and then use that keystroke for a Trigger Action that checks the current turn, and triggers a Send to Location back to the original location if it's too soon.
jrwatts
 
Posts: 223
Joined: April 29th, 2020, 10:30 pm

Re: Restric movement

Postby jrwatts » December 21st, 2020, 8:45 am

Option 2: Hide the piece on another board (not easily accessible), then move it to its proper location with a Global Key Command triggered by the turn counter on the appropriate turn.
Option 3: Define most of the piece in a prototype. Have the piece reference the prototype, plus a Does Not Stack trait that makes it immobile, and a Replace With Other trait that replaces it with an identical piece (again, use the prototype) minus the Does Not Stack & Replace With Other traits. Trigger the Replace With Other from a Global Key Command in the turn counter on the appropriate turn.
jrwatts
 
Posts: 223
Joined: April 29th, 2020, 10:30 pm

Re: Restric movement

Postby Sevijuanillo » December 26th, 2020, 12:05 am

Thanks for the answer. I wil try to use one of the two solutions.
Sevijuanillo
 
Posts: 8
Joined: April 24th, 2020, 10:26 am

Re: Restric movement

Postby m3tan » December 26th, 2020, 2:29 pm

jrwatts wrote:I can't think of any way to prevent the piece from being dragged and dropped before a condition is met, but what you can do is add a "Keystroke to apply when a piece is moved here" to any map board it might be moved to, and then use that keystroke for a Trigger Action that checks the current turn, and triggers a Send to Location back to the original location if it's too soon.

That's actually exactly how you prevent pieces from being dragged and dropped. Use a Trigger action with the property match:

{LocationName!=OldLocationName&&Turn<x}

that triggers a Send to Location moving the Piece to {OldLocationName}. I'd also trigger an Alert that reads "You cannot move that piece until turn x!"

I use this same method to prevent players from placing pieces in illegal locations.

PS No biggie, but these types of questions belong in the Module Design forum.
User avatar
m3tan
 
Posts: 232
Joined: August 12th, 2018, 11:49 pm

Re: Restric movement

Postby Sevijuanillo » December 31st, 2020, 2:09 pm

jrwatts wrote:PS No biggie, but these types of questions belong in the Module Design forum.


Hi, sorry to include this thread in this forum but I didn't realize that the appropriate one was "Module Design". If any admin can change it I thank him.

m3tan wrote:
jrwatts wrote:I can't think of any way to prevent the piece from being dragged and dropped before a condition is met, but what you can do is add a "Keystroke to apply when a piece is moved here" to any map board it might be moved to, and then use that keystroke for a Trigger Action that checks the current turn, and triggers a Send to Location back to the original location if it's too soon.

That's actually exactly how you prevent pieces from being dragged and dropped. Use a Trigger action with the property match:

{LocationName!=OldLocationName&&Turn<x}

that triggers a Send to Location moving the Piece to {OldLocationName}. I'd also trigger an Alert that reads "You cannot move that piece until turn x!"

I use this same method to prevent players from placing pieces in illegal locations.


Regarding the problem raised, if I use the option "Key Command to apply to all units ending movement on this map:" to trigger an event to change to the previous location, when I go back to that position again it fires and returns to the position where it moved, and it fires again to return to the initial position and so on in an infinite loop.
And if I only put as a condition to the trigger that {LocationName!=OldLocationName}, without including any keyboard command or waiting for the keyboard, it will never be executed, and I thought that by not putting it I would always be checking it. I have tried to only make a report when it is produced and never give that report by moving the piece.
I think I've reached a dead end and I don't know how to get out
Thanks @jrwatts for your advice.
Sevijuanillo
 
Posts: 8
Joined: April 24th, 2020, 10:26 am

Re: Restric movement

Postby Sevijuanillo » December 31st, 2020, 3:32 pm

Of course thanks to @m3tan too !!!
Sevijuanillo
 
Posts: 8
Joined: April 24th, 2020, 10:26 am

Re: Restric movement

Postby jrwatts » December 31st, 2020, 11:55 pm

Rather than {LocationName!=OldLocationName && Turn < x}, try {LocationName != "<original location name>" && Turn < x}, Where <original location name> is the name of the location you're moving it back to. That way, it should only trigger when it's moved away from the original location, not when it's moved back.

If you're just moving it to coordinates, rather than a named region, use {(CurrentX != <original x> || CurrentY != <original y>) && Turn < x} (again, substituting the correct values) instead. You need the parenthesis because && (logical and) normally has higher priority than || (logical or) in Java.
jrwatts
 
Posts: 223
Joined: April 29th, 2020, 10:30 pm


Return to Technical Support & Bugs

Who is online

Users browsing this forum: No registered users and 8 guests