But! In actually using the thing, anytime I try to wrap a block, it tells me the subject line. Wha? Isn't that the whole point of a boolean value?
Anyway, I've spent an hour on this and cannot figure out my mistake. I'm hoping you guys will lend me some fresh eyes.
The API:
Spoiler
taber = {
activate = function(bOn) rs.setOutput(this.side, bOn) end
}
function wrap(side)
if side == "top" or side == "right" or side == "left" or side == "front" or side == "back" or side == "bottom" then
bobble = taber
bobble.activate = function(bOn) rs.setOutput(side, bOn) return true end
print("Block created")
coroutine.create(blockEvent(side))
return bobble
else
error("not a side")
end
end
function blockEvent(side)
local bOn = false
while true do
if rs.getInput(side) and not bOn then
os.queueEvent("block_activate", side)
bOn = not bOn
elseif not rs.getInput(side) and not bOn then
bOn = not bOn
end
sleep(0.05)
end
end
The Test Program: (I was in the process of testing the eventQueue system)
Spoiler
b = block.wrap("top")
if b then
print("Got a block")
else
print("Nothing!")
end
b.activate(true)
sleep(2.0)
b.activate(false)
while b do
print("Well")
evt, arg1, arg2, arg3 = os.pullEvent()
print(evt, ": ", arg1, ", ", arg2, ", ", arg3)
sleep(0.5)
end
I left in all debug prints, so work them out as you wish. And thank you in advance.
QUICK EDIT: The error show up on line 1 of the test program, but I'm certain it has something to do with the API.