Welcome to the Builder Academy

Question Trigger of the Day - Parna's Elevator

More
22 Dec 2013 19:31 - 24 Mar 2014 04:08 #4581 by Parnassus
Lately I've been working on housing zones, since the housing code requires pre-made rooms. One of these zones is an apartment/condo/dorm type building which I decided needed an elevator. There are two versions here already:
www.tbamud.com/forum/3-building/209-trigger-of-the-day-elevator
www.tbamud.com/forum/3-building/1460-tri...push-button-teleport
but I decided to throw my own in the mix.

As always, I need people to break the trigger so I can figure out how to fix it. [strike]Also, there's a problem here that perhaps someone can help me with. The motion check doesn't work so the elevator sometimes tries to go to two different floors at one time which, I have to admit, looks really funny :)[/strike] Also, I've tried to make the start and stop of the elevator a bit dynamic but I'm not completely happy with it. Any suggestions?

I hope you like this. Happy Holidays.
Code:
Name: 'Running the Elevator', VNum: [65302], RNum: [ 4609] Trigger Intended Assignment: Rooms Trigger Type: Command , Numeric Arg: 100, Arg list: * Commands: * Written December 31, 2013 by Parnassus for TBAmud * Thanks to Fizban for writing an Elevator trigger, and Rumble for posting it as * a Trigger of the day, which made me decide that my Housing project * apartment really needed an elevator. * Thanks to Axanon for letting me look at his really nice elevator triggers. * Be prepared for errors, use at your own risk. * Any errors are mine, any people named in this trigger are blameless! * * Parnassus' Special Anti-Freeze Formula if %cmd.mudcommand% == nohassle return 0 halt end * * Variable assignments: make changes here. * Thanks to Krell for helping me work out this format which is especially * good for a stand-alone trigger! * adjust zone number * set maxfl to the highest floor number. To make a penthouse, make adjustments * similar to the Ground floor here. If you add more than 20 floors, switch to the * commented line using CURFL instead of the one using ORDINAL . * add additional floors along with %zone% and room number of the linking room. * (Also add mention of button and display in the linking room. Set up door to the * elevator, flagged as 2 - Pickproof door.) set zone 653 set maxfl 4 set totfl 5 set Elevat %zone%99 set Floor0 %zone%98 set Floor1 %zone%06 set Floor2 %zone%14 set Floor3 %zone%22 set Floor4 %zone%30 * Which side of the elevator is the door on? set elevdoor north * Which side of the room is the elevator on? set roomdoor south ** Thanks to Thomas for the formula that makes this part work. eval temp %%Elevat.%elevdoor%(vnum)%% eval eleroom %temp% if %eleroom% == %Floor1% set CurFl 1 set Curex %Floor1% elseif %eleroom% == %Floor2% set CurFl 2 set Curex %Floor2% elseif %eleroom% == %Floor3% set CurFl 3 set Curex %Floor3% elseif %eleroom% == %Floor4% set CurFl 4 set Curex %Floor4% elseif %eleroom% == %Floor0% set CurFl 0 set Curex %Floor0% end if %cmd% == push if %arg% == g || %arg% >= 1 && %arg% <= %maxfl% if %self.vnum% != %Elevat% %send% %actor% You don't see that here. halt else ** Thanks to Kyle for figuring out how to make this part work. eval text %%self.%elevdoor%(bits)%% if %text.contains(LOCKED)% && !%text.contains(PICKPROOF)% %send% %actor% The elevator is already in motion. Please be patient. halt end end if %arg% == g set %arg% 0 set targfl 0 set Tarex %Floor0% elseif %arg% == 1 set Tarex %Floor1% set targfl 1 elseif %arg% == 2 set Tarex %Floor2% set targfl 2 elseif %arg% == 3 set Tarex %Floor3% set targfl 3 elseif %arg% == 4 set Tarex %Floor4% set targfl 4 end elseif %arg% == button if %self.vnum% == %Elevat% %send% %actor% Which button? halt else eval text %%self.%roomdoor%(bits)%% if !%text.contains(CLOSED)% %send% %actor% The elevator is already here. halt elseif %text.contains(LOCKED)% && !%text.contains(PICKPROOF)% %send% %actor% The elevator is already in use. Please wait and try again. halt end end else %send% %actor% You don't see that here. halt end if %self.vnum% == %Floor0% set Tarex %Floor0% set targfl 0 elseif %self.vnum% == %Floor1% set Tarex %Floor1% set targfl 1 elseif %self.vnum% == %Floor2% set Tarex %Floor2% set targfl 2 elseif %self.vnum% == %Floor3% set Tarex %Floor3% set targfl 3 elseif %self.vnum% == %Floor4% set Tarex %Floor4% set targfl 4 end if %targfl% == g set dir down eval length %Curfl% elseif %targfl% > %Curfl% set dir up eval length %targfl% - %Curfl% elseif %targfl% < %Curfl% set dir down eval length %Curfl% - %targfl% else set dir nowhere set length 0 end %at% %Elevat% %echo% The elevator doors slide shut. %at% %Curex% %echo% The elevator doors slide shut. wait 5 set echofl 0 while %echofl% < %totfl% eval temp %%Floor%echofl%%% %at% %temp% %echo% The elevator doors start to vibrate. %door% %temp% %roomdoor% flags abc eval echofl %echofl% + 1 done if %length% > 0 set origlen %length% %door% %Curex% %roomdoor% flags abc %door% %Elevat% %elevdoor% purge %door% %Elevat% %elevdoor% room %Elevat% %door% %Elevat% %elevdoor% flags abc %at% %Elevat% %echo% The elevator @g*l u r c h e s*@n %at% %Elevat% %echo% @n @G*l u r c h e s*@n %at% %Elevat% %echo% @n @g*l u r c h e s*@n %dir%wards. end while %length% if %dir% == up eval Curfl %Curfl% + 1 elseif %dir% == down eval Curfl %Curfl% -1 end if %Curfl% == 0 set ordinal ground elseif %Curfl% == 1 set ordinal 1st elseif %Curfl% == 2 set ordinal 2nd elseif %Curfl% == 3 set ordinal 3rd elseif %Curfl% > 3 set ordinal %Curfl%th end wait 15 %at% %Elevat% %echo% @g *DING!*@n %at% %Elevat% %echo% You have reached the %ordinal% floor. * It's easier to use the following line if you have over 20 floors (instead of the 21th floor) * %at% %Elevat% %echo% You have reached floor %Curfl%. wait 5 eval length %length% - 1 if %CurFl% > %maxfl% %echo%@r Something seems to be wrong with the elevator.@n %echo%@r Please try again and if there's still a problem,@n %echo%@r please report this to admin.@n set length 0 end done if %origlen% > 0 wait 2 %at% %Elevat% %echo% @nThe elevator @y*s h u d d e r s*@n %at% %Elevat% %echo% @n @Y*s h u d d e r s*@n %at% %Elevat% %echo% @n @y*s h u d d e r s*@n to a halt. end wait 2 set echofl 0 while %echofl% < %totfl% eval temp %%Floor%echofl%%% %at% %temp% %echo% The elevator doors stop vibrating. wait 3 %door% %temp% %roomdoor% flags abcd eval echofl %echofl% + 1 done wait 1 %at% %targfl% %echo% @g *DING!*@n wait 3 %door% %Tarex% %roomdoor% room %Elevat% %door% %Tarex% %roomdoor% flags a %door% %Elevat% %elevdoor% purge %door% %Elevat% %elevdoor% room %Tarex% %at% %Elevat% %echo% The doors slide open. %at% %Tarex% %echo% The elevator doors slide open. wait 3 %door% %Elevat% %elevdoor% flags a elseif %cmd.mudcommand% == look if !%arg% return 0 halt elseif %arg% == display if %self.vnum% != %Elevat% eval text %%self.%roomdoor%(bits)%% if !%text.contains(CLOSED)% %send% %actor% The elevator is already here. halt end else eval text %%self.%elevdoor%(bits)%% end if %text.contains(LOCKED)% && !%text.contains(PICKPROOF)% %send% %actor% Numbers flash across the display. The elevator is on the move. halt end if %Curfl% == 0 set displaymsg the ground floor else set displaymsg floor %Curfl% end %send% %actor% The elevator is on %displaymsg%. halt * if look is not noarg or display else return 0 end * if command is anything except look or push else return 0 end * If you do not use the stock TBA colour system (or if you're using an old one) * delete this comment and the following line. They are just here to remind * the user to enable the color codes. /t
Last edit: 24 Mar 2014 04:08 by Parnassus. Reason: Not written December 31, 2014

