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

NAMN

From Creatures Wiki
Jump to navigation Jump to search

NAMN is a CAOS command which allows the user to loop over all named local variables of the target agent.

Usage[edit]

Syntax: NAMN PREVIOUS (variable)

This returns the name of the NAME variable of the agent. PREVIOUS is the name of the previous variable, to get the first NAME variable set it to "". After having looped over all the NAME variables, it will return an empty string "".

Examples[edit]

If you target an agent, this piece of code will return the name and value of the named variables.

sets va00 ""
loop
	namn va00
	outs va00
	doif va00 ne ""
		outs " - "
		outs name va00
		outs " \n"
	endi
untl va00 eq ""

Bugs[edit]

If you attempt to check the value of a NAME variable named an empty string (""), the NAMN command will not work anymore on this agent. Examples:

*Do NOT use this, as it disables the use of NAMN on this agent
sets name "" "abc"
*Do NOT use this, as it disables the use of NAMN on this agent
doif name "" eq 0
endi
*Do NOT use this, as it disables the use of NAMN on this agent
outv type name ""

So if you want to enable the use NAMN on the target agent, make sure to check that the name of the returned NAME variable isn't an empty string ("") before trying to manipulate it. Do not set the NAME "" variable either.

See also[edit]

External links[edit]