Advertisement
RadioMelon

E2: Cloaking Device

Apr 15th, 2022 (edited)
1,636
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.75 KB | None | 0 0
  1. @name Cloaking_Device
  2. @inputs Toggle Range
  3. @outputs Status:string
  4. @persist Target:entity List:array I C:entity
  5.  
  6. # Cloaks a range of objects within a set radius
  7. # Only cloaks object when first activated, does NOT actively cloak per tick
  8.  
  9. if(Toggle == 1) # If it's on
  10. {  
  11.    D = "Cloaking device activated."
  12.    
  13.    if(Range == 0)
  14.    {
  15.        soundPlay(1,0,"common/warning.wav")
  16.        print("Error, no range defined for cloak!")
  17.    }
  18.    elseif(Range < 0)
  19.    {
  20.        soundPlay(1,0,"common/warning.wav")
  21.        print("Range cannot be negative!")
  22.        Range = 0
  23.        print("Range reassigned to 0")
  24.    }
  25.    elseif(Range > 0)
  26.    {
  27.        soundPlay(1,0,"hl1/fvox/blip.wav")
  28.        print("Cloaking range: " + Range)
  29.    }
  30.    
  31.    if(findCanQuery())
  32.    {
  33.        I = 0
  34.  
  35.        if(findInSphere(entity():pos(), Range))
  36.        {
  37.            findSortByDistance(entity():pos())
  38.            List = findToArray()
  39.            print("Cloaking area.")
  40.            while(I < List:count())
  41.            {          
  42.                Target = List[I, entity]
  43.                Target:setAlpha(1)
  44.            
  45.                I++
  46.            }
  47.        }
  48.    }
  49. }
  50. else
  51. {
  52.    Status = "Cloaking device deactivated."
  53.    
  54.    # Can only uncloak things within it's range
  55.     # Uncloak things out of range - TODO
  56.     if(findCanQuery())
  57.     {
  58.         I = 0
  59.        
  60.         findInSphere(entity():pos(), Range)
  61.         findSortByDistance(entity():pos())
  62.         List = findToArray()
  63.         print("Uncloaking area.")
  64.         print("Uncloaked: ")
  65.         print(List)
  66.         while(I < List:count())
  67.         {
  68.             Target = List[I, entity]
  69.             Target:setAlpha(255)
  70.            
  71.             I++
  72.         }
  73.     }
  74. }
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement