Welcome to the Creatures Wiki! Log in and join the community.

Simple door script

From Creatures Wiki
Jump to: navigation, search

This is a very basic door which can be pushed by a creature to transfer to the linked door, or by the hand to teleport the camera and the creatures that are currently touching the door.

We will create four doors: two on the upper level of the norn meso, and their partnering doors in the workshop and comms room. These doors will be CA linked, and both creatures and the hand will be able to push the door to be transferred to the partnering door. When the door is clicked, it will enumerate over all the doors with the classifier you use and search for the partnering door. If they found their partnering door, the creature(s) and/or the hand will be moved to that door. There will also be a removal script that enumerates over all doors, kills them and remove the script from the scriptorium.

[Open the full script code]

Install Script[edit]

  • Make the script run instantly
inst
  • Make the first door! This one is going to be the leftmost door in the top left part of the norn meso. This door will link to the agent injector.
  • Create a simple object that classifies as a door. For convenience's sake, we will use the image of the existing DS teleporters, which are called "ds portals.c16" in the image folder. I will just be using 1 sprite, the 11th, since that one looks cute. You could totally use your own sprite or even add animations in the push script, just be sure to ajdust the image_count and first_image in the new: simp script. We want the door's plane to be behind the creature, so we'll set it to 550.
new: simp 2 2 20855 "ds portals" 1 11 550
  • Give the door the correct attribute flags, we'll make them clickable by the pointer, which means a total attribute value of 4.
attr 4
  • Now give the door the correct behaviour: creatures can activate 1 (push) it, which makes for a total behaviour value of 1.
bhvr 1
setv ov00 0
  • Move the door to the correct place: this one goes in the upper left part of the norn meso. You can pick your own spot by clicking ctrl-alt-x ingame, then the pointer will show the coordinates it's currently at.
mvto 810 8814
  • Get the room id of the xcoord ycoord of the door, then set it in a temporary variable va00
setv va00 grap posx posy
  • We made our first door! On to the second one, which is the partnering door of the first one. The second one can be found at the workshop, at the bottom left.
new: simp 2 2 20855 "ds portals" 1 11 550
attr 4
bhvr 1
setv ov00 0
mvto 4478 9368
setv va01 grap posx posy
  • Now, to allow Cellular Automata to travel freely, we'll link these two doors, using the temporary variables va00 and va01.
link va00 va01 100
  • The first two doors are done now. Let's now make the next two doors (which belong to another door group, so their OV00s are different from the first group.) The third door is in the norn meso, a bit to the right of the first door, and the fourth door is in the agent injector. Then we'll link the third and fourth door.
new: simp 2 2 20855 "ds portals" 1 11 550
attr 4
bhvr 1
setv ov00 1
mvto 910 8827
setv va00 grap posx posy
new: simp 2 2 20855 "ds portals" 1 11 550
attr 4
bhvr 1
setv ov00 1
mvto 6305 9097
setv va01 grap posx posy
link va00 va01 100
  • You now made 4 doors. Congratulations! Now we have to write their activation script.

Event Scripts[edit]

  • Create an event script for the doors that activates when you send a Push message to it. Don't forget to close your script block with endm at the end.
scrp 2 2 20855 1
  • We want this script to be locked, so it can't be interrupted by other norns when someone activated it.
lock
  • Hmm, so we got a push message. Let's enumerate over all doors to find your partnering door. Don't forget to close your enumeration block with next at the end of the enumeration script. Before we can enumerate, we'll have to save the object variable of the door that received the click into a temporary variable, since when you enumerate over agents, they get TARGeted and you won't be able to reach any of the object variables of the original door. We will save the door group (stored in ov00).
setv va00 ov00
seta va01 targ
enum 2 2 20855
  • You're now inside of the enumeration loop. Make sure that the door you're currently targeting isn't the door being activated.
doif targ ne va01
  • Check if this door belongs to the same group as the original door
doif ov00 eq va00
  • If yes, WOO, you've found your partnering door! Let's save the coordinates in temporary variables first.
setv va02 posx
setv va03 posy
  • Now, let's check who actually called the script: was it the pointer and do we need to teleport all touching creatures AND the camera, or was it a creature and do we only have to teleport that creature, and eventually the camera if it's locked to that creature?
  • Let's assume it's the pointer first. If it is the pointer
doif from eq pntr
  • Move the center of the camera to the xcoord ycoords of the partnering door
 cmrp va02 va03 1
  • Target the original door
 targ ownr
  • For each creature touching the door:
 etch 4 0 0
  • Check if the creature can move to the xcoord ycoords of the partnering door. If they can, move them.
 doif tmvf va02 va03 eq 1
  mvft va02 va03
 endi
  • End the creatures enumeration loop and "pointerclick" script.
next
endi
  • Now let's assume it's not the pointer but a creature. Then just that creature should be moved, but if the camera is locked on that creature, then the camera view should move too. Check if it's a creature:
doif crea from eq 1
  • If it's a creature, target it and check if it can be moved to the xcoord ycoord of the partnering door.
 targ from
 doif tmvf va02 va03 eq 1
  • If the camera is currently tracking this creature, move the camera.
  doif trck eq from
   cmrp va02 va03 1
  endi
  • Move the creature
  mvft va02 va03
  • End the block where it checks whether the creature can move, and the creatureclick script.
 endi
endi
  • When you've found the partnering door, stop the script at the end of this block, so it won't run any inneccessary enumeration loops
stop
  • End the 'if found partnering door' block, the 'if not me' block and the 'enumerate over all doors' loop.
endi
endi
next
  • Unlock and end the script
unlk
endm

Removal script[edit]

  • The removal script identification tag
rscr
  • Enumerate over all the doors and kill them
enum 2 2 20855
kill targ
next
  • Remove the push script from the scriptorium
scrx 2 2 20855 1

Credits[edit]

Pilla

External links[edit]