User Tools

Site Tools


crpl:docs:setscriptvar

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:docs:setscriptvar [2013/01/14 14:59] virgilwcrpl:docs:setscriptvar [2020/05/29 10:18] (current) – made example code more legible/consistent Sanian
Line 1: Line 1:
 +~~DISCUSSION:off~~ 
 +<- [[crpl:crplreference| CRPL reference]] <- [[crpl:crplreference#script_commands|Script Commands]]
 =====  SetScriptVar  ===== =====  SetScriptVar  =====
  
Line 7: Line 8:
  
 === Description === === Description ===
-Sets the named variable on the specified unit script to a value.+Sets the named variable on the specified unit script to a value.  
 + 
 +Can also set the variables of built-in units like spore towers and emitters.  
 +You can check the names of built-in variable for units on the [[crpl:docs:getscriptvar|GetScriptVar]] page or at the bottom of this page. 
 +<note>**Payload** and **Amt** values for Emitters, Inhibitors, Spores and Runners are internal integers, not the floats you would use in the map editor dialog. For example, 1.5 Creeper in-game should be set as 1500000. 
 + 
 +**Interval** values for Emitters, Inhibitors, Spore Towers, Runner Nests should be set as the number of frames, rather than seconds. For example, 2 second interval as shown in-game should be set as 60 frames. 
 + 
 +This is what setting an Emitter with 32.5 power and 2.5 second interval would look like: 
 + 
 +<code> 
 +SetScriptVar(<-unit 0 "productionAmt" 32.5 1000000 mul) 
 +SetScriptVar(<-unit 0 "productionInterval" 2.5 30 mul) 
 +</code></note> 
 + 
 +<note>The **"startTime"** variable of Emitters and Spore Towers works based off of the start of the game, not the time of unit creation. 
 + 
 +If you're procedurally generating a unit, and you want to give it a delay, you need to add the current time elapsed to it. 
 + 
 +This is what setting a delay of 10 seconds would look like: 
 +<code> 
 +SetScriptVar(<-unit 0 "startTime" 300 GetGameTimeFrames add) 
 +</code></note> 
 + 
 + 
  
 === Examples === === Examples ===
 +
 <code> <code>
 @CreateBullet @CreateBullet
  
 :CreateBullet :CreateBullet
- "CRPLCore" CurrentX CurrentY CreateUnit ->unit + CreateUnit("CRPLCore" CurrentCoords) ->unit 
- <-unit "CRBullet.crpl" AddScriptToUnit + AddScriptToUnit(<-unit "CRBullet.crpl") 
- <-unit "CRBullet.crpl" "targetX" <-targetX SetScriptVar + SetScriptVar(<-unit "CRBullet.crpl" "targetX" <-targetX) 
- <-unit "CRBullet.crpl" "targetY" <-targetY SetScriptVar + SetScriptVar(<-unit "CRBullet.crpl" "targetY" <-targetY) 
- <-unit "CRBullet.crpl" "payload" <-payload SetScriptVar + SetScriptVar(<-unit "CRBullet.crpl" "payload" <-payload) 
- <-unit "main" "Custom2" SetImage + SetImage(<-unit "main" "Custom2") 
- <-unit "main" -0.01 SetImagePositionZ + SetImagePositionZ(<-unit "main" -0.01) 
- <-unit "main" self "barrel" GetImageRotation SetImageRotation  + SetImageRotation(<-unit "main" self "barrel" GetImageRotation) 
-</code> +</code> 
 + 
 +<code>CreateUnit("SPORETOWER" 0 0) ->sporeTowerUID 
 +SetScriptVar(<-sporeTowerUID 0 "startTime" 3600) # The number of frames before the tower commences firing. 
 +SetScriptVar(<-sporeTowerUID 0 "waveInterval" 3600) # The number of frames between each volley of spores. 
 +SetScriptVar(<-sporeTowerUID 0 "waveCount" 1) 
 +SetScriptVar(<-sporeTowerUID 0 "sporePayload" 25000000) 
 +</code> 
 + 
 +<code>CreateUnit("EMITTER" 31 8) ->unit 
 +SetScriptVar(<-unit 0 "productionInterval" 45) 
 +SetScriptVar(<-unit 0 "productionAmt" 800000) 
 +SetScriptVar(<-unit 0 "startTime" 45)</code> 
 + 
 +<code>CreateUnit("RUNNERNEST" <-spawnX <-spawnY) ->uid  
 +SetScriptVar(<-uid 0 "moveSpeed" 1) 
 +SetScriptVar(<-uid 0 "spawnInterval" 150)  
 +SetScriptVar(<-uid 0 "maxPopulation" 5) 
 +SetScriptVar(<-uid 0 "runnerMaxHealth" 5)  
 +SetScriptVar(<-uid 0 "creeperPayload" 75000000)</code> 
 + 
 +<code># Added in 1.66 
 +CreateUnit("RESOURCEPACK" <-spawnX <-spawnY) ->uid  
 +SetScriptVar(<-uid 0 "resourceType" "ORE") # Can be ORE, ENERGY or AETHER 
 +SetScriptVar(<-uid 0 "amt" 150) </code> 
 + 
 +=== List of vars === 
 + 
 +Emitter 
 +  Script: 0 
 +   
 +  STARTTIME 
 +    Number of frames before emitter starts production. 
 +  FINISHTIME 
 +    Number of frames before emitter halts production. Defaults to 2147483647 (the maximum signed 32 bit integer). 
 +  PRODUCTIONINTERVAL 
 +    Number of frames between each creeper production. 
 +  PRODUCTIONAMT 
 +    The amount of creeper produced per production, multiplied by 1000000. 
 + 
 +SporeTower 
 +  Script: 0 
 +   
 +  STARTTIME 
 +    The number of frames before the tower starts producing spores. 
 +  WAVEINTERVAL 
 +    The number of frames between each wave of spores. 
 +  WAVECOUNT 
 +    The number of spores in each wave. 
 +  SPOREPAYLOAD 
 +    The amount of creeper that each spores dumps on the map when it lands, multiplied by 1000000. 
 + 
 +AETower 
 +  Script: 0 
 +   
 +  RANGE 
 +    The size of the exclusion zone. 
 + 
 +RunnerNest 
 +  Script: 0 
 +   
 +  SPAWNINTERVAL 
 +    The number of frames between the production of each runner 
 +  MAXPOPULATION 
 +    The maximum number of runners produced by this nest on the map at any given time. 
 +  MOVESPEED 
 +    The movement speed in pixels per second of each runner. 
 +  RUNNERMAXHEALTH 
 +    The maximum health and starting health of each runner. 
 +  CREEPERPAYLOAD 
 +    The amount of creeper that each runner dumps to the map when it dies or is killed, multiplied by 1000000. 
 + 
 +Inhibitor 
 +  Script: 0 
 +   
 +  STARTTIME 
 +    The number of frames before the inhibitor starts producing creeper. 
 +  PRODUCTIONINTERVAL 
 +    The number of frames between each production of creeper. 
 +  PRODUCTIONAMT 
 +    The amount of creeper produced. 
 +  RANGE 
 +    The range of the aerial exclusion zone. Set to 0 for none. 
 + 
 +ResourcePack 
 +  Script: 0 
 +   
 +  AMT 
 +    The starting amount that the pack carries. Must be less than MAXAMT. 
 +  MAXAMT 
 +    The maximum amount that the pack carries. 
 +  RESOURCETYPE 
 +    The type of resource that the pack carries. Either ENERGY, ORE or AETHER. 
 + 
 +Guppy Pad (added in 1.68) 
 +  Script: "" 
 +   
 +  MODE 
 +    The type of cargo that the guppy ferries. Either PACKET, ORE or AC. 
 + 
 +Artifact of Odin (AOO) 
 +  Script: 0 
 +   
 +  TYPE 
 +    The type of AoO. Either FREEZE, MASS or CONVERT. 
 +     
 +Tech Artifact (Added in 1.83)     
 +   Script:
 +    
 +   COUNT 
 +     The number of items the tech artifact should unlock.
crpl/docs/setscriptvar.1358193547.txt.gz · Last modified: 2014/10/01 15:02 (external edit)