v0.3.1 bugfix #1
@@ -1,7 +1,7 @@
|
||||
local loadfile = ...
|
||||
local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile)
|
||||
|
||||
_G._OSVERSION = "Halyde 0.2.0"
|
||||
_G._OSVERSION = "Halyde 0.3.1"
|
||||
|
||||
function _G.import(module, ...)
|
||||
local args = table.pack(...)
|
||||
|
||||
+10
-3
@@ -13,8 +13,12 @@ function _G.cormgr.loadCoroutine(path)
|
||||
end
|
||||
|
||||
function handleError(errormsg)
|
||||
-- nothing for now
|
||||
assert(false, errormsg)
|
||||
if errormsg~=nil then
|
||||
-- nothing for now
|
||||
error(tostring(errormsg))
|
||||
else
|
||||
error("An error has occured, but given as 'nil'.")
|
||||
end
|
||||
end
|
||||
|
||||
local function runCoroutines()
|
||||
@@ -41,11 +45,14 @@ repeat
|
||||
until not tmpdata
|
||||
for line in data:gmatch("([^\n]*)\n?") do
|
||||
if line ~= "" then
|
||||
--[[ if _G.print then
|
||||
print(line)
|
||||
end ]]
|
||||
_G.cormgr.loadCoroutine(line)
|
||||
runCoroutines()
|
||||
end
|
||||
end
|
||||
_G.cormgr.loadCoroutine("/halyde/core/shell.lua")
|
||||
-- _G.cormgr.loadCoroutine("/halyde/core/shell.lua")
|
||||
|
||||
while true do
|
||||
runCoroutines()
|
||||
|
||||
@@ -2,15 +2,17 @@ _G.evmgr = {}
|
||||
_G.evmgr.eventQueue = {}
|
||||
local maxEventQueueLength = 10 -- increase if events start getting dropped
|
||||
|
||||
--local ocelot = component.proxy(component.list("ocelot")())
|
||||
local ocelot = component.proxy(component.list("ocelot")())
|
||||
|
||||
while true do
|
||||
local args
|
||||
repeat
|
||||
args = computer.pullSignal(0)
|
||||
if args then
|
||||
table.insert(evmgr.eventQueue, table.pack(computer.uptime(), args))
|
||||
ocelot.log("Sending signal "..args..","..computer.uptime())
|
||||
table.insert(evmgr.eventQueue, {computer.uptime(),args})
|
||||
while #evmgr.eventQueue > maxEventQueueLength do
|
||||
ocelot.log("Queue length breach, removing first signal")
|
||||
table.remove(evmgr.eventQueue, 1)
|
||||
end
|
||||
--ocelot.log("Event queue:")
|
||||
|
||||
@@ -6,6 +6,6 @@ local event = import("event")
|
||||
print("\n │\n │ ".._OSVERSION..'\n │ Welcome! Type "help" to get started.\n │')
|
||||
while true do
|
||||
--coroutine.yield()
|
||||
local args = table.pack(event.pull("key_down"))
|
||||
local args = {event.pull("key_down")}
|
||||
--ocelot.log(tostring(args[1]))
|
||||
end
|
||||
+9
-10
@@ -2,19 +2,17 @@ local event = {}
|
||||
|
||||
local ocelot = component.proxy(component.list("ocelot")())
|
||||
|
||||
function event.pull(type, timeout)
|
||||
checkArg(1, type, "string", "nil")
|
||||
function event.pull(evtype, timeout)
|
||||
checkArg(1, evtype, "string", "nil")
|
||||
checkArg(2, timeout, "number", "nil")
|
||||
local startTime = computer.uptime()
|
||||
local args
|
||||
repeat
|
||||
for i = 1, #evmgr.eventQueue do
|
||||
ocelot.log("Args 1 and 2:")
|
||||
ocelot.log(tostring(evmgr.eventQueue[i][1]))
|
||||
ocelot.log(tostring(evmgr.eventQueue[i][2]))
|
||||
ocelot.log(tostring(evmgr.eventQueue[i][3]))
|
||||
ocelot.log(tostring(evmgr.eventQueue[i][4]))
|
||||
if evmgr.eventQueue[i][1] >= startTime and (evmgr.eventQueue[i][2] == type or not type) then
|
||||
ocelot.log(tostring(evmgr.eventQueue[i][1]).." ("..type(evmgr.eventQueue[i][1]).."), "..tostring(evmgr.eventQueue[i][2]))
|
||||
--ocelot.log(tostring(evmgr.eventQueue[i][3]))
|
||||
--ocelot.log(tostring(evmgr.eventQueue[i][4]))
|
||||
if evmgr.eventQueue[i][1] >= startTime and (evmgr.eventQueue[i][2] == evtype or not evtype) then
|
||||
args = evmgr.eventQueue[i]
|
||||
break
|
||||
end
|
||||
@@ -24,8 +22,9 @@ function event.pull(type, timeout)
|
||||
end
|
||||
until args and not timeout or args and timeout and (args or computer.uptime() >= startTime + timeout)
|
||||
if args then
|
||||
table.remove(args, 1)
|
||||
return table.unpack(args)
|
||||
--[[ table.remove(args, 1)
|
||||
return table.unpack(args) ]]
|
||||
return args[2]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user