**Versioning
*$Id: dev\040tool.cos,v 1.6 2001/01/17 09:29:15 mashton Exp $


new: simp 1 1 121 "blnk" 1 0 0
imsk 1
mvto 0 0
**OV00 is whether XY tool is out or not
*0=no, 1=yes
**OV01 is whether room tool is out
*0=no, 1=yes
**OV02 is whether classifier tool is out
*0=no, 1=yes

**1 1 18 = room tool 
**1 1 59 = XY tool 
**1 1 143 = classifer tool 

*R=room tool
*X=XY tool
*T=taxonomy tool
*F=food


scrp 1 1 121 73
	inst
	doif keyd 17 eq 1 and keyd 16 eq 1
***XY position tool
		doif _p1_ eq 'X'
*			kill the room tool if it exists
			doif ov01 eq 1
				rtar 1 1 18
				doif targ ne null
					kill targ
				endi
				targ ownr
				setv ov01 0
			endi
*			kill the classifier tool if it exists
			doif ov02 eq 1
				rtar 1 1 143
				doif targ ne null
					kill targ
				endi
				targ ownr
				setv ov02 0
			endi
*		create the XY tool if it doesn't exist			
			doif ov00 eq 0
				new: comp 1 1 59 "blank" 1 0 9000
				attr 32
				frel pntr
				pat: fixd 1 "blank" 0 0 0 0 "whiteontransparentchars"
				flto 30 30
				tick 1
				targ ownr
				setv ov00 1
			else
*			otherwise put it away if it does exist
				rtar 1 1 59
				doif targ ne null
					kill targ
				endi
				targ ownr
				setv ov00 0
			endi
***room ID tool
		elif _p1_ eq 'R'
*			kill the XY tool if it exists
			doif ov00 eq 1
				rtar 1 1 59
				doif targ ne null
					kill targ
				endi
				targ ownr
				setv ov00 0
			endi
*			kill the classifier tool if it exists
			doif ov02 eq 1
				rtar 1 1 143
				doif targ ne null
					kill targ
				endi
				targ ownr
				setv ov02 0
			endi
*		create the room tool if it doesn't exist			
			doif ov01 eq 0
				new: comp 1 1 18 "blank" 1 0 9000
				attr 32
				frel pntr
				pat: fixd 1 "blank" 0 0 0 0 "whiteontransparentchars"
				flto 30 30
				tick 1
				targ ownr
				setv ov01 1
			else
*			otherwise put it away if it does exist
				rtar 1 1 18
				doif targ ne null
					kill targ
				endi
				targ ownr
				setv ov01 0
			endi
		elif _p1_ eq 'T'
*			kill the XY tool if it exists
			doif ov00 eq 1
				rtar 1 1 59
				doif targ ne null
					kill targ
				endi
				targ ownr
				setv ov00 0
			endi
*			kill the room tool if it exists
			doif ov01 eq 1
				rtar 1 1 18
				doif targ ne null
					kill targ
				endi
				targ ownr
				setv ov01 0
			endi
*		create the classifier tool if it doesn't exist
			doif ov02 eq 0
				new: comp 1 1 143 "blank" 1 0 9000
				attr 32
				frel pntr
				pat: fixd 1 "blank" 0 0 0 0 "whiteontransparentchars"
				flto 30 30
				tick 1
				targ ownr
				setv ov02 1
			else
*				otherwise put it away if it does exist
				rtar 1 1 143
				doif targ ne null
					kill targ
				endi
				targ ownr
				setv ov02 0
			endi
		elif _p1_ eq 'E'
			setv va00 mopx
			setv va01 mopy
			reps 10
*		produce food
*			carrot
				new: simp 2 11 9 "carr" 0 0 563
				attr 194
				bhvr 48
				perm 64
				accg 1
				elas 20
				fric 99
				pose 6
				mvsf va00 va01
				emit 8 .5
				tick 1000
				setv va09 rand 0 1
				doif va09 = 0
					sets name "direction" "left"
				elif va09 = 1
					sets name "direction" "right"
				endi
				velo rand -5 5 rand -5 9
*			nut
				new: simp 2 3 17 "justanut pod" 9 18 51
				attr 194
				perm 64
				bhvr 48
				pose 1
				accg 3
				aero 5
				fric 99
				elas 20
				mvsf va00 va01
				emit 7 .5
				tick 200
				velo rand -5 5 rand -5 9
*			lemon
				new: simp 2 8 7 "ds lemon pod" 2 30 355
				attr 194
				bhvr 48
				accg 2
				perm 64
				fric 100
				elas 30
				aero 2
				sets name "eaten" "no"
				mvsf va00 va01
** make it emit fruit smell
				emit 6 .5
				tick 1000
				velo rand -5 5 rand -5 9
			repe
		endi
	endi
endm
*****XY timer
scrp 1 1 59 9
	inst
	targ pntr
	setv va00 posl
	setv va01 post
	slow
	targ ownr
	sets va99 vtos va00
	adds va99 " "
	adds va99 vtos va01

	part 1
	ptxt va99
endm
******Room ID timer
scrp 1 1 18 9
	inst
	targ pntr
	setv va00 posl
	setv va01 post
	slow
	targ ownr
	setv va99 grap va00 va01

	part 1
	ptxt vtos va99
endm
*********classifer tool timer
scrp 1 1 143 9
	inst
	targ hots
	doif targ ne null
		sets va00 vtos fmly
		sets va01 vtos gnus
		sets va02 vtos spcs
		sets va99 " "

		adds va00 va99
		adds va00 va01
		adds va00 va99
		adds va00 va02
	else
		sets va00 " "
	endi
	targ ownr
	part 1
	ptxt va00
endm


rscr
enum 1 1 59
	kill targ
next
enum 1 1 121
	kill targ
next
enum 1 1 18
	kill targ
next
enum 1 1 143
	kill targ
next