User Tools

Site Tools


crpl:crpltutorial:code_examples

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:crpltutorial:code_examples [2015/04/06 22:40] – Contributed 'GetClosestUnitToCoords' at the bottom. Telanircrpl:crpltutorial:code_examples [2022/01/11 03:00] (current) – old revision restored (2020/06/08 16:35) Karsten75
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]]
  
 ====== Code Examples ====== ====== Code Examples ======
 +
  
 Code examples contributed by map makers and coders alike. Feel free to submit your own - it will be much appreciated. Code examples contributed by map makers and coders alike. Feel free to submit your own - it will be much appreciated.
  
 You can also view the scripts in any map: make a copy of the map you want to inspect, rename the copy "save.cw3", create a new project, and then replace the project's "save.cw3" file. You can also view the scripts in any map: make a copy of the map you want to inspect, rename the copy "save.cw3", create a new project, and then replace the project's "save.cw3" file.
 +
 +<wrap hi>Telanir contributed an [[EasyCRPL|entire section on EasyCRPL]]. </wrap>
 ===== Manage Treasure Chests in Credits Mission ===== ===== Manage Treasure Chests in Credits Mission =====
  
Line 875: Line 877:
 #If all units are outside of the maxDistance or none found returns integer value '-1'. #If all units are outside of the maxDistance or none found returns integer value '-1'.
 :GetClosestUnitToCoords :GetClosestUnitToCoords
- ->gcu_mdist asfloat + asfloat ->gcu_mdist 
- ->gcu_y + asfloat ->gcu_y 
- ->gcu_x+ asfloat ->gcu_x
  StackSize ->gcu_szmin  StackSize ->gcu_szmin
  
Line 936: Line 938:
 #Simple convenience method. Takes a unit and returns the coordinates. #Simple convenience method. Takes a unit and returns the coordinates.
 #'CurrentCoords' and 'self @UnitCoords' are equivalent. #'CurrentCoords' and 'self @UnitCoords' are equivalent.
-#Notation: n1 - x+#Notation: n1 - x y
 #eg. <-myUnitID @UnitCoords ->unitX ->unitY #eg. <-myUnitID @UnitCoords ->unitX ->unitY
 :UnitCoords :UnitCoords
Line 962: Line 964:
 </code> </code>
 <sub>Contributed by Telanir</sub> <sub>Contributed by Telanir</sub>
 +
 +
 +===CRPL generating CRPL===
 +This CRPL will generate CRPL with custom program (if it is in the map scripts)
 +<code>
 +CreateUnit("CRPLCORE" CurrentX CurrentY) ->unit
 +AddScriptToUnit(<-unit "[Programname].crpl")
 +</code>
 +<sub> Stolen from Teknotiss(who took it from virgil), where pyramids make golems. I simply changed golem to unit. Added by cpaca, known as Karma's coming on map search </sub>
crpl/crpltutorial/code_examples.1428374440.txt.gz · Last modified: 2015/04/06 22:40 by Telanir