Having trouble with some computercraft/lua code -


hi want lua code in computercraft allow user turn redstone signal on/off right clicking on monitor on top, can't work.

monitor = peripheral.wrap("top") monitor.clear() monitor.settextcolor(colors.red) monitor.setcursorpos(1, 1) monitor.settextscale(1) monitor.write("hello")  function rubber()     monitor.setcursorpos(1, 2)     monitor.clearline()      if rs.getoutput("right", true)         monitor.write("rubber farm on")     elseif rs.getoutput("right", false)         monitor.write("rubber farm off")     end      local event = { os.pullevent() }      if event == "monitor_touch"         if rs.getoutput("right") == true             rs.setoutput("right", false)         else             rs.setoutput("right", true)         end     else         write("test")     end      rubber() end 

right displays 'hello' , don't know how fix it, know how? i'm beginner @ lua i've made pretty simple mistakes. thanks

local event = { os.pullevent() } if event == "monitor_touch" 

os.pullevent returns tuple. in code, you're packing tuple table. that's fine, compare table string. tables can't equal strings - they're table. either don't pack tuple table, , keep first return value (the type):

local event = os.pullevent() if event == "monitor_touch" 

or extract first element when comparing

local event = { os.pullevent() } if event[1] == "monitor_touch" 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -