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

C1 Carp Lanterns (teardown)

From Creatures Wiki
Jump to navigation Jump to search
C1 Carp Lanterns
This article is a teardown of an existing CAOS script.
Game Version Creatures 3 and Docking Station
Filename(s)
Classifier
Dependencies
Images C1CarpLanterns.c16
Sounds c1d7.wav, c1c4.wav
Catalogue Tags
Agents
Other none

This is a teardown page explaining the details and inner workings of this agent. For general information, see C1 Carp Lanterns

C1 Carp Lanterns is a simple toy agent made for Creatures 3 and Docking Station by Jesseth and CosmicSynthetics.

This object has a dual functionality: to creatures, it is a fun toy that can be pushed, pulled and hit, and to the hand, it can be used to decorate their world (including by easily flipping the agent) and add cellular automata to areas that may require more light. Note the use of a DOIF condition in the Activate 1 script to allow the coder to specify what happens when the hand shift-clicks, normal-clicks and if a creature decides to play with it.

Scripts[edit]

CAOS2PRAY[edit]

CAOS2PRAY template for use with Jagent.

**CAOS2PRAY
*# Pray-File "C1CarpLanterns.agents"
*# C3-Name "C1 Carp Lanterns C3"
*# DS-Name "C1 Carp Lanterns DS"
*# attach C1CarpLanterns.c16
*# attach c1d7.wav
*# attach c1c4.wav
*# attach C1CarpLanterns.catalogue
*# desc = "Cute lanterns based on background graphics from C1 that emit light when activated and can be played with by creatures. Shift click to flip it! Made for the CCSF 2021. Sprites by Jesseth and code by CosmicSynthetics."
*# Agent Animation File = "C1CarpLanterns.c16"
*# Agent Animation String = "0"
*# Agent Sprite First Image = 0
*# Agent Animation Gallery = "C1CarpLanterns"
*# Web URL = "https://tumblr.cosmicsynthetics.com/"
*# Web Label = "CosmicSynthetics on Tumblr"


Developer's notes[edit]

Some developers put a 'cheat sheet' for themselves at the top of their code to help organise themselves.

*TEMP SPECIES #: 3333
*FINAL SPECIES #: 15402

*ANIMATION NOTES:
*0=off stationary
*1=off sway left
*2=off sway right
*3=on stationary
*4=on sway left
*5=on sway middle
*6=on sway right

*SOUND NOTES:
*c1d7.wav=sway
*c1c4.wav=click

*NOTE: Shift click to flip the lantern!

Installation script[edit]

*** MAKE TOY (C1 Carp Lanterns)
inst
new: simp 2 21 15402 "C1CarpLanterns" 7 0 800

* Creature-to-agent Permissions: 1 push, 2 pull, 8 hit
bhvr 11
* Agent Properties: 2 Mouseable, 4 Activateable
attr 6
* Acceleration - none
accg 0
* Permeability - can be set anywhere
perm 100
* Friction - never slides
fric 100
* Elasticity - none
elas 0

*PLACE AGENT AT AGENT INJECTOR (C3 and DS - Default for this template)
doif gnam = "Creatures 3"
	doif tmvt 5702 3624 eq 1
		mvto 5702 3624
	else
		mvsf 5702 3624
	endi
elif gnam = "Docking Station"
	doif tmvt 6073 9174 eq 1
		mvto 6073 9174
	else
		mvsf 6073 9174
	endi
endi

Activate 1[edit]

**SCRIPTS: C1 Carp Lanterns
*SCRIPT 1: Activate 1 (Push)
scrp 2 21 15402 1
*If pushed by the hand...
*... while holding down shift...
	doif from eq pntr
		doif keyd 16 = 1
 			doif mira = 0
				mira 1
			else
 				mira 0
			endi
*...Otherwise, if just a normal click...
		else
*Check if the lamp is off and turn it on
			doif pose = 0
				sndc "c1c4"
				pose 3
				emit 1 0.8
*If the lamp is already on, turn it off
			elif pose = 3
				sndc "c1c4"
				pose 0
				emit 1 0
*End do-if-else sequence
			endi
		endi
*If not pushed by the hand...
	else
*Stimulate creature, play a sound, and sway (lamp off)
		doif pose = 0
			stim writ from 97 1
			sndc "c1d7"
			anim [0 1 0 2 0]
*Stimulate creature, play a sound, and sway (lamp on)
		elif pose = 3
			stim writ from 97 1
 			sndc "c1d7"
			anim [3 4 5 6 5 3]
		endi
*End do-if-else sequence
	endi
*End script
endm

Activate 2[edit]

*SCRIPT 2: Activate 2 (Pull)
scrp 2 21 15402 2

*Stimulate creature, play a sound, and sway (lamp off)
	doif pose = 0
		stim writ from 97 1
		sndc "c1d7"
		anim [0 1 0 2 0]
*Stimulate creature, play a sound, and sway (lamp on)
	elif pose = 3
		stim writ from 97 1
		sndc "c1d7"
		anim [3 4 5 6 5 3]
	endi
*End script
endm

Activate 3[edit]

*SCRIPT 3: Hit
scrp 2 21 15402 3

