This repository has been archived on 2024-11-12. You can view files and clone it, but cannot push or open issues or pull requests.
caffeine/run.lua

100 lines
2.1 KiB
Lua
Raw Normal View History

2022-03-28 17:00:16 +01:00
local gol = true
local noupair = true
local waterequ = true
if fs.exists("nacsl/caffeine/opt.conf") then
local f = io.open("nacsl/caffeine/opt.conf")
io.input(f)
local i = 0
for x in io.lines() do
if x == "true" and i == 0 then
gol = true
elseif x == "false" and i == 0 then
gol = false
end
if x == "true" and i == 1 then
noupair = true
elseif x == "false" and i == 1 then
noupair = false
end
if x == "true" and i == 2 then
waterequ = true
elseif x == "false" and i == 2 then
waterequ = false
end
i = i + 1
end
io.close(f)
end
if gol then
sim.gspeed(10)
end
if noupair then
sim.airMode(4)
end
if waterequ then
sim.waterEqualisation(0)
else
sim.waterEqualisation(1)
end
sim.edgeMode(1)
sim.prettyPowders(0)
sim.resetPressure()
sim.resetTemp()
ren.renderModes({67171201})
ren.displayModes({})
ren.colourMode(0)
ren.decorations(0)
ren.debugHUD(1)
local modmenu = Window:new(-1,-1,153,92)
local golbox = Checkbox:new(6,24,16,16,"Slow down GOL execution")
local airbox = Checkbox:new(6,48,16,16,"Prevent air updates")
local watrbox = Checkbox:new(6,72,16,16,"Disable water equalisation")
local closebut = Button:new(138,0,15,15,"X")
golbox:checked(gol)
airbox:checked(noupair)
watrbox:checked(waterequ)
local function updatesettings()
local beans = ""
local f = io.open("nacsl/caffeine/opt.conf", "w")
io.output(f)
if not golbox:checked() then
gol = false
beans = "false"
else
gol = true
beans = "true"
end
if not airbox:checked() then
noupair = false
beans = beans.."\nfalse"
else
noupair = true
beans = beans.."\ntrue"
end
if not watrbox:checked() then
waterequ = false
beans = beans.."\nfalse"
else
waterequ = true
beans = beans.."\ntrue"
end
io.write(beans)
io.close()
end
golbox:action(function(sender, checked) updatesettings() end)
airbox:action(function(sender, checked) updatesettings() end)
watrbox:action(function(sender, checked) updatesettings() end)
closebut:action(function(sender) interface.closeWindow(modmenu) end)
modmenu:addComponent(closebut)
modmenu:addComponent(golbox)
modmenu:addComponent(airbox)
modmenu:addComponent(watrbox)
nacsl.hook("caffeine",modmenu)
print("Caffeine hooked!")