architectt

Untitled

Feb 13th, 2021
140
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Other = {
  2.     CityWideDeviceTypes = {
  3.         "TrafficLight",
  4.         "CrossingLight",
  5.         "TV",
  6.         "Reflector",
  7.         "LcdScreen"
  8.     }
  9. }
  10.  
  11. function Other.ToggleAllDevices(state)
  12.     local player = Game.GetPlayer()
  13.     local targetSystem = Game.GetTargetingSystem()
  14.     local tsqAll = Game["TSQ_ALL;"]()
  15.    
  16.     local thingOne, targetParts = targetSystem:GetTargetParts(player, tsqAll, targetParts)
  17.  
  18.     for _, obj in ipairs(targetParts) do
  19.         local entity = obj:GetComponent(obj):GetEntity()
  20.  
  21.         if Other.Util.IfArrayHasValue(Other.CityWideDeviceTypes, entity:ToString()) then
  22.            
  23.             if state == "Activate" then
  24.                 entity:ActivateDevice()
  25.             end
  26.  
  27.             if state == "Deactivate" then
  28.                 entity:DeactivateDevice()
  29.             end
  30.         end
  31.     end
  32. end
RAW Paste Data