Welcome to the Builder Academy

Question Trigger of the Day - Elevator

More
23 Jun 2012 12:49 - 25 Jun 2012 09:49 #209 by Rumble
By Axanon
This is actually a few triggers used together to make a working elevator. You'll need a few prerequisites to get this running.
1.) Build your 'building', with the elevator on the first floor. Build the other floors (at least the rooms the elevator will exit at)
2.) Although not *mandatory*, a mobile should serve as the elevator attendant. This example uses one, so that's what I'll cover.
3.) Make a room for the elevator shaft. This is sort of a temporary room for the elevator doors to link to when it's not at a floor.

The elevator room (panel):
Code:
Name: 'Elevator Panel', VNum: [57400], RNum: [ 4107] Trigger Intended Assignment: Rooms Trigger Type: Command , Numeric Arg: 100, Arg list: press Commands: * Elevator Script * By Axanon * define floor exits in an array set floor[1] 57401 set floor[2] 57407 set floor[3] 57410 set floor[4] 57413 set shaft 57414 set elevator 57402 if %cmd% == press && %arg% >= 1 && %arg% <= 4 %send% %actor% You press button %arg%. The light flickers. %echoaround% %actor% %actor.name% presses button %arg% * get the current floor the elevator is on. if %self.east(vnum)% == 57401 set curfloor 1 end if %self.east(vnum)% == 57407 set curfloor 2 end if %self.east(vnum)% == 57410 set curfloor 3 end if %self.east(vnum)% == 57413 set curfloor 4 end * set current state of elevator eval gofloor %arg% eval gofloorex %%floor[%arg%]%% eval exitnum %self.east(vnum)% * determine if the elevator is going up or down if %gofloor% > %curfloor% set eledir upward eval waittime (%gofloor% - %curfloor%) * 2 end if %gofloor% < %curfloor% set eledir downward eval waittime (%curfloor% - %gofloor%) * 2 end if %arg% == %curfloor% %echo% This is an elevator, not a stayavator! set eledir nowhere set waittime 0 end wait 5 sec * close the doors on both sides %echo% The elevator doors close. %asound% The elevator doors close. %door% %exitnum% west purge %door% %exitnum% west room %shaft% %door% %exitnum% west name elevator %door% %exitnum% west flags bcd %door% %elevator% east purge %door% %elevator% east room %shaft% %door% %elevator% east name elevator %door% %elevator% east flags bcd wait 1 sec %echo% The elevator squeaks and begins moving %eledir%. set inmotion 1 global inmotion * as set above, for each floor the elevator has to move, it will take longer * to get there. wait %waittime% sec * Second floor! Sporting goods and lingerie! %door% %gofloorex% west purge %door% %gofloorex% west room %elevator% %door% %gofloorex% west name elevator %door% %gofloorex% west flags a %door% %elevator% east purge %door% %elevator% east room %gofloorex% %door% %elevator% east name elevator %door% %elevator% east flags a %echo% *DING!* %asound% *DING!* wait 1 sec %echo% The elevator doors open. %asound% The elevator doors open. set inmotion 0 global inmotion else * incase somebody tries to go to a non-existant floor. %send% %actor% There are only 4 floors, that's not one of them! end

The elevator call button, place outside the elevator on each floor (requires mobile):
Code:
Name: 'Elevator Call Button', VNum: [57401], RNum: [ 4108] Trigger Intended Assignment: Rooms Trigger Type: Command , Numeric Arg: 100, Arg list: press Commands: if %self.vnum% == 57401 set floor 1 elseif %self.vnum% == 57407 set floor 2 elseif %self.vnum% == 57410 set floor 3 else %self.vnum% == 57413 set floor 4 end %send% %actor% You press the call button. %echoaround% %actor% %actor.name% presses the call button. if %in_motion% == 1 %echo% The elevator is currently in use. Please wait and try again. else if %cmd% == press && %arg% == call %force% elevator say You better get out of here! Somebody else needs the elevator. wait 4s %force% elevator press %floor% else %send% %actor% Perhaps try pressing something that is there! end end
And finally, some 'atmosphere' :):
Code:
Name: 'Elevator Music', VNum: [57402], RNum: [ 4109] Trigger Intended Assignment: Rooms Trigger Type: Random , Numeric Arg: 10, Arg list: None Commands: switch %random.9% case 1 %echo% "Tijiuana Taxi" plays over the broken speaker. break case 2 %echo% The ever famous song, "Spanish Flea" comes on. Arriba! break case 3 %echo% The elevator plays the theme song from M*A*S*H. break case 4 %echo% An instrumental version of "Dancing Queen" plays out of the elevator speaker. Go girl! wait 5 sec %force% elevator emote bops his head to the music. break case 6 %echo% An instrumental rendition of "Kung-Fu Fighting" plays over the elevator speaker. break case 7 %echo% The MuzeHACK(tm) version of "Gypsies, Tramps and Thieves" is stinging your ears. wait 5 sec %echo% As if god himself could feel your pain and help you, the elevator speaker cuts out. wait 2 sec %force% elevator emote bangs on the wall of the elevator. wait 1 sec %echo% The music returns! Nooo! break case 8 %echo% The MuzeHACK(tm) version of The Monkee's "Daydream Believer" comes on. wait 5 sec %send% %person% You catch yourself inadvertently humming along and quickly stop. wait 5 sec %send% %person% The elevator attendant winks at you. %echoaround% The elevator attendant winks at %person%. break case 9 %echo% A Bossa nova-style variation of the "Imperial March" from Star Wars plays over the speaker. wait 4 sec %force% elevator emote gags in disgust. break default break done
If this was helpful please vote or leave a review for TBA.

Rumble
The Builder Academy
tbamud.com 9091
rumble@tbamud.com
Last edit: 25 Jun 2012 09:49 by Rumble.

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

Time to create page: 0.162 seconds