User Tools

Site Tools


crpl:overview

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
crpl:overview [2018/06/15 14:03] – added alteranite crpl.xml autocomplete file with hints kajacxcrpl:overview [2023/10/18 15:50] (current) – adding notepad disclaimer Bob
Line 1: Line 1:
- 
-<html><!--Comments visible to editors only can be placed in HTML comments --></html> 
 <-[[cw3:creeper_world_3|CW3 Home]]<- [[crpl:start|CRPL Home]]\\ <-[[cw3:creeper_world_3|CW3 Home]]<- [[crpl:start|CRPL Home]]\\
  
  
-===== CRPL - The Language ===== +====== CRPL - The Language ====== 
-CRPL (**<color blue>C</color>**reeper **<color blue>R</color>**everse **<color blue>P</color>**olish **<color blue>L</color>**anguage) is a stack-based, Reverse Polish Notation language. There, now that we've said it, what does it mean?+CRPL (**<color orange>C</color>**reeper **<color orange>R</color>**everse **<color orange>P</color>**olish **<color orange>L</color>**anguage) is a stack-based, Reverse Polish Notation language. There, now that we've said it, what does it mean?
  
-CRPL programming is similar to programming a HP calculator or Forth language programming. If this is not something you have done, read on for a brief introduction to CRPL and stack-based programming. <note>For a more detailed CRPL explanation, see the [[crpl:crpltutorial|Tutorial]].</note>+CRPL programming is similar to programming a HP calculator or Forth language programming. If this is not something you have done, read on for a brief introduction to CRPL and stack-based programming. <WRAP info>For a more detailed CRPL explanation, see the [[crpl:crpltutorial|Tutorial]].</WRAP>
  
 Each CRPL instruction (term) uses one or more arguments that are on a "stack". The most recent argument on the stack will be used first. This is called LIFO (**L**ast **I**n, **F**irst **O**ut). In return, the instruction may also place new arguments on the stack as part of its output. These new arguments are first in line to be consumed by the next instruction to be executed. Each CRPL instruction (term) uses one or more arguments that are on a "stack". The most recent argument on the stack will be used first. This is called LIFO (**L**ast **I**n, **F**irst **O**ut). In return, the instruction may also place new arguments on the stack as part of its output. These new arguments are first in line to be consumed by the next instruction to be executed.
Line 22: Line 20:
 <code>2 9</code> <code>2 9</code>
  
-<note> +<WRAP info>You can find more commands and detailed explanations of them in the [[crpl:crplreference|CRPL Reference]]!</WRAP>
-You can find more commands and detailed explanations of them in the [[crpl:crplreference|CRPL Reference]]! +
-</note>+
  
-==== Comments ====+===== Comments =====
  
 Adding comments makes code easier to understand, and sometimes helps the programmer or another reader to grasp complex pieces of logic. Also, after some time interval, it refreshes one's memory about exactly what a certain piece of code was intended to do. Adding comments makes code easier to understand, and sometimes helps the programmer or another reader to grasp complex pieces of logic. Also, after some time interval, it refreshes one's memory about exactly what a certain piece of code was intended to do.
Line 40: Line 36:
   2 4 5  add               # adds 4 and 5 to get 9</code>   2 4 5  add               # adds 4 and 5 to get 9</code>
  
-==== Stack Notation ====+===== Stack Notation =====
  
 Every CRPL operand takes zero or more arguments from a "stack", pushes zero or more operands onto the "stack, or does both. In order to diagram the number of arguments consumed or produced, the following notation is included in every description following: Every CRPL operand takes zero or more arguments from a "stack", pushes zero or more operands onto the "stack, or does both. In order to diagram the number of arguments consumed or produced, the following notation is included in every description following:
Line 66: Line 62:
 |< 80% 15% >| |< 80% 15% >|
 |b |**Boolean** ; nominally a 1 or a zero, representing True or False| |b |**Boolean** ; nominally a 1 or a zero, representing True or False|
-|i |**Integer** ; an integer. The CRPL run-time will, if possible, convert the argumant to an integer.|+|i |**Integer** ; an integer. The CRPL run-time will, if possible, convert the argument to an integer.|
 |n |**Term** ; a generic argument. Any term that will be accepted by the instruction. If possible, the CRPL run-time will attempt conversion between types.| |n |**Term** ; a generic argument. Any term that will be accepted by the instruction. If possible, the CRPL run-time will attempt conversion between types.|
 |f |**Float** ; a floating point value. If possible, the CRPL run-time will attempt conversion between types.| |f |**Float** ; a floating point value. If possible, the CRPL run-time will attempt conversion between types.|
Line 73: Line 69:
 |s |**String** ; a string of one or more text characters. If possible, numeric values will be converted at run-time.| |s |**String** ; a string of one or more text characters. If possible, numeric values will be converted at run-time.|
  
