User Tools

Site Tools


4rpl:commands:pingpong

Differences

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

Link to this comparison view

Next revision
Previous revision
4rpl:commands:pingpong [2024/05/23 00:34] – created Karsten754rpl:commands:pingpong [2025/02/14 14:57] (current) – external edit 127.0.0.1
Line 3: Line 3:
  
 :!: Available in version 2.5 and later. :!: Available in version 2.5 and later.
-====== CommandName ======+====== PingPong ======
 PingPong (<-t <-length) PingPong (<-t <-length)
  
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.1716424469.txt.gz · Last modified: 2025/02/14 14:56 (external edit)