Button to open and close PolyObject door.

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.

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Button to open and close PolyObject door.

Re: Button to open and close PolyObject door.

by TheGameratorT » Sat Nov 03, 2018 8:01 am

I have already changed to PolyWait(); it turns out I wasn't understanding it's use at the time, but 1 day after that I changed :)

Re: Button to open and close PolyObject door.

by ramon.dexter » Mon Sep 24, 2018 7:13 am

TheGameratorT wrote:I actually don't have any problems with the delay and I think I will keep it because it's the only way to lock the button. (Also the door crushes)

Also thx for the rotating door.
You should believe us when we tell you that delay can and WILL cause problems. When you want to delay something based on the polyobject, you have to use polywait(). The delay will just cause problems and is not intended for this purpose. You can believe me, becuase I spent lot of time tuning out polyobject door scripts. My example works, also it can control up to 1000 doors in a single map.

Re: Button to open and close PolyObject door.

by Zen3001 » Sun Sep 16, 2018 7:48 am

ramon.dexter wrote:Instead of delay() use tagwait() with the corresponding tag. The delay can and will cause problems.
that's something I didn't knew about and really helped the map I'm working on

Re: Button to open and close PolyObject door.

by TheGameratorT » Wed Aug 29, 2018 1:13 pm

I actually don't have any problems with the delay and I think I will keep it because it's the only way to lock the button. (Also the door crushes)

Also thx for the rotating door.

Re: Button to open and close PolyObject door.

by ramon.dexter » Sun Aug 26, 2018 5:47 am

Yep, correct. Forgot that there is PolyWait for polyobjects.

edit: Here, take a look at my "function" scripts - when used, it behaves as a linedef action. The speed is solely for sound purposes (when moving slow, is emits different sound than when moving faster).

Code: Select all

//POLYOBJECT DOORS
//=============================================================================================
//universal door script - one script to rule dem all
//==--------------------------------------------------==
#define MAX_SWINGING_DOORS 1000
bool polyDoor[MAX_SWINGING_DOORS]; //'dynamic' variable = array
//==--------------------------------------------------==
//universal door script with variable sound
//==--------------------------------------------------==
script "polyDRswing_Right" (int poly, int spd)
{
	if(!polyDoor[poly])
	{
		Polyobj_RotateRight(poly, spd, 64);
		if(spd  < 16)
		{
			AmbientSound("DoorCreak", 127);
		}
		else if(spd >= 16)
		{
			AmbientSound("sounds/officeDopen", 127);
		}
		PolyWait(poly);
		polyDoor[poly] = true;
	}
	else if(polyDoor[poly])
	{
		Polyobj_RotateLeft(poly, spd, 64);
		if(spd  < 16)
		{
			AmbientSound("DoorCreak", 127);
		}
		else if(spd >= 16)
		{
			AmbientSound("sounds/officeDclose", 127);
		}
		PolyWait(poly);
		polyDoor[poly] = false;
	}
}
script "polyDRswing_Left" (int poly, int spd)
{
	if(!polyDoor[poly])
	{
		Polyobj_RotateLeft(poly, spd, 64);
		if(spd  < 16)
		{
			AmbientSound("DoorCreak", 127);
		}
		else if(spd >= 16)
		{
			AmbientSound("sounds/officeDopen", 127);
		}
		PolyWait(poly);
		polyDoor[poly] = true;
	}
	else if(polyDoor[poly])
	{
		Polyobj_RotateRight(poly, spd, 64);
		if(spd  < 16)
		{
			AmbientSound("DoorCreak", 127);
		}
		else if(spd >= 16)
		{
			AmbientSound("sounds/officeDclose", 127);
		}
		PolyWait(poly);
		polyDoor[poly] = false;
	}
}
script "polyDRSlide" (int poly, int angle, int dist)
{
	if(!polyDoor[poly])
	{
		Polyobj_Move(poly, 24, angle, dist);
		PolyWait(poly);
		polyDoor[poly] = true;
	}
	else if(polyDoor[poly])
	{
		Polyobj_Move(poly, 24, -angle, dist);
		PolyWait(poly);
		polyDoor[poly] = false;
	}
}

Re: Button to open and close PolyObject door.

by Graf Zahl » Sat Aug 25, 2018 1:35 am

Actually for Polyobjects, tagwait() does not work, you need to use polywait().

Re: Button to open and close PolyObject door.

by ramon.dexter » Sat Aug 25, 2018 12:17 am

Instead of delay() use tagwait() with the corresponding tag. The delay can and will cause problems.

Re: Button to open and close PolyObject door.

by TheGameratorT » Fri Aug 24, 2018 6:17 am

Thx for the reply this ended up working! :D

Code: Select all

#include "zcommon.acs"

Int Door1Closed = 1;
Int Door1Working = 0;

Script "Door1OpenClose" (void)
{
	If(Door1Working)
	{
		Terminate;
	}

	If(Door1Closed)
	{
		Door1Working = 1;
		HudMessage (l:"DOOR_OPENED"; HUDMSG_FADEINOUT, 0, CR_GOLD, 0.5, 0.5, 1.0, 0.0, 0.0);
		Polyobj_MoveTo(0, 32, 96, 736);
		delay(35*1);
		Door1Closed = 0;
		Door1Working = 0;
	}
	Else
	{
		Door1Working = 1;
		HudMessage (l:"DOOR_CLOSED"; HUDMSG_FADEINOUT, 0, CR_GOLD, 0.5, 0.5, 1.0, 0.0, 0.0);
		Polyobj_MoveTo(0, 32, 0, 736);
		delay(35*1);
		Door1Closed = 1;
		Door1Working = 0;
	}
}

Re: Button to open and close PolyObject door.

by Caligari87 » Tue Aug 21, 2018 1:34 pm

You'll need to script the rotation (or slide) manually both directions I believe. So instead of doing a polyobject_door, you'd do polyobject_rotate/slide(direction) when the first switch is pressed, then polyobject_rotate/slide(opposite direction) when the button is pressed again.

8-)

Button to open and close PolyObject door.

by TheGameratorT » Tue Aug 21, 2018 12:48 pm

So I know that a delay of -1 keeps the PolyObject door open forever but how can I make a close/open switch instead of delaying it's re-closing?

Top