Please Log in or Create an account to join the conversation.

More
26 Dec 2013 01:40 - 26 Dec 2013 02:01 #4583 by krell

Parnassus wrote: <snip>
Also, I've tried to make the start and stop of the elevator a bit dynamic but I'm not completely happy with it. Any suggestions?


How about music? It's just not an elevator ride without Elevator Muzak! :-)

It also seems to me, with all respect due to Fizban, that %Elevator_moving% indicates that the elevator is either moving, or it is not which is a binary condition. So instead of having:

Code:
if %Elevator_moving% > 0 <do something> elseif %Elevator_moving% <= 0 <do something else> end

Could you get away with?

Code:
if %Elevator_moving% <do something> elseif !%Elevator_moving% <do something else> end

Speaking of %Elevator_moving% [strike]1) I can only seem to find an instance where it is set to a value of one indicating the elevator is moving, but not where it is set to zero indicating that the elevator is NOT moving. 2)[/strike] There should be a context variable if you're using a global, no?

ie. set context %self.id%

Otherwise,cool script. I promise to check it out one day soon. I'm trying fo figure out a good elevator script as well and have also looked at Fizban's script for inspiration.

Happy Holidays and all that rot.
Last edit: 26 Dec 2013 02:01 by krell. Reason: changed "elif"'s to "elseif"'s