-==== Warp Notation ====+===== Warp Notation =====
  
 An extra and optional operator to CRPL allows for a reversed order that you write some things in CRPL.  It doesn't change a thing about the stack, or how CRPL works.  It only gives you a syntax alternative that can make things easier to read in some cases. An extra and optional operator to CRPL allows for a reversed order that you write some things in CRPL.  It doesn't change a thing about the stack, or how CRPL works.  It only gives you a syntax alternative that can make things easier to read in some cases.
Line 146: Line 142:
 </code> </code>
  
-==== Typographical conventions ====+===== Typographical conventions =====
 **Note:** FIXME This has not yet been implemented. We intend to, but until then the following is merely a placeholder. **Note:** FIXME This has not yet been implemented. We intend to, but until then the following is merely a placeholder.
  
Line 156: Line 152:
 |User         |Refers text that should be replaces with user-supplied values.| |User         |Refers text that should be replaces with user-supplied values.|
  
-==== Creating CRPL Scripts ====+===== Creating CRPL Scripts =====
  
-Any text editor can be used to edit CRPL files. However, syntax highlight and auto completion support files are provided for the freely available Notepad++ editorNotepad++ can be obtained from here: +Any text editor can be used to edit CRPL files. However, syntax highlight and auto completion support files are provided for several available editors.
-[[http://notepad-plus-plus.org/]]+
  
-  * Once Notepad++ is installed you can add **syntax hightlight** for the CRPL langage by downloading this file [[crpl:crpl-syntax|crpl-syntax.xml]]+<WRAP info>See how others created their maps! You can extract the CRPL scripts and custom images from any CW3 game file. The guide to [[examine map resources]] will show you how to retrieve these resources from other maps.</WRAP> 
 + 
 +==== Notepad++ ==== 
 + 
 +Notepad++ can be obtained from here: [[https://notepad-plus-plus.org/]] 
 +<note>Make sure you download only from the official Notepad++ website to avoid malware. https://notepad-plus-plus.org/</note> 
 +  * Once Notepad++ is installed you can add **syntax highlight** for the CRPL language. Currently there are two sample thems, one for the "normal (llisth) theme and one for the "dark" (Deep Black) theme.  
 +      * Light theme: [[crpl:crpl-syntax|crpl-syntax.xml]] 
 +      * Deep Black theme: [[crpl:crpl-syntax-deep-black.xml]]    
 +  *  Download either (or both) of those files, then: 
     * Open Notepad++,  select Language from the menu bar, click "Define Your Language", then "Import".     * Open Notepad++,  select Language from the menu bar, click "Define Your Language", then "Import".
 +
 +
   *You can add **keyword auto completion** to Notepad++ by download this file [[CRPL.xml]]   *You can add **keyword auto completion** to Notepad++ by download this file [[CRPL.xml]]
-    * To install into Notepad++ you need to copy CRPL.xml to your Notepad++ install directory\plugins\APIs directory. Then, restart Notepad++. Next, go to the Settings/Preferences menu in Notepad++. Click the "Backup/Auto-Completion" tab. Check the "Enable auto-completion on each input" checkbox, and make sure the "Function completion" radio button is selected. +    * To install into Notepad++ you need to copy CRPL.xml to the ''autoCompletion'' subdirectory of the Notepad++ install folder. (In older versions, Notepad++ v7.6.1 and earlier, you had to put the file in the ''plugins\APIs'' subdirectory of the intstall folder.Then, restart Notepad++. Next, go to the Settings/Preferences menu in Notepad++. Click the "Backup/Auto-Completion" tab. Check the "Enable auto-completion on each input" checkbox, and make sure the "Function completion" radio button is selected. 
-  * Alternatively, download this file [[https://drive.google.com/open?id=18U2nQ32AajOZESGKERYBtrNlS1YHjlmD|crpl.xml]] instead, which works for **keyword auto completion** as well, but also contains the input, output, and description of each command. +  * Alternatively, download this file [[https://drive.google.com/open?id=18U2nQ32AajOZESGKERYBtrNlS1YHjlmD|crpl.xml]] instead, which works for **keyword auto completion** as well, but also contains the input, output, and the description of each command. 
-    * Use the same process to install as above. To see the description of the command, type opening bracket "(" after the command you want to see help for. Then press Esc to dismiss the help, or click elsewhere in the code. Disclaimer: these hints were autogenerated from the wiki, so the formatting might not be best.+    * Use the same process to install as above. To see the description of the command, type the opening bracket "(" after the command you want to see help for. Then press Esc to dismiss the help, or click elsewhere in the code. Disclaimer: these hints were autogenerated from the wiki, so the formatting might not be the best
 +  * You can also create a keyboard shortcut to open the wiki of the current command you have your cursor on. 
 +    * In Notepad++, go into "Run -> Run", then type ''https://knucklecracker.com/wiki/doku.php?id=crpl:docs:$(CURRENT_WORD)'' into the input field and click "Save". After that, select a name (for example "Open CRPL Wiki") and a keyboard shortcut (for example Ctrl+Shift+H) and click OK, then just close the Run... dialog. After that, you should see your shortcut in the "Run" menu, and you can use it to open the current command (the one that your input cursor is currently on) in the wiki. 
 + 
 +==== Visual Studio Code ==== 
 + 
 +Visual Studio Code can be obtained from here: [[https://code.visualstudio.com/]]. 
 + 
 +Features: 
 +  * Syntax Highlighting 
 +  * Looking stuff up on the wiki 
 +  * Syntactical diagnostics  (making sure block delimiters match, $ parameters are at the start of the file, etc) 
 +  * Implements several VSCode features for named entities (variables/functions): go-to-definition, rename, and find references 
 +  * Checks to make sure variables are used (written to at least once and read from at least once) 
 + 
 +Instructions:  
 + 
 +  * Download this *.vsix file: [[https://github.com/stellHex/crpl-vscode/releases/download/v0.3.0-beta/crpl-0.3.0.vsix]] 
 +  * In Visual Studio Code, Go to View -> Extensions. 
 +  * In the menu that opens, expand the more options menu in top right and press Install from VSIX, then point to the downloaded file. 
 +  * All files with the *.crpl extension will now automatically utilize the features above. 
 + 
 +==== Sublime Text ==== 
 + 
 +Sublime Text can be obtained from here: [[https://www.sublimetext.com/3]]. 
 + 
 +Features include syntax highlighting and auto completion. 
 + 
 +Instructions: 
 + 
 +  * In Sublime Text, go to Tools -> Command Palette. 
 +  * Type "Install Package Control" and hit Enter. 
 +  * Open the Command Palette again and type "Package Control: Install Package"
 +  * In the menu that opens, type "CRPL", then select the Creeper Reverse Polish Language package. 
 +  * All files with the *.crpl extension should now use this package. 
 + 
 +=====Translation Front-ends ===== 
 + 
 +  * Forum user [[https://knucklecracker.com/forums/index.php?action=profile;u=6122 | Arin112]] (Discord: Arin112#8343) wrote a C-lookalike front-end translator that will produce xRPL code as output. There is a [[https://knucklecracker.com/forums/index.php?topic=31849.msg179146#msg179146 | reference to the translator (MplLang) on the forum]].  The source code and examples are on [[https://github.com/Arin112/mplLang |  Github]]. 
 + 
 +  * Discord user Redcrafter#7494 wrote a transpiler that translates Javascript to xRPL code. The source code and examples are on [[https://github.com/Redcrafter/crplJs |  Github]]. 
 + 
 +Time permitting, this deserves a more complete treatment and probably a section of it's own
  
-<note>See how others created their maps! You can extract the CRPL scripts and custom images from any CW3 game file. The guide to [[examine map resources]] will show you how to retrieve these resources from other maps.</note> 
 \\ \\
 \\ \\
-FIXME / DELETEME  + 
 =====Syntax Highlighting in the Wiki =====   =====Syntax Highlighting in the Wiki =====  
     
 Dokuwiki uses [[http://qbnz.com/highlighter/|GeSHi]] syntax highlighting. Dokuwiki uses [[http://qbnz.com/highlighter/|GeSHi]] syntax highlighting.
 +
 +Code examples can be highlighted using the `4rpl` code tag eg:
 +
 +<code 4rpl>
 +# --Volcano-- 5/13/2020 12:58:29 PM
 +
 +$$POSX:154
 +$$POSZ:98
 +$$AMT:100
 +
 +if (GetGameUpdateCount 3600 % eq0)
 + true ->erupting
 +endif
 +
 +if (<-erupting)
 + @Erupt
 +endif
 +
 +if (<-orbsHaveErupted ! GetUnitCount("sniper") 21 gte &&)
 + 240 ->orbsErupting
 + true ->orbsHaveErupted
 +endif
 +
 +if (<-orbsErupting)
 + @OrbsErupt
 +endif
 +
 +:Erupt
 + if (<-eruptCount 60 % eq0)
 + do(2 -1)
 + do(2 -1)
 + AddCreeper(<-POSX I + <-POSZ J + <-AMT)
 + loop
 + loop
 + endif
 + <-eruptCount 1 + ->eruptCount
 + if (<-eruptCount 400 gte)
 + false ->erupting
 + 0 ->eruptCount
 + endif
 +
 +:OrbsErupt
 + V3(RandFloat 0.5 - 1 * 2 RandFloat 0.5 - 1 *) ->orbInitData{"velocity"}
 + CreateOrb(V3(154 randint(-1 2) + 15 98 randint(-1 2) +) <-orbInitData)
 + <-orbsErupting 1 - ->orbsErupting
 +
 +:once
 + Table( "payload" 500 
 + "bounce" true 
 + "creeperdamps" false 
 + "destroywhenstill" false 
 + "destroywhendrytime" 60 
 + "releaseondestroy" false) ->orbInitData
 +</code>
 +
crpl/overview.1529085816.txt.gz · Last modified: 2018/06/15 14:03 by kajacx