Vendor as plant script
A Docking Station tomato agent, using the sprite file File:tutorial_tomato.c16. It is a single feature plant which vends a fruit object if it is pushed, pulled, hit, and on a regular timed basis, with appropriate stimuli. Fragrant fruit will usually appear around the foot of the tomato plant, attracting creatures. It's useful to use the CAOS Tool or another highlighting tool to read the code because they can make the CAOS syntax easier to read.
Contents
- 1 CAOS2PRAY
- 2 Install script
- 3 Plant construction script
- 4 Plant Activate 1 (push) script (play with plant)
- 5 Plant Activate 2 (pull) script (play with plant)
- 6 Plant hit script (play with plant)
- 7 Plant Timer script
- 8 Fruit creation script
- 9 Fruit eat script
- 10 Fruit Timer script
- 11 Remove scripts
- 12 Whole script
CAOS2PRAY[edit]
CAOS2PRAY is a feature included with RProgrammer's Jagent which allows the coder to not have to code a separate PRAY file in their agents. This chunk of code goes at the top of the COS file, and when it is dragged and dropped onto Monk (also part of the Jagent suite), compiles the cos file, with its dependant sprite file, into an agent that will be easy for everyone to install and play with. For more details on CAOS2PRAY, see CAOS2PRAY: An Easier Way by Amaikokonut.
**CAOS2PRAY *# Pray-File "tutorial_tomato.agents" *# DS-Name "Tutorial Tomato" *# attach tutorial_tomato.c16 *# desc = "A feature plant for your Capillata." *# Agent Animation File = "tutorial_tomato.c16" *# Agent Animation String = "0" *# Agent Sprite First Image = 0 *# Agent Animation Gallery = "tutorial_tomato" *# Web URL = "creatures.wiki" *# Web Label = "Creatures Wiki"
Install script[edit]
The plant will be created held in the hand
new: simp 2 4 2000 "tutorial_tomato" 2 0 1100 * The construction script automatically gets called after creation (= now) * The plant has been created now, move it into the correct place mesg wrt+ pntr 1000 targ null 0
Plant construction script[edit]
scrp 2 4 2000 10 * Call the construction script instantly inst * Attr: mouseable 2 + collide 64 + physics 128 = 194 attr 194 * Bhvr: act1 1 + act 2 2 + hit 8 bhvr 11 * Set physics attributes accg 2 aero 3 * Set collision attributes perm 100 fric 100 elas 0 * emit flower smell (optional, if it is a flower) emit 9 0.3 * set the timer script to a random tick (timer script gets called to make fruit) tick rand 400 800 endm
Plant Activate 1 (push) script (play with plant)[edit]
scrp 2 4 2000 1 * Stim the pushing creature (from) with "played with good plant" stim writ from 84 1 ** Reset the timer script mesg writ ownr 9 endm
Plant Activate 2 (pull) script (play with plant)[edit]
scrp 2 4 2000 2 * Stim the pulling creature (from) with "played with good plant" stim writ from 84 1 ** Reset the timer script mesg writ ownr 9 endm
Plant hit script (play with plant)[edit]
scrp 2 4 2000 3 * Stim the hitting creature (from) with "played with good plant" stim writ from 84 1 ** Reset the timer script mesg writ ownr 9 endm
Plant Timer script[edit]
scrp 2 4 2000 9 * set the tick to a random value again tick rand 400 800 * if there's a tomato on the plant, create fruit. doif pose ne 1 * Create fruit * Save the coordinates of the plant into variables so the fruit can be created at the plant setv va02 posl setv va03 post * Create a new fruit object new: simp 2 8 2000 "tutorial_tomato" 1 2 1200 * Check if the fruit object can be created in this spot doif tmvt va02 va03 eq 1 * If yes, create it mvto va02 va03 * also move the fruit away from the plant velo rand -5 5 -5 else * If not, kill it kill targ endi endi *setting targ to the ownr of the script targ ownr *look plucked pose 1 *wait a second wait 20 *grow back your tomato pose 0 endm
Fruit creation script[edit]
scrp 2 8 2000 10 * Attr: mouseable 2 + collide 64 + physics 128 = 194 attr 194 * Bhvr: eat 16 + pick up 32 bhvr 48 * Set physics attributes accg 2 aero 3 * Set collision attributes perm 60 fric 60 elas 30 * Emit fruit smell emit 6 0.3 * Set a tick after which the fruit will decay tick 3000 endm
Fruit eat script[edit]
scrp 2 8 2000 12 * Stim the eating creature with "eaten fruit" stim writ from 78 2 kill ownr endm
Fruit Timer script[edit]
scrp 2 8 2000 9 * If around for too long, kill it * First check if it's not being carried doif carr eq null * Go to the dying subroutine gsub detritus else * It's being carried. Make the tick smaller now since it's quite old already and should decay some while after being dropped. tick 200 endi * This is the detritus subroutine subr detritus * At this point, you could include a detritus subroutine, but in this case we're just going to kill the fruit. kill ownr retn endm
Remove scripts[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!
rscr enum 2 4 2000 kill targ next enum 2 8 2000 kill targ next scrx 2 4 2000 10 scrx 2 4 2000 1 scrx 2 4 2000 2 scrx 2 4 2000 3 scrx 2 4 2000 9 scrx 2 8 2000 10 scrx 2 8 2000 12 scrx 2 8 2000 9
Whole script[edit]
**CAOS2PRAY *# Pray-File "tutorial_tomato.agents" *# DS-Name "Tutorial Tomato" *# attach tutorial_tomato.c16 *# desc = "A feature plant for your Capillata." *# Agent Animation File = "tutorial_tomato.c16" *# Agent Animation String = "0" *# Agent Sprite First Image = 0 *# Agent Animation Gallery = "tutorial_tomato" *# Web URL = "creatures.wiki" *# Web Label = "Creatures Wiki" * Install script new: simp 2 4 2000 "tutorial_tomato" 2 0 1100 * The construction script automatically gets called after creation (= now) * The plant has been created now, move it into the correct place - held in the hand mesg wrt+ pntr 1000 targ null 0 ** ** Plant scripts ** ** Plant construction script scrp 2 4 2000 10 * Call the construction script instantly inst * Attr: mouseable 2 + collide 64 + physics 128 = 194 attr 194 * Bhvr: act1 1 + act2 2 + hit 8 bhvr 11 * Set physics attributes accg 2 aero 3 * Set collision attributes perm 100 fric 100 elas 0 * emit flower smell (optional, if it is a flower) emit 9 0.3 * set the timer script to a random tick (timer script gets called to make fruit) tick rand 400 800 endm ** Plant Activate 1 (push) script (play with plant) scrp 2 4 2000 1 * Stim the pushing creature (from) with "played with good plant" stim writ from 84 1 ** Reset the timer script mesg writ ownr 9 endm ** Plant Activate 2 (pull) script (play with plant) scrp 2 4 2000 2 * Stim the pulling creature (from) with "played with good plant" stim writ from 84 1 ** Reset the timer script mesg writ ownr 9 endm ** Plant hit script (play with plant) scrp 2 4 2000 3 * Stim the hitting creature (from) with "played with good plant" stim writ from 84 1 ** Reset the timer script mesg writ ownr 9 endm ** Plant Timer script scrp 2 4 2000 9 * set the tick to a random value again tick rand 400 800 * if there's a tomato on the plant, create fruit. doif pose ne 1 * Create fruit * Save the coordinates of the plant into variables so the fruit can be created at the plant setv va02 posl setv va03 post * Create a new fruit object new: simp 2 8 2000 "tutorial_tomato" 1 2 1200 * Check if the fruit object can be created in this spot doif tmvt va02 va03 eq 1 * If yes, create it mvto va02 va03 * also move the fruit away from the plant velo rand -5 5 -5 else * If not, kill it kill targ endi endi *setting targ to the ownr of the script targ ownr *look plucked pose 1 *wait a second wait 20 *grow back your tomato pose 0 endm ** Fruit creation script scrp 2 8 2000 10 * Attr: mouseable 2 + collide 64 + physics 128 = 194 attr 194 * Bhvr: eat 16 + pick up 32 bhvr 48 * Set physics attributes accg 2 aero 3 * Set collision attributes perm 60 fric 60 elas 30 * Emit fruit smell emit 6 0.3 * Set a tick after which the fruit will decay tick 3000 endm ** Fruit eat script scrp 2 8 2000 12 stim writ from 78 2 kill ownr endm ** Fruit Timer script scrp 2 8 2000 9 * If around for too long, kill it * First check if it's not being carried doif carr eq null * Go to the dying subroutine gsub detritus else * It's being carried. Make the tick smaller now since it's quite old already and should decay some while after being dropped. tick 200 endi * This is the detritus subroutine subr detritus * At this point you could create a detritus subroutine, but I'm just going to kill the fruit. kill ownr retn endm rscr enum 2 4 2000 kill targ next enum 2 8 2000 kill targ next scrx 2 4 2000 10 scrx 2 4 2000 1 scrx 2 4 2000 2 scrx 2 4 2000 3 scrx 2 4 2000 9 scrx 2 8 2000 10 scrx 2 8 2000 12 scrx 2 8 2000 9