Please Log in or Create an account to join the conversation.

More
26 Dec 2013 02:33 - 26 Dec 2013 02:46 #4584 by krell
Code:
if (%Elevator_moving% > 0) %echo% Please wait and try again. halt elseif (%Elevator_moving% <= 0) %echo% The elevator starts to vibrate. end

Change too:

Code:
if (%Elevator_moving% > 0) %echo% Please wait and try again. set Elevator_moving 1 * Because I'm kinda anal and all.... global Elevator_moving halt elseif (%Elevator_moving% <= 0) %echo% The elevator starts to vibrate end

And

Code:
if %origlen% > 0 wait 2 %at% %Elevat% %echo% The elevator *s h u d d e r s* %at% %Elevat% %echo% *s h u d d e r s* %at% %Elevat% %echo% *s h u d d e r s* to a halt. end wait 2 %at% %Elevat% %echo% The doors slide open. %at% %targfl% %echo% *DING!* wait 1 %at% %Tarex% %echo% The elevator doors slide open. %door% %Tarex% south room %Elevat% %door% %Tarex% south flags a %door% %Elevat% north room %Tarex% %door% %Elevat% north flags a set Elevator_moving 0 global Elevator_moving

Change too:

Code:
if %origlen% > 0 set Elevator_moving 0 * Set and global Elevator_moving right away. global Elevator_moving * Again, because I'm anal. :-) wait 2 %at% %Elevat% %echo% The elevator *s h u d d e r s* %at% %Elevat% %echo% *s h u d d e r s* %at% %Elevat% %echo% *s h u d d e r s* to a halt. end wait 2 %at% %Elevat% %echo% The doors slide open. %at% %targfl% %echo% *DING!* wait 1 %at% %Tarex% %echo% The elevator doors slide open. %door% %Tarex% south room %Elevat% %door% %Tarex% south flags a %door% %Elevat% north room %Tarex% %door% %Elevat% north flags a

HTH YMMV. :-)
Last edit: 26 Dec 2013 02:46 by krell. Reason: removed an extraneous line or two that were erroneous

Please Log in or Create an account to join the conversation.

