New lift script
This acts as an alternative to the basic lift script, using File:Tuto_new_lifts.c16 as the image for the lifts and hewing more closely to the Creatures Development Standards, using "ding.wav" for the call button sound, "buzz.wav" for if the call button is hit, and "c2sl.wav" for the sound of the lift pulleys cranking as the lift moves. It installs a lift with two call buttons. It is useful to use the CAOS Tool or another highlighting tool because they can make the CAOS syntax easier to read.
Contents
Installation script[edit]
This script installs one lift and two call buttons - one on level 0 and one on level 1. It also creates a smell link for scents to travel vertically between the call buttons.
inst new: vhcl 3 1 1000 "tuto_new_lifts" 1 0 10 *Open air cabin attr 512 *Creatures can push and pull bhvr 3 *Define cabin properties - the cabin dimensions (CABN), the image plane the passengers will be at (CABP) and the capacity of the cabin (CABW) cabn 0 0 122 151 cabp 50 cabw 10 *ov00 = lift state (0 = still; 1 = moving) setv ov00 0 *ov01 = current level (starts on bottom) setv ov01 0 *ov16 = what button you're travelling to seta ov16 null *Mark this lift for later seta va16 targ
*Add gate that keeps creatures in (probably) pat: dull 1 "tuto_new_lifts" 1 0 0 200 *Add buttons pat: dull 2 "tuto_new_lifts" 2 90 65 1 *Move to desired location mvto 74160 71485
*Create buttons new: simp 2 12 1000 "tuto_new_lifts" 2 5 500 *Can be activated by hand attr 4 *Creatures can push, pull and hit bhvr 11 *ov01 = level setv ov01 0 *ov16 = associated lift seta ov16 va16 *Move to desired location mvto 74314 71547 *Get room setv va00 grap posx posy
new: simp 2 12 1000 "tuto_new_lifts" 2 5 500 *Can be activated by hand attr 4 *Creatures can push, pull and hit bhvr 11 *ov01 = level setv ov01 1 *ov16 = associated lift seta ov16 va16 *Move to desired location mvto 74314 71362 *Get room setv va01 grap posx posy
*Link rooms together for CAs to travel link va00 va01 100
Elevator push script[edit]
*Elevator Push scrp 3 1 1000 1 *Before anything else, check to see if you can go up *Don't check outside of the metaroom you're in setv va00 gmap posx posy *Get your level setv va01 ov01 *And find a button to associate with seta va16 null inst *Go through all the buttons in the world enum 2 12 1000 *Make sure they're valid doif targ <> null *Are they in the same metaroom? doif gmap posx posy = va00 *And are they associated with you? doif ov16 = ownr *Is it on a higher level than you? doif ov01 > va01 *Mark it down if you don't have a target already doif va16 = null seta va16 targ setv va51 ov01 else *Is it lower than the one you found previously? doif ov01 < va51 *Mark it as your new one if so seta va16 targ setv va51 ov01 endi endi endi endi endi endi next slow
*Does this button even exist? doif va16 = null *If you never found one, disappoint the creature who activated you doif crea from = 1 stim writ from 0 1 endi stop endi
*Otherwise, tell the creature to wait and go to the "Go up" script doif crea from = 1 stim writ from 75 1 endi mesg wrt+ ownr 1000 from va16 0 endm
Elevator pull script[edit]
*Elevator Pull scrp 3 1 1000 2 *Before anything else, check to see if you can go down *Don't check outside of the metaroom you're in setv va00 gmap posx posy *Get your level setv va01 ov01 *And find a button to associate with seta va16 null inst *Go through all the buttons in the world enum 2 12 1000 *Make sure they're valid doif targ <> null *Are they in the same metaroom? doif gmap posx posy = va00 *And are they associated with you? doif ov16 = ownr *Is it on a lower level than you? doif ov01 < va01 *Mark it down if you don't have a target already doif va16 = null seta va16 targ setv va51 ov01 else *Is it higher than the one you found previously? doif ov01 > va51 *Mark it as your new one if so seta va16 targ setv va51 ov01 endi endi endi endi endi endi next slow
*Does this button even exist? doif va16 = null *If you never found one, disappoint the creature who activated you doif crea from = 1 stim writ from 0 1 endi stop endi
*Otherwise, tell the creature to wait and go to the "Go down" script doif crea from = 1 stim writ from 75 1 endi mesg wrt+ ownr 1001 from va16 0 endm
Elevator go up script[edit]
*Elevator Go Up scrp 3 1 1000 1000 *Don't want this script getting interrupted lock
*Determine who sent the message doif _p1_ = pntr *Check for grendels etch 4 2 0 nohh zomb 1 pose 80 dirn 1 doif targ <> null spas ownr targ endi wait 2 doif targ <> null doif carr = null zomb 0 endi endi next *Get everyone in the lift gpas 4 0 0 1 else targ _p1_ *If it was a creature, just pick that creature up doif fmly = 4 doif gnus = 2 nohh zomb 1 pose 80 dirn 1 wait 4 doif targ <> null spas ownr targ endi wait 2 doif targ <> null doif carr = null zomb 0 endi endi else spas ownr targ endi endi *Otherwise, just skip this step endi
lock targ _p2_ *Get positioning info setv va00 posb targ ownr *Mark yourself as moving setv ov00 1 *Light up "Go up" button part 2 pose 2 *Make some noise sndl "c2sl" *Time to move it, move it loop *Keep moving up until you've reached the call button setv vely -2 untl posb <= va00 *Stop moving velo 0 0 *Shut the call button off targ _p2_ pose 0 *Get its level setv va01 ov01 targ ownr *Shut light off part 2 pose 0 *Stop making noise fade *Drop everyone and stim with "Traveled in lift" epas 4 0 0 zomb 0 stim writ targ 94 1 next dpas 4 0 0 *Change level and mark yourself as not moving setv ov00 0 setv ov01 va01 endm
Elevator go down script[edit]
*Elevator Go Down scrp 3 1 1000 1001 *Don't want this script getting interrupted lock
*Determine who sent the message doif _p1_ = pntr *Check for grendels etch 4 2 0 *Stop hand-holding nohh *Zombify grendel zomb 1 *Make it take a certain pose pose 80 *And face in a certain direction dirn 1 *If TARG exists, the lift should pick it up (SPAS). doif targ <> null spas ownr targ endi *Wait for spas to work. wait 2 *Spas can fail, so check if carr is null and zombify. doif targ <> null doif carr = null zomb 0 endi endi next *Get everyone in the lift gpas 4 0 0 1 else targ _p1_ *If it was a creature, just pick that creature up doif fmly = 4 doif gnus = 2 nohh zomb 1 pose 80 dirn 1 wait 4 doif targ <> null spas ownr targ endi wait 2 doif targ <> null doif carr = null zomb 0 endi endi else spas ownr targ endi endi *Otherwise, just skip this step endi
lock targ _p2_ *Get positioning info setv va00 posb targ ownr *Mark yourself as moving setv ov00 1 *Light up "Go up" button part 2 pose 1 *Make some noise sndl "c2sl" *Time to move it, move it loop *Keep moving up until you've reached the call button setv vely 2 untl posb >= va00 *Stop moving velo 0 0 *Shut the call button off targ _p2_ pose 0 *Get its level setv va01 ov01 targ ownr *Shut light off part 2 pose 0 *Stop making noise fade *Drop everyone and stim with "Traveled in lift" epas 4 0 0 zomb 0 stim writ targ 94 1 next dpas 4 0 0 *Change level and mark yourself as not moving setv ov00 0 setv ov01 va01 endm
Call button push[edit]
*Button push scrp 2 12 1000 1 inst stim writ from 89 1 *Light up and play a sound pose 1 snde "ding"
*Now determine who sent the message doif from = pntr *If it was the hand, note it seta va99 from else *Otherwise, note yourself seta va99 ownr endi
*Now find your lift doif ov16 <> null targ ov16 *If it's moving, activate your timer script so you can call it then doif ov00 = 1 targ ownr tick 50 stop endi *And don't do anything if you're both on the same level doif ov01 = mv01 targ ownr pose 0 stop endi
*Now check the lift's position compared to your own doif ov01 < mv01 *It's underneath you, so tell it to go up mesg wrt+ targ 1000 va99 ownr 0 elif ov01 > mv01 *It's above you, so tell it to go down mesg wrt+ targ 1001 va99 ownr 0 endi endi endm
Call button pull[edit]
*Button pull scrp 2 12 1000 2 inst stim writ from 89 1 *Light up and play a sound pose 1 snde "ding"
*Now determine who sent the message doif from = pntr *If it was the hand, note it seta va99 from else *Otherwise, note yourself seta va99 ownr endi
*Now find your lift doif ov16 <> null targ ov16 *If it's moving, activate your timer script so you can call it then doif ov00 = 1 targ ownr tick 50 stop endi *And don't do anything if you're both on the same level doif ov01 = mv01 targ ownr pose 0 stop endi
*Now check the lift's position compared to your own doif ov01 < mv01 *It's underneath you, so tell it to go up mesg wrt+ targ 1000 va99 ownr 0 elif ov01 > mv01 *It's above you, so tell it to go down mesg wrt+ targ 1001 va99 ownr 0 endi endi endm
Call button hit[edit]
Adding the hit script and 'I have hit machine' stimulus makes the buttons hew closer to the recommendations of the Creatures Development Standards project.
*Button hit script scrp 2 12 1000 3 *Stimulate with I have hit machine stim writ from 92 1 *Blink the call button light on and off anim [0 1 255] *Play a buzzing sound (included by default with C3 and DS) snde "buzz" *Wait until the buzzing sound is over wait 7 *Resume a ready-to-serve pose. pose 0 endm
Call button timer[edit]
*Button timer scrp 2 12 1000 9 inst *Find your lift doif ov16 <> null targ ov16 *If it's still moving, wait a little longer doif ov00 = 1 stop endi
*Now check the lift's position compared to your own doif ov01 < mv01 *It's underneath you, so tell it to go up mesg wrt+ targ 1000 ownr ownr 0 elif ov01 > mv01 *It's above you, so tell it to go down mesg wrt+ targ 1001 ownr ownr 0 endi targ ownr tick 0 endi endm
Removal[edit]
This simply counts through all the objects in the world with that class number, removes them, and then removes the scripts that belong to that class number. It's important to double-check that the class numbers here match the class numbers you've been using all along, and make sure that all SCRPs in the object have a corresponding scrx. If the class numbers here do not match the ones you've been using, you might accidentally delete some other object in the player's world, or silently delete another object's scripts, which would be hard for someone to fix!
*Removal rscr enum 3 1 1000 kill targ next enum 2 12 1000 kill targ next scrx 3 1 1000 1 scrx 3 1 1000 2 scrx 3 1 1000 1000 scrx 3 1 1000 1001 scrx 2 12 1000 1 scrx 2 12 1000 9
Whole script[edit]
inst new: vhcl 3 1 1000 "tuto_new_lifts" 1 0 10 *Open air cabin attr 512 *Creatures can push and pull bhvr 3 *Define cabin properties - the cabin dimensions (CABN), the image plane the passengers will be at (CABP) and the capacity of the cabin (CABW) cabn 0 0 122 151 cabp 50 cabw 10 *ov00 = lift state (0 = still; 1 = moving) setv ov00 0 *ov01 = current level (starts on bottom) setv ov01 0 *ov16 = what button you're travelling to seta ov16 null *Mark this lift for later seta va16 targ *Add gate that keeps creatures in (probably) pat: dull 1 "tuto_new_lifts" 1 0 0 200 *Add buttons pat: dull 2 "tuto_new_lifts" 2 90 65 1 *Move to desired location mvto 74160 71485 *Create buttons new: simp 2 12 1000 "tuto_new_lifts" 2 5 500 *Can be activated by hand attr 4 *Creatures can push, pull and hit bhvr 11 *ov01 = level setv ov01 0 *ov16 = associated lift seta ov16 va16 *Move to desired location mvto 74314 71547 *Get room setv va00 grap posx posy new: simp 2 12 1000 "tuto_new_lifts" 2 5 500 *Can be activated by hand attr 4 *Creatures can push, pull and hit bhvr 11 *ov01 = level setv ov01 1 *ov16 = associated lift seta ov16 va16 *Move to desired location mvto 74314 71362 *Get room setv va01 grap posx posy *Link rooms together link va00 va01 100 *Elevator Push scrp 3 1 1000 1 *Before anything else, check to see if you can go up *Don't check outside of the metaroom you're in setv va00 gmap posx posy *Get your level setv va01 ov01 *And find a button to associate with seta va16 null inst *Go through all the buttons in the world enum 2 12 1000 *Make sure they're valid doif targ <> null *Are they in the same metaroom? doif gmap posx posy = va00 *And are they associated with you? doif ov16 = ownr *Is it on a higher level than you? doif ov01 > va01 *Mark it down if you don't have a target already doif va16 = null seta va16 targ setv va51 ov01 else *Is it lower than the one you found previously? doif ov01 < va51 *Mark it as your new one if so seta va16 targ setv va51 ov01 endi endi endi endi endi endi next slow *Does this button even exist? doif va16 = null *If you never found one, disappoint the creature who activated you doif crea from = 1 stim writ from 0 1 endi stop endi *Otherwise, tell the creature to wait and go to the "Go up" script doif crea from = 1 stim writ from 75 1 endi mesg wrt+ ownr 1000 from va16 0 endm *Elevator Pull scrp 3 1 1000 2 *Before anything else, check to see if you can go down *Don't check outside of the metaroom you're in setv va00 gmap posx posy *Get your level setv va01 ov01 *And find a button to associate with seta va16 null inst *Go through all the buttons in the world enum 2 12 1000 *Make sure they're valid doif targ <> null *Are they in the same metaroom? doif gmap posx posy = va00 *And are they associated with you? doif ov16 = ownr *Is it on a lower level than you? doif ov01 < va01 *Mark it down if you don't have a target already doif va16 = null seta va16 targ setv va51 ov01 else *Is it higher than the one you found previously? doif ov01 > va51 *Mark it as your new one if so seta va16 targ setv va51 ov01 endi endi endi endi endi endi next slow *Does this button even exist? doif va16 = null *If you never found one, disappoint the creature who activated you doif crea from = 1 stim writ from 0 1 endi stop endi *Otherwise, tell the creature to wait and go to the "Go down" script doif crea from = 1 stim writ from 75 1 endi mesg wrt+ ownr 1001 from va16 0 endm *Elevator Go Up scrp 3 1 1000 1000 *Don't want this script getting interrupted lock *Determine who sent the message doif _p1_ = pntr *Check for grendels etch 4 2 0 nohh zomb 1 pose 80 dirn 1 doif targ <> null spas ownr targ endi wait 2 doif targ <> null doif carr = null zomb 0 endi endi next *Get everyone in the lift gpas 4 0 0 1 else targ _p1_ *If it was a creature, just pick that creature up doif fmly = 4 doif gnus = 2 nohh zomb 1 pose 80 dirn 1 wait 4 doif targ <> null spas ownr targ endi wait 2 doif targ <> null doif carr = null zomb 0 endi endi else spas ownr targ endi endi *Otherwise, just skip this step endi lock targ _p2_ *Get positioning info setv va00 posb targ ownr *Mark yourself as moving setv ov00 1 *Light up "Go up" button part 2 pose 2 *Make some noise sndl "c2sl" *Time to move it, move it loop *Keep moving up until you've reached the call button setv vely -2 untl posb <= va00 *Stop moving velo 0 0 *Shut the call button off targ _p2_ pose 0 *Get its level setv va01 ov01 targ ownr *Shut light off part 2 pose 0 *Stop making noise fade *Drop everyone and stim with "Traveled in lift" epas 4 0 0 zomb 0 stim writ targ 94 1 next dpas 4 0 0 *Change level and mark yourself as not moving setv ov00 0 setv ov01 va01 endm *Elevator Go Down scrp 3 1 1000 1001 *Don't want this script getting interrupted lock *Determine who sent the message doif _p1_ = pntr *Check for grendels etch 4 2 0 nohh zomb 1 pose 80 dirn 1 doif targ <> null spas ownr targ endi wait 2 doif targ <> null doif carr = null zomb 0 endi endi next *Get everyone in the lift gpas 4 0 0 1 else targ _p1_ *If it was a creature, just pick that creature up doif fmly = 4 doif gnus = 2 nohh zomb 1 pose 80 dirn 1 wait 4 doif targ <> null spas ownr targ endi wait 2 doif targ <> null doif carr = null zomb 0 endi endi else spas ownr targ endi endi *Otherwise, just skip this step endi lock targ _p2_ *Get positioning info setv va00 posb targ ownr *Mark yourself as moving setv ov00 1 *Light up "Go up" button part 2 pose 1 *Make some noise sndl "c2sl" *Time to move it, move it loop *Keep moving up until you've reached the call button setv vely 2 untl posb >= va00 *Stop moving velo 0 0 *Shut the call button off targ _p2_ pose 0 *Get its level setv va01 ov01 targ ownr *Shut light off part 2 pose 0 *Stop making noise fade *Drop everyone and stim with "Traveled in lift" epas 4 0 0 zomb 0 stim writ targ 94 1 next dpas 4 0 0 *Change level and mark yourself as not moving setv ov00 0 setv ov01 va01 endm *Button push scrp 2 12 1000 1 inst stim writ from 89 1 *Light up and play a sound pose 1 snde "ding" *Now determine who sent the message doif from = pntr *If it was the hand, note it seta va99 from else *Otherwise, note yourself seta va99 ownr endi *Now find your lift doif ov16 <> null targ ov16 *If it's moving, activate your timer script so you can call it then doif ov00 = 1 targ ownr tick 50 stop endi *And don't do anything if you're both on the same level doif ov01 = mv01 targ ownr pose 0 stop endi *Now check the lift's position compared to your own doif ov01 < mv01 *It's underneath you, so tell it to go up mesg wrt+ targ 1000 va99 ownr 0 elif ov01 > mv01 *It's above you, so tell it to go down mesg wrt+ targ 1001 va99 ownr 0 endi endi endm *Button pull scrp 2 12 1000 2 inst stim writ from 89 1 *Light up and play a sound pose 1 snde "ding" *Now determine who sent the message doif from = pntr *If it was the hand, note it seta va99 from else *Otherwise, note yourself seta va99 ownr endi *Now find your lift doif ov16 <> null targ ov16 *If it's moving, activate your timer script so you can call it then doif ov00 = 1 targ ownr tick 50 stop endi *And don't do anything if you're both on the same level doif ov01 = mv01 targ ownr pose 0 stop endi *Now check the lift's position compared to your own doif ov01 < mv01 *It's underneath you, so tell it to go up mesg wrt+ targ 1000 va99 ownr 0 elif ov01 > mv01 *It's above you, so tell it to go down mesg wrt+ targ 1001 va99 ownr 0 endi endi endm *Button hit script scrp 2 12 1000 3 *Stimulate with I have hit machine stim writ from 92 1 *Blink the call button light on and off anim [0 1 255] *Play a buzzing sound (included by default with C3 and DS) snde "buzz" *Wait until the buzzing sound is over wait 7 *Resume a ready-to-serve pose. pose 0 endm *Button timer scrp 2 12 1000 9 inst *Find your lift doif ov16 <> null targ ov16 *If it's still moving, wait a little longer doif ov00 = 1 stop endi *Now check the lift's position compared to your own doif ov01 < mv01 *It's underneath you, so tell it to go up mesg wrt+ targ 1000 ownr ownr 0 elif ov01 > mv01 *It's above you, so tell it to go down mesg wrt+ targ 1001 ownr ownr 0 endi targ ownr tick 0 endi endm *Removal rscr enum 3 1 1000 kill targ next enum 2 12 1000 kill targ next scrx 3 1 1000 1 scrx 3 1 1000 2 scrx 3 1 1000 1000 scrx 3 1 1000 1001 scrx 2 12 1000 1 scrx 2 12 1000 2 scrx 2 12 1000 3 scrx 2 12 1000 9
Moving on[edit]
- Reserve and use your own class numbers at Creatures Caves.
- Follow the Creating a Metaroom tutorial, change the coordinates of the installation scripts (using the keyboard shortcut CTRL + SHIFT + X), and use the CAOS2PRAY "LINK" command (as described by Pilla in Make an .agents file) to include the lift in the new metaroom.
- Search on OpenGameArt.org or take inspiration from the Creating Agent Art tutorial to make a new sprite for your lifts.
- Can you work out how to make a three-level lift?
- Adding a 'pushed button' stimulus for the call button push script has been experimentally tested and adding the stimulus generally produces a lower amount of button pushes, while not producing an observable change in behavior.
Credits[edit]
This lift script is derived from the lifts in Risen Angel's C2 Swamp.
External links[edit]
- Using the Map Editor - Part 2 - discusses another way of coding an elevator.