Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Jeff Walters' Swinging Door Cog
Jeff Walters' Swinging Door Cog
2001-04-14, 12:34 PM #1
I need to know how to make a swinging door out of these two cogs. I can't get it right... I don't know how to use the cog... Maybe you all can help me.

Client Side

Code:
# Jedi Knight Cog Script
#
# Swing_Ct.cog
#
# Generic Swinging Door Script, C/S version, Client side
#
# [JW]
#
# (C) 1998 Jeff Walters

flags=0x240

symbols
   	message  trigger
	
	int      doorID
end

## Code Section
code

trigger:
  
   if(GetSourceRef() != 500000 + doorID) Return;

   if(GetParam(1) == 1) RotatePivot(GetParam(0), 1, GetParam(2));  // Swing (rotate) door
  
   return;

end



Server Side

Code:
# Jedi Knight Cog Script
#
# Swing_Sr.cog
#
# Generic Swinging Door Script, C/S version, Server side
#
# [JW]
#
# (C) 1998 Jeff Walters

symbols
   message     activated
   message     blocked
   message     arrived
   message     timer

   thing       Door    
  
   flex        Time=4.0
   flex        AutoCloseDelay=0.0

   int         doorID
   int         Rotating=0        	local

end


## Code Section
code

activated:
   if (Rotating) return;                  // Rotation already in progress
   Rotating = 1; 
   SendTrigger(-1, 500000 + doorID, door, 1, Time, 0);
   return;

blocked:
   Time = -Time;
   SendTrigger(-1, 500000 + doorID, door, 1, Time, 0);
	Return;

delayed:
   if (Rotating) return;                  // Rotation already in progress
   Rotating = 1;
   SendTrigger(-1, 500000 + doorID, door, 1, Time, 0);
   return;

arrived:
   if (!Rotating) return;                 // Rotation already finished
   Time = -Time;                          // Negate time for invers rotation
   Rotating = 0;

   if (AutoCloseDelay > 0.0  &&  Time < 0)
      SetTimer(AutoCloseDelay);           // Prepare delayed automatic closing
   return;

timer:
   call delayed;                          // Delayed closing
   return;

end

↑ Up to the top!