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