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

Difference between revisions of "Gardenboxifying a Traditional Plant"

From Creatures Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ ==Introduction== right|Sharmflower sprite images. This plant script uses a few basic variables and is coded so that creatures can push,...")
 
(One intermediate revision by the same user not shown)
Line 22: Line 22:
 
   *# desc = "A plant that grows and ungrows, and creatures can get food from. Injects one at a time."
 
   *# desc = "A plant that grows and ungrows, and creatures can get food from. Injects one at a time."
  
The plant is in the GB Category 1, which [http://bargles.skinhorse.net/viewtopic.php?f=7&t=36 means it will show up as a 'traditional plant'].
+
The plant is in the GB Category 2, which [http://bargles.skinhorse.net/viewtopic.php?f=7&t=36 means it will show up as a 'traditional plant'].
  
   *# GB_Category = 1
+
   *# GB_Category = 2
  
 
The Agent Author is a new field created for the Garden Box.
 
The Agent Author is a new field created for the Garden Box.
Line 40: Line 40:
 
   *# Agent Animation Gallery = "sharmflower"
 
   *# Agent Animation Gallery = "sharmflower"
 
   *# Web URL = "creatures.wiki"
 
   *# Web URL = "creatures.wiki"
   *# Web Label = "Creatures Wiki"  
+
   *# Web Label = "Creatures Wiki"
  
 
==Installation Script==
 
==Installation Script==
Line 144: Line 144:
 
*# attach sharmflower.c16
 
*# attach sharmflower.c16
 
*# desc = "A plant that grows and ungrows, and creatures can get food from. Injects one at a time."
 
*# desc = "A plant that grows and ungrows, and creatures can get food from. Injects one at a time."
*# GB_Category = 1
+
*# GB_Category = 2
 
*# Agent Author = "Creatures Wiki"
 
*# Agent Author = "Creatures Wiki"
 
*# Agent Animation File = "sharmflower.c16"
 
*# Agent Animation File = "sharmflower.c16"

Revision as of 00:52, 19 April 2019

Introduction

Sharmflower sprite images.

This plant script uses a few basic variables and is coded so that creatures can push, pull or hit the plant, with the appropriate stimulus attached so that the creature is rewarded for playing with the plant. This focuses on taking the plant described in the Basic interactive plant script part 2 and making it compatible with Amaikokonut's Garden Box injection system, using the sprite file File:Sharmflower.c16 for both the Garden Box preview image and the in-game images. This plant is a 'traditional plant' and so is suitable for precision-placement. Please note that this version removes obsolete code relating to checking GNAM and installing cheese: because the Garden Box is DS-only, only peaking pie will be vended. The timer script also removes the feature where plants would die if they landed on a non-soil room type to avoid player disappointment. It's useful to use the CAOS Tool or another highlighting tool because they can make the CAOS syntax easier to read.

The major differences in creating a plant for the garden box lie in the CAOS2PRAY coding and the injection script.

CAOS2PRAY

Monk, ready to use CAOS2PRAY.

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 dependent 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 "BasicInteractivePlant_GB_single.agents"

All Garden Box agents are DS-only, and so all you need to do is use *# DSGB-Name in the CAOS2PRAY chunk and give your agent a unique name, rather than have two names for the C3 version and the DS version.

 *# DSGB-Name "Basic Interactive Plant Single"
 *# attach sharmflower.c16

Short and sweet is the aim of the game in a GB plant description.

 *# desc = "A plant that grows and ungrows, and creatures can get food from. Injects one at a time."

The plant is in the GB Category 2, which means it will show up as a 'traditional plant'.

 *# GB_Category = 2

The Agent Author is a new field created for the Garden Box.

 *# Agent Author = "Creatures Wiki"

It is ideal that the preview image for the Garden Box is 40x40 pixels. If you search for crop image in DuckDuckGo, you will find some online image editors or some tutorials for programs that you can use to make such an image. Saving it as a PNG makes it compatible with Jagent's Edos sprite-compiling feature. Smaller versions, like the 32x32 image used here for the Sharmflower may be acceptable, but may show out of alignment with other GB images.

 *# Agent Animation File = "sharmflower.c16"

This is the mature flower of the sharmflower.

 *# Agent Animation String = "5"
 *# Agent Sprite First Image = 5
 *# Agent Animation Gallery = "sharmflower"
 *# Web URL = "creatures.wiki"
 *# Web Label = "Creatures Wiki"

Installation Script

When installing the plant, it is sometimes more essential to pay attention to the physics required. The elasticity of 0 means that the plant will not bounce, which is usually what's wanted. Note that REPE and REPS have been removed. The GAME variables "ch_x" and "ch_y" were created by Amaikokonut for the Garden Box and mean where the crosshairs of the GB are.

inst
new: simp 2 4 6006 "sharmflower" 6 0 rand 200 6000
attr 196
bhvr 11
*setting a RANGE of 100 for smart vending abilities
rnge 100
elas 0
setv ov00 0
setv ov99 0
tick rand 300 1000
mvsf game "ch_x" game "ch_y"

Timer Script

Please note that as the Basic interactive plant script part 2 is programmed to die if it lands on a non-soil room (see the Timer script in the earlier tutorial for a discussion of this), players may be disappointed as they cannot plant the plant everywhere. This has been resolved in the code below by removing the relevant code and changing to a new class number. Please also note that obsolete code relating to making the plant vend cheese has been removed, as the Garden Box only works with DS or docked worlds, not Creatures 3 standalone.

*timer script
scrp 2 4 6006 9
*Grow UP
	doif ov00 eq 0
		doif pose lt 5
			setv va00 pose
			addv va00 1
			pose va00
		else
*remain in a mature pose, add to age counter.		
			addv ov99 1
*instantly check to make sure that there are no peaking pies touching the plant, and if not, vend another if plant is fully mature.
			inst
			etch 2 11 7
				doif targ = null
					mesg writ ownr 1000
				endi
			next
			slow
*you've been mature for too long now, prepare to become immature.	
			doif ov99 eq 50
				setv ov00 1
*MESG the vend script, starting off the vend routine.		
				mesg writ ownr 1000
			endi
		endi
*grow DOWN	
		doif ov00 eq 1
			doif pose gt 0
				setv va00 pose
				subv va00 1
				pose va00
			else
*Reset plant		
				setv ov99 0
				setv ov00 0
			endi
		endi
	endi
endm


Script 1000: Custom Vending Script

Please note that obsolete code relating to making the plant vend cheese has been removed, as the Garden Box only works with DS or docked worlds, not Creatures 3 standalone. The following is very similar to the script used in the Making a Smart Vendor tutorial, but it is broken out into its own script to make it easier to call at multiple different occasions.

scrp 2 4 6006 1000
	lock
	setv va66 0
	esee 2 11 7
		addv va66 1
	next
	targ ownr
	doif va66 le 2
		setv va00 posx
		setv va01 post
		inst
		new: simp 2 11 7 "ds empathic vendor" 3 42 425
		attr 195
		bhvr 48
		perm 64
		elas 30
		accg 5
		fric 100
		mvsf va00 va01
		velo rand -5 10 rand 1 20
		emit 8 .5
		tick 120
		slow
	endi
	targ ownr
	unlk
endm


Whole Script

**CAOS2PRAY
*# Pray-File "BasicInteractivePlant_GB_single.agents"
*# DSGB-Name "Basic Interactive Plant Single"
*# attach sharmflower.c16
*# desc = "A plant that grows and ungrows, and creatures can get food from. Injects one at a time."
*# GB_Category = 2
*# Agent Author = "Creatures Wiki"
*# Agent Animation File = "sharmflower.c16"
*# Agent Animation String = "5"
*# Agent Sprite First Image = 5
*# Agent Animation Gallery = "sharmflower"
*# Web URL = "creatures.wiki"
*# Web Label = "Creatures Wiki" 

inst
new: simp 2 4 6006 "sharmflower" 6 0 rand 200 6000
attr 196
bhvr 11
*setting a RANGE of 100 for smart vending abilities
rnge 100
*unbouncy
elas 0
*OV00: plant state: 0 is growing up, 1 is growing down.
setv ov00 0
*OV99: age counter
setv ov99 0
*random timer between 15 and 50 seconds.
tick rand 300 1000
*safely move to GB crosshairs
mvsf game "ch_x" game "ch_y"

*push script
scrp 2 4 6006 1
	stim writ from 84 1
	mesg writ ownr 1000
endm

*pull script
scrp 2 4 6006 2
	stim writ from 84 1
	mesg writ ownr 1000
endm

*timer script
scrp 2 4 6006 9
*Grow UP
	doif ov00 eq 0
		doif pose lt 5
			setv va00 pose
			addv va00 1
			pose va00
		else
*remain in a mature pose, add to age counter.		
			addv ov99 1
*instantly check to make sure that there are no peaking pies touching the plant, and if not, vend another if plant is fully mature.
			inst
			etch 2 11 7
				doif targ = null
					mesg writ ownr 1000
				endi
			next
			slow
*you've been mature for too long now, prepare to become immature.	
			doif ov99 eq 50
				setv ov00 1
*MESG the vend script, starting off the vend routine.		
				mesg writ ownr 1000
			endi
		endi
*grow DOWN	
		doif ov00 eq 1
			doif pose gt 0
				setv va00 pose
				subv va00 1
				pose va00
			else
*Reset plant		
				setv ov99 0
				setv ov00 0
			endi
		endi
	endi
endm

*Hit script
scrp 2 4 6006 3
	stim writ from 84 1
*this makes sure that the plant itself is targeted to change pose.	
	targ ownr
*the plant grows DOWN if it is hit.	
	doif pose gt 0
		setv va00 pose
		subv va00 1
		pose va00
*plant can be smushed to death		
	elif pose eq 0
		kill ownr
	endi
endm

scrp 2 4 6006 1000
	lock
*count peaking pies
	setv va66 0
	esee 2 11 7
		addv va66 1
	next
	targ ownr
*if there aren't peaking pies nearby, set coordinates and...
	doif va66 le 2
		setv va00 posx
		setv va01 post
*make a fresh peaking pie: note it is exactly the same as the official one, but moves to the coordinates we just set.
		inst
		new: simp 2 11 7 "ds empathic vendor" 3 42 425
		attr 195
		bhvr 48
		perm 64
		elas 30
		accg 5
		fric 100
		mvsf va00 va01
		velo rand -5 10 rand 1 20
		emit 8 .5
		tick 120
		slow
*end 'if there aren't peaking pies nearby' check
	endi
	targ ownr
	unlk
endm

*REMOVE ME
rscr
enum 2 4 6006
	kill targ
next
scrx 2 4 6006 1
scrx 2 4 6006 2
scrx 2 4 6006 9
scrx 2 4 6006 3
scrx 2 4 6006 1000