45 lines
1.0 KiB
Lua
45 lines
1.0 KiB
Lua
local object = {}
|
|
local nvram = {}
|
|
|
|
function object.getMachineEvent()
|
|
if INTERNAL_EVENT_QUEUE[1]==nil then
|
|
return nil
|
|
end
|
|
local event = INTERNAL_EVENT_QUEUE[1]
|
|
INTERNAL_EVENT_QUEUE={table.unpack(INTERNAL_EVENT_QUEUE, 2)}
|
|
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("/AceVM/computers/"..tostring(aceVM.id).."/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
|
|
|
|
function aceVM.components.computer(id)
|
|
local file = fs.open("/AceVM/computers/"..tostring(id).."/nvram.dat", "r")
|
|
nvram = string.split(file.readAll(), "\n")
|
|
file.close()
|
|
aceVM.newComponent("computer", object)
|
|
end |