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

NEGV

From Creatures Wiki
Jump to navigation Jump to search

NEGV is a CAOS command for arithmetic.

Usage[edit]

Syntax: NEGV var (variable)

Changes the sign on the variable, so var = - var. var must be int or float.

If you want to make a variable negative, use ABSV first.

Examples[edit]

This is equivalent to NEGV va00.

SETV va01 0
SUBV va01 va00
SETV va00 va01

In the DS/C3 files, it is often used to flip the variable that keeps track of some binary state (direction left/direction right, inventory panel pulled out/inventory panel put away, etc), such as this turning code for the stingers:

** Changing direction? This code turns em ;-)
doif velx > -3 and ov10 = 1 and ov80 = -1
	frat 2
	anim [16 17 18 19 20 21 22 23 24]
	over
	frat 1
	anim [8 9 10 11 12 13 14 15 255]
	negv ov80
	setv ov83 -1
elif velx < 3 and ov10 = -1 and ov80 = 1
	frat 2
	anim [24 23 22 21 20 19 18 17 16]
	over
	frat 1
	anim [0 1 2 3 4 5 6 7 255]
	negv ov80
	setv ov83 1
endi

See also[edit]