Scripting Variable

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
Misery
Posts: 157
Joined: Sun Nov 04, 2018 4:57 pm

Scripting Variable

Post by Misery »

I am scripting an elevator by lowering the floor and ceiling by a certain amount. The next script is the door, which only activates by script. But I need the door script to be unable to be activated until the elevator reaches a certain floor Z height, but can't figure out how to word the variable statement. Any assistance I may request on this?
User avatar
TheMightyHeracross
Posts: 2100
Joined: Sun Aug 18, 2013 9:41 am
Location: Philadelphia, PA

Re: Scripting Variable

Post by TheMightyHeracross »

Something like this should do the trick:

Code: Select all

//Let "tag1" be the sector tag of the elevator
//Let "tag2" be the sector tag of the door
//Let "height" be your chosen height (fixed point, so it must have a decimal point)

script "DoorScript" (void)
{
	if(GetSectorFloorZ(tag1, 0, 0)  <= height )//If elevator floor is at or below this height at the moment of activation...
	{
		Door_Raise(tag2, speed, delay, lighttag);//...door successfully opens
	}
}
Obviously the speed, delay, etc. of the door is your choice.

[wiki]GetSectorFloorZ[/wiki]
Post Reply

Return to “Scripting”