This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
pf:vars_and_functions [2016/06/23 13:09] – virgilw | pf:vars_and_functions [2016/06/23 16:49] (current) – removed virgilw | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | < | ||
- | =CMD | ||
- | =COMMAND $VARNAME: | ||
- | =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: | ||
- | CreateParticle(CurrentCoords 0 0 < | ||
- | =ENDEX | ||
- | =ENDCMD | ||
- | |||
- | =CMD | ||
- | =COMMAND ClearLocals | ||
- | =DESC | ||
- | Clears all local variables. Local variables persist across script invocations. | ||
- | =ENDDESC | ||
- | =EX | ||
- | 1 ->temp | ||
- | trace(< | ||
- | ClearLocals | ||
- | trace(< | ||
- | =ENDEX | ||
- | =ENDCMD | ||
- | |||
- | =CMD | ||
- | =COMMAND --VARNAME | ||
- | =DESC | ||
- | Deletes VARNAME from the heap. It is now unassigned. | ||
- | =ENDDESC | ||
- | =EX | ||
- | 42 -> | ||
- | trace(< | ||
- | --TheAnswer | ||
- | trace(< | ||
- | =ENDEX | ||
- | =ENDCMD | ||
- | |||
- | =CMD | ||
- | =COMMAND < | ||
- | =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 add(1) ->i | ||
- | =ENDEX | ||
- | =ENDCMD | ||
- | |||
- | =CMD | ||
- | =COMMAND -> | ||
- | =DESC | ||
- | value ARG1: The value to pop from the stack and store in the heap at VARNAME.< | ||
- | 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 -> | ||
- | 20 -> | ||
- | 40 -> | ||
- | 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(-? | ||
- | CreateUnit(10 20 " | ||
- | endif | ||
- | =ENDEX | ||
- | =ENDCMD | ||
- | |||
- | =CMD | ||
- | =COMMAND <-! (string) value | ||
- | =DESC | ||
- | string ARG1: The string name of the heap variable to read.< | ||
- | Reads the contents of the local variable and pushes it to the stack. This allows dynamic reading of variables. | ||
- | =ENDDESC | ||
- | =EX | ||
- | 42 -> | ||
- | trace( < | ||
- | =ENDEX | ||
- | =ENDCMD | ||
- | |||
- | =CMD | ||
- | =COMMAND ->! (value string) | ||
- | =DESC | ||
- | value ARG1: The value to store.< | ||
- | string ARG2: The string name of the heap variable to write to.< | ||
- | Pops a name of a variable and an item from the stack and stores the item in the variable. | ||
- | =ENDDESC | ||
- | =EX | ||
- | ->!(42 " | ||
- | trace(< | ||
- | =ENDEX | ||
- | =ENDCMD | ||
- | |||
- | =CMD | ||
- | =COMMAND -?! (string) bool | ||
- | =DESC | ||
- | string ARG1: The string name of the heap variable to check.< | ||
- | 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 -> | ||
- | trace(-? | ||
- | =ENDEX | ||
- | =ENDCMD | ||
- | |||
- | =CMD | ||
- | =COMMAND --? | ||
- | =DESC | ||
- | string ARG1: The string name of the heap variable to delete.< | ||
- | Finds a local variable by string name and deletes it. | ||
- | =ENDDESC | ||
- | =EX | ||
- | 42 -> | ||
- | --? | ||
- | trace(< | ||
- | =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(" | ||
- | endif | ||
- | |||
- | :GetAnswer | ||
- | -> | ||
- | 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 ' | ||
- | =ENDDESC | ||
- | =EX | ||
- | if (@GetAnswer(true) eq(42)) | ||
- | trace(" | ||
- | endif | ||
- | |||
- | :GetAnswer | ||
- | -> | ||
- | 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 | ||
- | |||
- | </ |