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

Basic seed as food script

From Creatures Wiki
Jump to navigation Jump to search

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 “Inert Seed.agents"
*# C3-Name “Inert Seed C3"
*# DS-Name “Inert Seed DS"
*# attach tutorial_seed.c16
*# attach smit.wav
*# attach chwp.wav
*# desc = “An inert seed which is a simple foodstuff for creatures, nothing more.“
*# Agent Animation File = “tutorial_seed.c16"
*# Agent Animation String = "0"
*# Agent Sprite First Image = 0
*# Agent Animation Gallery = “tutorial_seed”
*# Web URL = "creatures.wiki"
*# Web Label = "Creatures Wiki"

Installation script

Anything with a * in front of it is a comment, not read by the machine.

********Lets make a seed

Let's do this INSTantaneously

inst

Repeat the following 5 times:

reps 5

Create a new simple agent, using the classifier numbers 2 3 1000 (a seed of genus 1000) and using the sprite (image) file "tutorial_seed.c16". Use one image from the tutorial_seed file, located at position 0 in the file (because computers start counting at 0) and have it at image plane 5000 in the world. A common error that can be introduced here is "Pose change failed", caused by miscounting the amount of images that are being used, by not including image #0.

new: simp 2 3 1000 “tutorial_seed” 1 0 5000

Various attributes - it is carryable, mouse-carryable, suffers collisions and suffers physics. Amaikokonut's CAOS APPS can be used to help choose new ATTR and BHVR values.

attr 195

Can be picked up and eaten.

bhvr 48

It is slightly bouncy

elas 30

Has a medium friction

fric 50

Is moderately heavy

accg 3

The following block of code tests whether the seed can be moved to a point below the Creatures 3 Norn Meso garden, and then if that's not possible, it tries to install the seed near the DS agent creator in the Comms Room. Ghosthande's basic agent tutorial discusses a few more options when it comes to install locations.

doif tmvt 1950 950 eq 1
mvto 1950 950
else
setv va00 game “CreatorX”
setv va01 game “CreatorY”
mvsf va00 va01
endi

And smell like a seed should.

emit 7 0.3

This closes the REPS loop from before.

repe

This moves the player's vision to the foodstuff.

cmrt 0

Collision script

The collision script simply plays a sound (smit.wav) when the object hits the ground.

******collision script:
scrp 2 3 1000 6
sndc "smit"
endm

Eat script

The eat script LOCKs to prevent interuption, then plays a crunchy chewing sound and stimulates the eater with stimuli 77. It then removes the seed object from the world. You can use CHEM here (before KILL OWNR) to inject other chemicals as well if you want.

*****eat script
scrp 2 3 1000 12
	lock
	sndc "chwp"
	stim writ from 77 1
	kill ownr
endm


Removal script

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 2 3 1000
	kill targ
next
scrx 2 3 1000 4
scrx 2 3 1000 6
scrx 2 3 1000 12

Whole script

**CAOS2PRAY
*# Pray-File “Inert Seed.agents"
*# C3-Name “Inert Seed C3"
*# DS-Name “Inert Seed DS"
*# attach tutorial_seed.c16
*# attach smit.wav
*# attach chwp.wav
*# desc = “An inert seed which is a simple foodstuff for creatures, nothing more.“
*# Agent Animation File = “tutorial_seed.c16"
*# Agent Animation String = "0"
*# Agent Sprite First Image = 0
*# Agent Animation Gallery = “tutorial_seed”
*# Web URL = "creatures.wiki"
*# Web Label = "Creatures Wiki"


********Lets make a seed
inst
reps 5
new: simp 2 3 1000 “tutorial_seed” 1 0 5000
attr 195
bhvr 48
elas 30
fric 50
accg 3
*create some underneath the garden
doif tmvt 1950 950 eq 1
mvto 1950 950
else
*if that doesn't work, create it at the agent creator for DS
setv va00 game “CreatorX”
setv va01 game “CreatorY”
mvsf va00 va01
endi
emit 7 0.3
repe
cmrt 0

******collision script:
scrp 2 3 1000 6
sndc “smit”
endm

*****eat script
scrp 2 3 1000 12
	lock
	sndc "chwp"
	stim writ from 77 1
	kill ownr
endm



********REMOVAL
rscr
enum 2 3 1000
	kill targ
next
scrx 2 3 1000 6
scrx 2 3 1000 12

Moving on

See also