More
26 Dec 2013 19:20 #4585 by Parnassus
It seems that the reason those checks weren't working is that the trigger is posted in various places. Part of the plan was to make one trigger that anybody could easily insert into any zone. You said something about (I think) always declaring the variables at the start which makes the trigger much easier to insert. Axanon used three triggers (and, yeah, one of them is the Muzak trigger!) but I wanted one stand-alone, both for ease of insertion and because there's no way to know how many triggers would exist in the zone already.

The trigger is placed in the elevator and in the waiting spot at each floor. What was happening was that the global was attached to the room where the trigger was accessed but it was pretty obvious, in that spot, that the trigger was running already. The problem was that if you called the elevator (push button) the global inside the elevator couldn't be accessed. This goes back to that other question about checking for globals in other places. The only real time that global would work would be if you were standing in the elevator, pushed the floor and then pushed another floor. This happens all the time in real life but it's a complication I'd prefer not to work on.

I've come up with the type of workaround I'd have used in Smaug, where I had to run around and around within a trigger, trying to get to a place that wasn't normally possible. The obvious way was to create an object that the trigger could look for. This would be easy and, if the object was invisible, un-noticeable. However, this would take away from the whole stand-alone plan. The only thing that I could find that could access other rooms from a trigger was %door%. My next plan was to create and purge hidden doors and then let the trigger search for them. Unfortunately, it turns out that triggers cannot create hidden doors. My current thought is to change the door-flags and check for the flags themselves. It turns out that the helpfiles on this are not exactly helpful. Kyle worked out a syntax for me and it's almost ready to go. I'm not totally happy with it but it works and is generally undetectable.

As to the placement of the checks, I preferred to turn off the motion after the elevator stopped so the doors wouldn't slam shut again as soon as it stopped. When I look at your post, I've given 1 sec after the doors open and I think I'll lengthen that. But why did you want to set the global after seeing that the global was set? If it is > 0, set it to 1? Isn't it already there?

I'll probably copy mark2 over current code sometime today. Thanks for looking into the matter for me though. I like to get any suggestions coming because they all come in helpful somewhere along the line.

Please Log in or Create an account to join the conversation.

More
27 Dec 2013 00:41 #4586 by krell

Parnassus wrote: As to the placement of the checks, I preferred to turn off the motion after the elevator stopped so the doors wouldn't slam shut again as soon as it stopped. When I look at your post, I've given 1 sec after the doors open and I think I'll lengthen that. But why did you want to set the global after seeing that the global was set? If it is > 0, set it to 1? Isn't it already there?


1) I prefer to set the neccessary variable as soon as possible unless there's a good reason not to set it. You apparently have a good reason.

2) As I've mentioned, it's an anal characteristic. I know the value has just been checked, but it doesn't hurt to make sure the value remains in the correct place. It's not something I always do however. To be complete, I might even set the variable to zero even after I've checked that it is zero.

Please Log in or Create an account to join the conversation.

More
27 Dec 2013 00:53 - 27 Dec 2013 01:05 #4587 by krell

Parnassus wrote: The trigger is placed in the elevator and in the waiting spot at each floor. What was happening was that the global was attached to the room where the trigger was accessed but it was pretty obvious, in that spot, that the trigger was running already. The problem was that if you called the elevator (push button) the global inside the elevator couldn't be accessed. This goes back to that other question about checking for globals in other places. The only real time that global would work would be if you were standing in the elevator, pushed the floor and then pushed another floor. This happens all the time in real life but it's a complication I'd prefer not to work on.


Okay,this goes back to a problem I had been working on before and had started asking questions about. Yes, I don't think globals work on another room, just for the room it's assigned too. IIRC, %varexists% doesn't work on rooms or objects either, just characters. I'd like to see %varexists% extended to rooms then rooms could check up on each other for actions that cross several rooms.

Just my humble opinion.

Another possible solution that I've been toying with in my scripts; Set remote variables on the players using the elevator, purge them when they players exit the elevatorm check for pre-existing remote variables on players that may have teleported off of the elevator and purge or reset those, check for pre-existing remote variables or non-existant remote variables on players that telport into your elevator.
Last edit: 27 Dec 2013 01:05 by krell.

Please Log in or Create an account to join the conversation.

Time to create page: 0.203 seconds