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 [2014/10/01 15:02] – external edit 127.0.0.1crpl:docs:setscriptvar [2020/05/29 10:18] (current) – made example code more legible/consistent Sanian
Line 1: Line 1:
-~~DISCUSSION~~+~~DISCUSSION:off~~
 <- [[crpl:crplreference| CRPL reference]] <- [[crpl:crplreference#script_commands|Script Commands]] <- [[crpl:crplreference| CRPL reference]] <- [[crpl:crplreference#script_commands|Script Commands]]
 =====  SetScriptVar  ===== =====  SetScriptVar  =====
Line 12: Line 12:
 Can also set the variables of built-in units like spore towers and emitters.  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. 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 values for spores and emitters are internal integers, not the floats you would use +<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. 
-in the map editor dialog. There is room for 6 digits after the decimal. 1.in the dialog would + 
-be 1000000 on the internal intThe values in the sample below correlate to 25.0 for the spore +**Interval** values for Emitters, Inhibitors, Spore Towers, Runner Nests should be set as the number of frames, rather than secondsFor example, 2 second interval as shown in-game should be set as 60 frames
-payload and 0.8 for the emitter production amount.</note>+ 
 +This is what setting an Emitter with 32.5 power and 2.5 second interval would look like: 
 + 
 +<code> 
 +SetScriptVar(<-unit "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>
  
  
Line 26: Line 41:
  
 :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>
  
crpl/docs/setscriptvar.1412190170.txt.gz · Last modified: 2014/10/12 18:46 (external edit)