This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
skypickle's profile picture

Sample table code won't work in online Lua demo

Started by skypickle, 25 June 2015 - 11:51 AM
skypickle #1
Posted 25 June 2015 - 01:51 PM
local eventHandler = { }
eventHandler["redstone"] = function (side)
   print("Redstone event on side: " .. side)
end
evtType,p1 = os.pullEvent()
eventHandler[evtType](p1)

--[[ On redstone event, outputs:
   Redstone event on side <side>
]]

Why doesn't the above code work in this Luademo here

http://www.lua.org/cgi-bin/demo
Edited on 25 June 2015 - 03:51 PM
Lyqyd #2
Posted 25 June 2015 - 05:53 PM
I've split this in to a new topic.
The_Cat #3
Posted 25 June 2015 - 06:22 PM
os.pullEvent is a computercraft api… Why not try it on a actual computer in-game?
Lupus590 #4
Posted 25 June 2015 - 06:30 PM
os.pullEvent is a computercraft api… Why not try it on a actual computer in-game?

or use one of the emulators on the forums, mimic is apparently a good online one
TheOddByte #5
Posted 25 June 2015 - 06:43 PM
or use one of the emulators on the forums, mimic is apparently a good online one
I'd recommend CCEmuRedux instead, as Mimic seems to have some bugs, atleast from what I've heard.
Lupus590 #6
Posted 25 June 2015 - 09:53 PM
I would recommend CCEmuRedux too as i have had problems with my few encounters with Mimic, but OP said they were using the online demo so I thought they may prefer a web based emulator over one they have to download.