e
This commit is contained in:
1 parent
5111182a4b
commit
abd573f686
64 files changed
+2407
-157
No files matched your search
@@ -0,0 +1,42 @@
|
||||
local object = {}
|
||||
local file = fs.open("/computers/0/nvram.dat", "r")
|
||||
local nvram = string.split(file.readAll(), "\n")
|
||||
file.close()
|
||||
|
||||
function object.getMachineEvent()
|
||||
if INTERNAL_EVENT_QUEUE[1]==nil then
|
||||
return nil
|
||||
end
|
||||
local event = INTERNAL_EVENT_QUEUE[1]
|
||||
INTERNAL_EVENT_QUEUE[1]=nil
|
||||
return table.unpack(event)
|
||||
end
|
||||
|
||||
function object.getData(addr)
|
||||
if type(addr)~="number" then
|
||||
error()
|
||||
end
|
||||
return nvram[addr]
|
||||
end
|
||||
|
||||
function object.setData(addr, data)
|
||||
if type(addr)~="number" then
|
||||
error()
|
||||
end
|
||||
if type(data)~="string" then
|
||||
error()
|
||||
end
|
||||
nvram[addr]=data
|
||||
end
|
||||
|
||||
function object.saveData()
|
||||
local file=fs.open("/nvram.dat", "w")
|
||||
file.write(table.concat(nvram,"\n"))
|
||||
end
|
||||
|
||||
object.reboot=os.reboot
|
||||
object.shutdown=os.shutdown
|
||||
|
||||
function object.beep() end -- IDK how i should implement this
|
||||
|
||||
newComponent("computer", object)
|
||||
Reference in new issue
Block a user