Button to open and close PolyObject door.

Ask about mapping, UDMF, using DoomBuilder/editor of choice, etc, here!
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.

Button to open and close PolyObject door.

Postby TheGameratorT » Tue Aug 21, 2018 1: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?
User avatar
TheGameratorT
If you read this you now like potatoes and ducks.
 
Joined: 04 Mar 2018
Location: Portugal
Discord: TheGameratorT#1850
Twitch ID: thegameratort

Re: Button to open and close PolyObject door.

Postby Caligari87 » Tue Aug 21, 2018 2: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-)
User avatar
Caligari87
I'm just here for the community
User Accounts Assistant
 
Joined: 26 Feb 2004
Location: Salt Lake City, Utah, USA
Discord: Caligari87#3089

Re: Button to open and close PolyObject door.

Postby TheGameratorT » Fri Aug 24, 2018 7:17 am

Thx for the reply this ended up working! :D

Code: Select allExpand view
#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;
   }
}
User avatar
TheGameratorT
If you read this you now like potatoes and ducks.
 
Joined: 04 Mar 2018
Location: Portugal
Discord: TheGameratorT#1850
Twitch ID: thegameratort

Re: Button to open and close PolyObject door.

Postby ramon.dexter » Sat Aug 25, 2018 1:17 am

Instead of delay() use tagwait() with the corresponding tag. The delay can and will cause problems.
User avatar
ramon.dexter
rudebwoy
 
Joined: 20 Oct 2015
Location: Kozolupy, Bohemia

Re: Button to open and close PolyObject door.

Postby Graf Zahl » Sat Aug 25, 2018 2:35 am

Actually for Polyobjects, tagwait() does not work, you need to use polywait().
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Button to open and close PolyObject door.

Postby ramon.dexter » Sun Aug 26, 2018 6: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 allExpand view
//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;
   }
}
User avatar
ramon.dexter
rudebwoy
 
Joined: 20 Oct 2015
Location: Kozolupy, Bohemia

Re: Button to open and close PolyObject door.

Postby TheGameratorT » Wed Aug 29, 2018 2: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.
User avatar
TheGameratorT
If you read this you now like potatoes and ducks.
 
Joined: 04 Mar 2018
Location: Portugal
Discord: TheGameratorT#1850
Twitch ID: thegameratort

Re: Button to open and close PolyObject door.

Postby Zen3001 » Sun Sep 16, 2018 8: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
User avatar
Zen3001
Cannot the kingdom of salvation take me home?
Banned User
 
Joined: 25 Nov 2016
Location: some northern german shithole
Discord: #0629

Re: Button to open and close PolyObject door.

Postby ramon.dexter » Mon Sep 24, 2018 8: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.
User avatar
ramon.dexter
rudebwoy
 
Joined: 20 Oct 2015
Location: Kozolupy, Bohemia

Re: Button to open and close PolyObject door.

Postby TheGameratorT » Sat Nov 03, 2018 9: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 :)
User avatar
TheGameratorT
If you read this you now like potatoes and ducks.
 
Joined: 04 Mar 2018
Location: Portugal
Discord: TheGameratorT#1850
Twitch ID: thegameratort


Return to Mapping

Who is online

Users browsing this forum: No registered users and 1 guest