User Tools

Site Tools


4rpl:commands:pingpong

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
4rpl:commands:pingpong [2024/05/24 10:43] – Fix title Up-Level4rpl:commands:pingpong [2024/06/12 14:35] (current) – [Examples] Kalli
Line 15: Line 15:
 ===== Examples ===== ===== Examples =====
 <code 4rpl> <code 4rpl>
-need worked example+An example of a unit + a beam.  
 +# The brightness of the unit and beam fluctuates while paused. 
 +# The interval of t is 60+60 frames = 4 seconds. 
 + 
 +:once 
 +# Running the code in :PostUpdate allows it to work while paused when inside a unit script. 
 +RegisterForMSG("MSG_PostUpdate" "PostUpdate")  
 + 
 +# To Differentiate against other units of the same type, the pulse time is set out of sync: 
 +self getunittype 0 getunitsbytype ->unitList 
 +<-unitList self getlistindex 33 mul getgametickcount add 120 mod ->t  
 +   # tickcount instead of updatecount since this will run while paused. 
 + 
 +# Creating a beam between the unit and another unit 
 +"red" 2 3 createbeam ->otherBeam 
 +<-otherBeam <-otherUID "sphere" 1 getobjposition setbeamstart 
 +<-otherBeam self "core" 1 getobjposition setbeamend 
 + 
 +:PostUpdate 
 +<-t 1 add dup ->t 60 pingpong ->pingpong 
 +self "core" <-pingpong 10 div 0 0 v3 setobjcolor 
 +<-otherBeam <-pingpong 60 div setbeambrightness 
 </code> </code>
  
 <=[[4rpl:start| Index]] <=[[4rpl:start| Index]]
4rpl/commands/pingpong.txt · Last modified: 2024/06/12 14:35 by Kalli