This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
pf:prpldocs:vars_and_functions [2016/06/23 13:18] – created virgilw | pf:prpldocs:vars_and_functions [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
< | < | ||
- | | + | <script type=" |
+ | function selectText(containerid) { | ||
+ | if (document.selection) { | ||
+ | var range = document.body.createTextRange(); | ||
+ | range.moveToElementText(document.getElementById(containerid)); | ||
+ | range.select(); | ||
+ | } else if (window.getSelection) { | ||
+ | var range = document.createRange(); | ||
+ | range.selectNode(document.getElementById(containerid)); | ||
+ | window.getSelection().addRange(range); | ||
+ | } | ||
+ | } | ||
+ | </script> | ||
+ | <a href="#" | ||
+ | Save the contents to "Vars and Functions.txt" | ||
- | | + | <div id=" |
- | | + | </html> |
+ | < | ||
+ | =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: | ||
- | //Get a reference to the link on the page | + | CreateParticle(CurrentCoords 0 0 < |
- | // with an id of " | + | =ENDEX |
- | var a = document.getElementById(" | + | =ENDCMD |
- | //Set code to run when the link is clicked | + | =CMD |
- | // by assigning a function to " | + | =COMMAND ClearLocals |
- | a.onclick | + | =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(< | ||
+ | =ENDEX | ||
+ | =ENDCMD | ||
- | // Your code here... | + | =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 | ||
- | function downloadInnerHtml(filename, | + | =CMD |
- | var elHtml | + | =COMMAND -> |
- | var link = document.createElement(' | + | =DESC |
- | mimeType = mimeType || 'text/plain'; | + | value ARG1: The value to pop from the stack and store in the heap at VARNAME.<p/> |
- | link.setAttribute(' | + | Pops an item from the stack and stores it in the local variable named VARNAME. |
- | | + | =ENDDESC |
- | | + | =EX |
- | } | + | # Store coordinate points in local variables. |
- | var fileName = ' | + | # The points are defined once and assigned |
- | | + | once |
- | //If you don't want the link to actually | + | 10 -> |
- | // redirect the browser to another page, then | + | 20 -> |
- | // return false at the end of this block. | + | 40 -> |
- | // Note that this also prevents event bubbling, | + | 50 ->y2 |
- | // which is probably what we want here, but won' | + | endonce |
- | // always be the case. | + | =ENDEX |
- | | + | =ENDCMD |
- | } | + | |
- | } | + | |
- | </script> | + | =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 | ||
- | <a id=" | + | =CMD |
+ | =COMMAND ->! (value string) | ||
+ | =DESC | ||
+ | value ARG1: The value to store.<br/> | ||
+ | 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 | ||
- | <div id=" | + | =CMD |
+ | =COMMAND | ||
+ | =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 | ||
- | Phasellus ornare quis ipsum non scelerisque. In sollicitudin est placerat nibh porttitor pretium. Phasellus ac purus nulla. Phasellus in enim vel leo viverra sodales eget sit amet ante. Sed ultrices elementum nibh, tristique euismod nunc volutpat sit amet. Suspendisse potenti. Morbi feugiat diam tristique, euismod dui in, mattis diam. Vestibulum euismod commodo cursus. Proin posuere libero vitae purus blandit, in posuere erat malesuada. Donec ultrices vel velit in feugiat. Vestibulum suscipit erat urna, bibendum vestibulum dui varius sit amet.</p></ | + | =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 | ||
+ | |||
+ | : | ||
+ | -> | ||
+ | if (really) | ||
+ | 42 | ||
+ | else | ||
+ | 0 | ||
+ | endif | ||
+ | =ENDEX | ||
+ | =ENDCMD | ||
+ | |||
+ | =CMD | ||
+ | =COMMAND : | ||
+ | =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 | ||
+ | |||
+ | : | ||
+ | -> | ||
+ | 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 | ||
+ | |||
+ | </code> | ||
+ | <html></ |