[ACS] How to delay button re-use?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
TheGameratorT
Posts: 63
Joined: Sun Mar 04, 2018 4:42 am
Graphics Processor: nVidia with Vulkan support
Location: Portugal
Contact:

[ACS] How to delay button re-use?

Post by TheGameratorT »

So I have a door that opens and closes, but I can't delay the re-use of the button and that causes the door to be closed while the game thinks it's opened if the button is clicked while closing.
This is my current code:

Code: Select all

Script 200 (void)
{
	If(Power > 1)
	{
		If(DoorLeftClosed)
		{
			Door_Open(38, 64);
			DoorLeftClosed = DoorLeftClosed+1;
		}
		Else
		{
			Door_Close(38, 64);
			DoorLeftClosed = DoorLeftClosed-1;
		}
	}
}
User avatar
m8f
 
 
Posts: 1445
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Manjaro Linux
Location: Siberia (UTC+7)
Contact:

Re: [ACS] How to delay button re-use?

Post by m8f »

1. Create a variable oldUseTick, initialize it to zero somewhere (maybe in ENTER script)
2. On your button use, check: if (Timer() > oldUseTick + delay)
3. If check succeeds, set oldUseTick to value returned by Timer() and go on processing button use.
User avatar
KeksDose
 
 
Posts: 595
Joined: Thu Jul 05, 2007 6:13 pm
Contact:

Re: [ACS] How to delay button re-use?

Post by KeksDose »

Or just use [wiki]TagWait[/wiki](38). This can delay script ending until the door finished moving. It won't play as expected with Acs_ExecuteAlways, though, but for one door, it should be okay.

And map scope vars can be initialised with declaration, so you don't need a script to do that if you go there.
User avatar
TheGameratorT
Posts: 63
Joined: Sun Mar 04, 2018 4:42 am
Graphics Processor: nVidia with Vulkan support
Location: Portugal
Contact:

Re: [ACS] How to delay button re-use?

Post by TheGameratorT »

Thx for the help guys :)

It's working now! :D
Post Reply

Return to “Scripting”