User Tools

Site Tools


pf:rpldocs:vars_and_functions
Vars and fucntions.txt
=CMD
=COMMAND $VARNAME:DEF_VAL
=DESC 
Defines an input variable. Input variables are created at script start and assigned either the default value, or a value specified in the editor. Input variables must start with a $ sign
=ENDDESC
=EX 
$enemy:1
$particleType:0

CreateParticle(CurrentCoords 0 0 <-particleType <-enemy)
=ENDEX
=ENDCMD

=CMD
=COMMAND ClearLocals
=DESC 
Clears all local variables. Local variables persist across script invocations.
=ENDDESC
=EX 
1 ->temp
trace(<-temp) #prints out 1 to the tracelog
ClearLocals
trace(<-temp) #prints out 0 to the tracelog
=ENDEX
=ENDCMD

=CMD
=COMMAND --VARNAME
=DESC 
Deletes VARNAME from the heap. It is now unassigned.
=ENDDESC
=EX 
42 ->TheAnswer
trace(<-TheAnswer) #prints out 42
--TheAnswer
trace(<-TheAnswer) #prints out 0
=ENDEX
=ENDCMD

=CMD
=COMMAND <-VARNAME value
=DESC 
Reads the contents of the local variable VARNAME and pushes it to the stack. If VARNAME does not exist, 0 is pushed to the stack.
=ENDDESC
=EX 
#Increment a variable named 'i' by 1 and store the result back in 'i' 
<-i add(1) ->i
=ENDEX
=ENDCMD

=CMD
=COMMAND ->VARNAME (value)
=DESC
value ARG1: The value to pop from the stack and store in the heap at VARNAME.<p/> 
Pops an item from the stack and stores it in the local variable named VARNAME.
=ENDDESC
=EX 
# Store coordinate points in local variables. 
# The points are defined once and assigned to local variables. 
once 
	10 ->x1 
	20 ->y1 
	40 ->x2 
	50 ->y2 	
endonce
=ENDEX
=ENDCMD

=CMD
=COMMAND -?VARNAME bool
=DESC 
Checks to see if VARNAME exists (has been assigned). If so, 1 is pushed to the stack else 0.
=ENDDESC
=EX 
if (not(-?unit))
	CreateUnit(10 20 "AmpGem") ->unit
endif
=ENDEX
=ENDCMD

=CMD
=COMMAND <-! (string) value
=DESC 
string ARG1: The string name of the heap variable to read.<p/>
Reads the contents of the local variable and pushes it to the stack. This allows dynamic reading of variables.
=ENDDESC
=EX 
42 ->someVar
trace( <-!("someVar") )
=ENDEX
=ENDCMD

=CMD
=COMMAND ->! (value string)
=DESC 
value ARG1: The value to store.<br/>
string ARG2: The string name of the heap variable to write to.<p/>
Pops a name of a variable and an item from the stack and stores the item in the variable.
=ENDDESC
=EX 
->!(42 "someVar")
trace(<-someVar)
=ENDEX
=ENDCMD

=CMD
=COMMAND -?! (string) bool
=DESC 
string ARG1: The string name of the heap variable to check.<p/>
Takes a string from the stack and uses it as a variable name. Checks to see if the variable exists (has been assigned). If so, 1 is pushed to the stack else 0.
=ENDDESC
=EX 
42 ->somevar
trace(-?!("somevar"))
=ENDEX
=ENDCMD

=CMD
=COMMAND --?
=DESC 
string ARG1: The string name of the heap variable to delete.<p/>
Finds a local variable by string name and deletes it.
=ENDDESC
=EX 
42 ->theAnswer
--?("theAnswer")
trace(<-theAnswer)
=ENDEX
=ENDCMD

=CMD
=COMMAND @FUNC_NAME
=DESC 
Invokes a function. Execution passes to the function that is named and returns to the statement after the call when the function is complete. Arguments can be passed to and received from functions via the stack.
=ENDDESC
=EX 
if (@GetAnswer(true) eq(42))
	trace("The Answer")
endif

:GetAnswer
	->really
	if (really)
		42
	else
		0
	endif	
=ENDEX
=ENDCMD

=CMD
=COMMAND :FUNC_NAME
=DESC 
Defines the beginning of a function block. Choose a unique name for the function. Statements after a function block only execute if called by invoking the function with an '@FUNC_NAME' call. The end of a function block is either the end of the script or the beginning of another function, whichever comes first.
=ENDDESC
=EX 
if (@GetAnswer(true) eq(42))
	trace("The Answer")
endif

:GetAnswer
	->really
	if (really)
		42
	else
		0
	endif	
=ENDEX
=ENDCMD

=CMD
=COMMAND #
=DESC 
Turns the rest of the line into a comment. Comments are not code: They do nothing.
=ENDDESC
=EX 
#This is a comment, it does nothing.
=ENDEX
=ENDCMD
pf/rpldocs/vars_and_functions.txt · Last modified: 2016/10/16 17:34 by Karsten75