User Tools

Site Tools


crpl:crpltutorial:interactive:advancedemitter

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:interactive:advancedemitter [2014/10/01 15:02] – external edit 127.0.0.1crpl:crpltutorial:interactive:advancedemitter [2018/05/16 16:28] (current) – [Progressive output] CatMan33
Line 1: Line 1:
-~~DISCUSSION~~ 
 <-[[cw3:creeper_world_3|CW3 Home]] <-[[crpl:start|CRPL Home]] <-[[crpl:crpltutorial:interactive|Interacive tutorials]]\\ <-[[cw3:creeper_world_3|CW3 Home]] <-[[crpl:start|CRPL Home]] <-[[crpl:crpltutorial:interactive|Interacive tutorials]]\\
 ====== Creating a custom emitter ====== ====== Creating a custom emitter ======
Line 24: Line 23:
  
 We want the script to be very portable, so instead of coding the values into the script, we'll use input variables. These will be Amt, Delay, AmtIncrease, AmtMax, DeathMode and DeathAmt. We want the script to be very portable, so instead of coding the values into the script, we'll use input variables. These will be Amt, Delay, AmtIncrease, AmtMax, DeathMode and DeathAmt.
-<hidden><code>$Amt:10+<hidden><code prpl>$Amt:10
 $Delay:15 $Delay:15
 $AmtIncrease:0.1 $AmtIncrease:0.1
Line 30: Line 29:
 $DeathMode:1 $DeathMode:1
 $DeathAmt:"50"</code>Note that "DeathAmt" holds a string instead of a number, the game will convert these into integers at runtime when possible</hidden>\\ $DeathAmt:"50"</code>Note that "DeathAmt" holds a string instead of a number, the game will convert these into integers at runtime when possible</hidden>\\
-And as it is an emitter, simple code to make it emit creeper+And as it is an emitter, simple code to make it emit Creeper
-<code>CurrentCoords <-Amt SetCreeperNoLower+<code prpl># Emit the saved amount of Creeper at the specified coordinates, 
 +# but only emit so much so that the creeper level is at least as much as 'Amt', but no more 
 +CurrentCoords <-Amt SetCreeperNoLower 
 +# Wait the specified amount of ticks before doing anything
 <-Delay Delay</code> <-Delay Delay</code>
  
Line 37: Line 39:
  
 You probably need a good popup text to make sure people think it's a normal emitter. Simply add these 2 lines and you're done. You probably need a good popup text to make sure people think it's a normal emitter. Simply add these 2 lines and you're done.
-<code>"Amt: " <-Amt concat "+<code prpl>"Amt: " <-Amt concat "
 " concat "Interval: " <-Delay 30.00 div 2 Round concat concat SetPopuptext</code> " concat "Interval: " <-Delay 30.00 div 2 Round concat concat SetPopuptext</code>
  
 ==== Leaving stuff behind ==== ==== Leaving stuff behind ====
  
-The hardest part probably, but the most important for huge maps to prevent power zone spam.+The hardest part probably, but the most important for huge maps, is to prevent power zone (PZ) spam.\\ 
 +This should be something the map maker should take care of himself and not be a problem you have to worry about. 
 +Though doing things on the destruction of our custom emitter isn't that hard.
  
 +== Set PZ creation on death ==
 +If you would like to force a PZ to appear or perhaps not to appear, that is done easily with the following snippet:\\
 +<code prpl>Self CONST_CREATEPZ FALSE SetUnitAttribute</code>
 +Explaining in-depth what it does:\\
 +__//self//__: Get the current unit (the emitter we're creating);\\
 +__//CONST_CREATEPZ//__: A constant each CRPL core has, defines whether or not to create a PZ on death;\\
 +__//FALSE//__: Set the above constant to false, meaning this emitter won't drop a PZ on death (obviously can also be TRUE);\\
 +__//SetUnitAttribute//__: Set the defined constant of the defined unit to the defined value.
 +<note>It's best not to force this constant in your code and leave the decision of whether or not to leave a PZ to the map maker. A map maker can choose whether or not to leave a PZ in the options of a CRPL code.</note>
 +
 +== Leaving something else behind ==
 +In case you're not satisfied with just a simple PZ, you can do whatever you'd like on the unit's death by defining a function called ''[[crpl:docs:func_destroyed|destroyed]]''.\\
 +This function is automatically called the moment the unit is destroyed.\\
 +Since we declared a variable called DeathAmt, lets release that much creeper upon death!
 +<code prpl>:destroyed 
 + CurrentCoords <-DeathAmt AddCreeper</code>
 +<note>Functions should always be at the end of your code. Read more about functions at [[crpl:crpltutorial#defining_your_own_functions|the CRPL tutorial]].</note>
 ==== Progressive output ==== ==== Progressive output ====
  
-=== Negative increment ===+== Negative increment == 
 + 
 +FIXME 
 +<hidden> What exactly is supposed to be put here? Progressive how? And why explain what a negative increment value would do? 
 +> I would assume increasing the creeper emission amount e.g.<code> 
 +if(<-Amt <-AmtMax neq) 
 + <-AmtIncrease 30.00 <-Delay div div <-Amt add ->Amt 
 +endif </code>  
 +</hidden>
  
 ==== Digitalis support ==== ==== Digitalis support ====
 +Simply add this code to the file to add Digitalis support
 +<code>
 +if(CurrentCoords GetDigitalis eq0 CurrentCoords GetDigitalisGrowth 1 eq eq)
 + CurrentCoords 1 SetDigitalis
 +endif
 +</code>
 +If there is any DigitalisGrowth //(The white Digitalis-like stuff that shows where it will grow)// under the core, Digitalis will grow.
  
 ==== Phantom/slip emitter ==== ==== Phantom/slip emitter ====
  
 ==== Flip emitter ==== ==== Flip emitter ====
crpl/crpltutorial/interactive/advancedemitter.1412190170.txt.gz · Last modified: 2014/10/12 18:46 (external edit)