lsft/cl_lsft.txt

110 lines
2.9 KiB
Text
Raw Permalink Normal View History

2021-12-14 20:11:04 -05:00
--@name Logan's Starfall Toolkit
--@author logan2611
--@client
--@includedir lsft/modules/client
--@includedir lsft/modules/shared
--[[
_ ____ _____ _____
| | / ___|| ___|_ _|
| | _____ \___ \| |_ | |
| |___ |_____| ___) | _| | |
|_____| |____/|_| |_|
--]]
--[[
TODO: Literally everything
TODO: Update checker
TODO: On module load, grab default config values. Write changed values
2021-12-22 19:17:09 -05:00
TODO: Clientside core:log, with network to owner or server
2021-12-14 20:11:04 -05:00
prop.createSent(chip():getPos()+Vector(0,0,90),Angle(0,0,0),"Seat_Airboat",true)
--]]
2021-12-16 02:03:25 -05:00
core = {}
2021-12-14 20:11:04 -05:00
if player() == owner() then
if not file.exists("lsftconf.txt") then
file.write("lsftconf.txt", "{}")
config = "{}"
else
config = file.read("lsftconf.txt")
end
net.start("LSFT-Config-Read")
net.writeStream(config)
net.send()
net.receive("LSFT-Config-Write", function(data)
print("Got net message to write config, waiting for stream...")
net.readStream(function(data)
print("Stream finished, writing")
file.write("lsftconf.txt", data)
end)
end)
--[[
net.receive("LSFT-Get-Config-Resp-Test", function()
print(unpack(net.readTable()))
print(unpack(net.readTable()))
end)
--]]
2021-12-14 20:11:04 -05:00
end
net.receive("LSFT-Loaded", function()
dodir("lsft/modules/client")
dodir("lsft/modules/shared")
if player() == owner() then
--[[
net.start("LSFT-Get-Config")
net.writeString("LSFT-Get-Config-Resp-Test")
net.writeTable({"core","command_prefix"})
net.writeTable({"spectate","controls","forward"})
net.writeTable({})
net.send()
--]]
end
local maxCPU = 0
timer.create("CPUCheck", 0.5, 0, function()
if quotaAverage() > maxCPU then
maxCPU = quotaAverage()
end
if quotaAverage() > quotaMax() * 0.9 then
timer.pause("CPUCheck")
timer.pause("NetCheck")
timer.pause("RAMCheck")
timer.simple(10, function() timer.unpause("CPUCheck") timer.unpause("NetCheck") timer.unpause("RAMCheck") end)
end
end)
local minNet = 2^31
timer.create("NetCheck", 0.5, 0, function()
if net.getBytesLeft() < minNet then
minNet = net.getBytesLeft()
end
end)
local maxRAM = 0
timer.create("RAMCheck", 0.5, 0, function()
if ramUsed() > maxRAM then
maxRAM = ramUsed()
end
end)
net.receive("LSFT-StatsRequest", function(len, ply)
net.start("LSFT-StatsResponse")
net.writeFloat(maxCPU)
net.writeFloat(quotaMax())
net.writeFloat(maxRAM)
net.writeFloat(ramMax())
net.writeFloat(minNet)
net.send()
end)
end)