*Stimulate creature, play a sound, and sway (lamp off)
	doif pose = 0
		stim writ from 97 1
		sndc "c1d7"
		anim [0 1 0 2 0]
*Stimulate creature, play a sound, and sway (lamp on)
	elif pose = 3
		stim writ from 97 1
		sndc "c1d7"
		anim [3 4 5 6 5 3]
	endi
*End script
endm

Remover[edit]

*** REMOVE SCRIPT
rscr

*Find all instances of the lanterns
enum 2 21 15402

*Remove the lanterns from the game
	kill targ

*Move on to next thing to remove
next

*Removes all the lantern's scripts
scrx 2 21 15402 1
scrx 2 21 15402 2
scrx 2 21 15402 3

Notes[edit]

Code[edit]

**CAOS2PRAY
*# Pray-File "C1CarpLanterns.agents"
*# C3-Name "C1 Carp Lanterns C3"
*# DS-Name "C1 Carp Lanterns DS"
*# attach C1CarpLanterns.c16
*# attach c1d7.wav
*# attach c1c4.wav
*# attach C1CarpLanterns.catalogue
*# desc = "Cute lanterns based on background graphics from C1 that emit light when activated and can be played with by creatures. Shift click to flip it! Made for the CCSF 2021. Sprites by Jesseth and code by CosmicSynthetics."
*# Agent Animation File = "C1CarpLanterns.c16"
*# Agent Animation String = "0"
*# Agent Sprite First Image = 0
*# Agent Animation Gallery = "C1CarpLanterns"
*# Web URL = "https://tumblr.cosmicsynthetics.com/"
*# Web Label = "CosmicSynthetics on Tumblr"

*TEMP SPECIES #: 3333
*FINAL SPECIES #: 15402

*ANIMATION NOTES:
*0=off stationary
*1=off sway left
*2=off sway right
*3=on stationary
*4=on sway left
*5=on sway middle
*6=on sway right

*SOUND NOTES:
*c1d7.wav=sway
*c1c4.wav=click

*NOTE: Shift click to flip the lantern!

*** MAKE TOY (C1 Carp Lanterns)
inst
new: simp 2 21 15402 "C1CarpLanterns" 7 0 800

* Creature-to-agent Permissions: 1 push, 2 pull, 8 hit
bhvr 11
* Agent Properties: 2 Mouseable, 4 Activateable
attr 6
* Acceleration - none
accg 0
* Permeability - can be set anywhere
perm 100
* Friction - never slides
fric 100
* Elasticity - none
elas 0

*PLACE AGENT AT AGENT INJECTOR (C3 and DS - Default for this template)
doif gnam = "Creatures 3"
	doif tmvt 5702 3624 eq 1
		mvto 5702 3624
	else
		mvsf 5702 3624
	endi
elif gnam = "Docking Station"
	doif tmvt 6073 9174 eq 1
		mvto 6073 9174
	else
		mvsf 6073 9174
	endi
endi

**SCRIPTS: C1 Carp Lanterns
*SCRIPT 1: Activate 1 (Push)
scrp 2 21 15402 1

*If pushed by the hand...
*... while holding down shift...
	doif from eq pntr
		doif keyd 16 = 1
			doif mira = 0
				mira 1
			else
				mira 0
			endi
*...Otherwise, if just a normal click...
		else
*Check if the lamp is off and turn it on
			doif pose = 0
				sndc "c1c4"
				pose 3
				emit 1 0.8
*If the lamp is already on, turn it off
			elif pose = 3
				sndc "c1c4"
				pose 0
				emit 1 0
*End do-if-else sequence
			endi
		endi

*If not pushed by the hand...
	else

*Stimulate creature, play a sound, and sway (lamp off)
		doif pose = 0
			stim writ from 97 1
			sndc "c1d7"
			anim [0 1 0 2 0]
*Stimulate creature, play a sound, and sway (lamp on)
		elif pose = 3
			stim writ from 97 1
			sndc "c1d7"
			anim [3 4 5 6 5 3]
		endi

*End do-if-else sequence
	endi
*End script
endm

*SCRIPT 2: Activate 2 (Pull)
scrp 2 21 15402 2

*Stimulate creature, play a sound, and sway (lamp off)
	doif pose = 0
		stim writ from 97 1
		sndc "c1d7"
		anim [0 1 0 2 0]
*Stimulate creature, play a sound, and sway (lamp on)
	elif pose = 3
		stim writ from 97 1
		sndc "c1d7"
		anim [3 4 5 6 5 3]
	endi
*End script
endm


*SCRIPT 3: Hit
scrp 2 21 15402 3

*Stimulate creature, play a sound, and sway (lamp off)
	doif pose = 0
		stim writ from 97 1
		sndc "c1d7"
		anim [0 1 0 2 0]
*Stimulate creature, play a sound, and sway (lamp on)
	elif pose = 3
		stim writ from 97 1
		sndc "c1d7"
		anim [3 4 5 6 5 3]
	endi
*End script
endm

*** REMOVE SCRIPT
rscr

*Find all instances of the lanterns
enum 2 21 15402

*Remove the lanterns from the game
	kill targ

*Move on to next thing to remove
next

*Removes all the lantern's scripts
scrx 2 21 15402 1
scrx 2 21 15402 2
scrx 2 21 15402 3