Bomb Bloke, on 08 February 2016 - 05:50 AM, said:
parallel.waitForAll(function() fs.delete("somefile") end, function() os.queueEvent("key",keys.y,false) end)
I had thought of something like that, which might lead to something like this:
env.coroutine.yield = function(...)
local event = {coroutine,yield}
while event[#event] == "Program Queued Event") do
table.remove(event,#event)
end
return event
end
env.os.queueEvent = function(...)
os.queueEvent(...,"Program Queued Event")
end
local randomNum = math.random(9999,1000000) --# Generating a random event name, so the program could not fake your special event
env.fos.open = function(path,mode)
print("Allow "..args[1].." to access "..path.."?")
print("Y/N")
while true do
local event = {os.pullEvent("key")}
if not event[#event] == "Program Queued Event" then
if event[2] == keys.y then
return _G.fs.open(path,mode)
elseif event[2] == keys.n then
return setmetatable({},{__index = function() return false end})
end
end
end
end
The program would only behave different if it for some reason queued a event with "Program Queued Event" at the end, but even then that could be accounted for. Only events queued by the program would be tagged, and anything outside of the program wouldn't remove the things at the end.
Edited by valithor, 08 February 2016 - 03:38 PM.