Skip to content

Instantly share code, notes, and snippets.

@TvL2386
Created November 30, 2025 00:46
Show Gist options
  • Select an option

  • Save TvL2386/eeecfea7bf9d492721c2a7617fcb8459 to your computer and use it in GitHub Desktop.

Select an option

Save TvL2386/eeecfea7bf9d492721c2a7617fcb8459 to your computer and use it in GitHub Desktop.
Script to turn off the LSC once Wireless EU exceeds SHUTOFF_EU (computer with adapter on LSC Controller)
local component = require("component")
LSC = component.gt_machine
require("debug_functions")
-- 1e16 turn off LSC
SHUTOFF_EU = 10000000000000000
function logInfo(string)
if type(string) == "string" then
print("[" .. os.date("%H:%M:%S") .. "] " .. string)
end
end
function getWirelessEnergy()
local sensorInformation = LSC.getSensorInformation()
local text = sensorInformation[23]
local value = text:gsub(",","")
value = value:match("%d+")
return tonumber(value)
end
function isRunning()
return LSC.isWorkAllowed()
end
function isNotRunning()
return not isRunning()
end
function turnOff()
LSC.setWorkAllowed(false)
end
function turnOn()
LSC.setWorkAllowed(true)
end
function shouldTurnOn()
return getWirelessEnergy() < SHUTOFF_EU
end
function shouldTurnOff()
return not shouldTurnOn()
end
function mainLoop()
logInfo("### Starting wireless LSC management program ###")
while true do
if isRunning() and shouldTurnOff() then
logInfo("Disable LSC")
turnOff()
elseif isNotRunning() and shouldTurnOn() then
logInfo("Enable LSC")
turnOn()
end
logInfo("Wireless EU: " .. getWirelessEnergy())
os.sleep(10)
end
end
mainLoop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment