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

Vendor as plant script

From Creatures Wiki
Revision as of 04:39, 12 June 2020 by ScoobyGambit (talk | contribs) (Created page with "** ** Plant script ** ==Install script== new: simp 2 4 2000 "tutorial_tomato" 2 0 1100 * The construction script automatically gets called after creation (= now) * The plant...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
    • Plant script

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
mesg wrt+ pntr 1000 targ null 0 

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 + 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)

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 food object can be created in this spot

doif tmvt va02 va03 eq 1

  • If yes, create it

mvto va02 va03

  • also move the food 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 food 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

  • This could have been "create detritus" but I'm lazy and I'll just kill the food.

kill ownr retn endm


Remove scripts

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

* 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
 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 food object can be created in this spot
		doif tmvt va02 va03 eq 1
* If yes, create it
			mvto va02 va03
* also move the food 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

** Food 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 food 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
* This could have been "create detritus" but I'm lazy and I'll just kill the food.
		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