Button to open and close PolyObject door.
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.
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.
- TheGameratorT
- Posts: 63
- Joined: Sun Mar 04, 2018 4:42 am
- Graphics Processor: nVidia with Vulkan support
- Location: Portugal
- Contact:
Button to open and close PolyObject door.
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?
- Caligari87
- Admin
- Posts: 6174
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
- Contact:
Re: Button to open and close PolyObject door.
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.
- TheGameratorT
- Posts: 63
- Joined: Sun Mar 04, 2018 4:42 am
- Graphics Processor: nVidia with Vulkan support
- Location: Portugal
- Contact:
Re: Button to open and close PolyObject door.
Thx for the reply this ended up working!
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;
}
}
- ramon.dexter
- Posts: 1520
- Joined: Tue Oct 20, 2015 12:50 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Kozolupy, Bohemia
Re: Button to open and close PolyObject door.
Instead of delay() use tagwait() with the corresponding tag. The delay can and will cause problems.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49056
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Button to open and close PolyObject door.
Actually for Polyobjects, tagwait() does not work, you need to use polywait().
- ramon.dexter
- Posts: 1520
- Joined: Tue Oct 20, 2015 12:50 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Kozolupy, Bohemia
Re: Button to open and close PolyObject door.
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).
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;
}
}
- TheGameratorT
- Posts: 63
- Joined: Sun Mar 04, 2018 4:42 am
- Graphics Processor: nVidia with Vulkan support
- Location: Portugal
- Contact:
Re: Button to open and close PolyObject door.
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.
Also thx for the rotating door.
Re: Button to open and close PolyObject door.
that's something I didn't knew about and really helped the map I'm working onramon.dexter wrote:Instead of delay() use tagwait() with the corresponding tag. The delay can and will cause problems.
- ramon.dexter
- Posts: 1520
- Joined: Tue Oct 20, 2015 12:50 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Kozolupy, Bohemia
Re: Button to open and close PolyObject 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.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.
- TheGameratorT
- Posts: 63
- Joined: Sun Mar 04, 2018 4:42 am
- Graphics Processor: nVidia with Vulkan support
- Location: Portugal
- Contact:
Re: Button to open and close PolyObject door.
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