| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- gl.setup(800,600)
- local json = require "json"
- local font = resource.load_font("silkscreen.ttf")
- local cur_image = resource.load_image("/home/david/git/especificos-node/node/1.png")
- local state = "diapo"
- local cur_preg = ""
- local time = "0:0"
- local img_prog="0/0"
- node.alias("eba")
- function decode_command(line)
- local cmd = json.decode(line)
- print(line)
- print(cmd.type)
- if cmd.type == "diapo" then
- cur_image:dispose()
- cur_image = resource.load_image(cmd.value)
- img_prog= cmd.progress
- elseif cmd.type == "pregunta" then
- cur_preg = cmd.preg
- elseif cmd.type == "time" then
- time = cmd.time
- print(time)
- elseif cmd.type == "video" then
- -- ?
- elseif cmd.type == "switch" then
- state = cmd.new_state
- end
- end
- --node.event("input", decode_command) -- listen to TCP
- node.event("data", decode_command) -- listen to UDP
- function node.render()
- if state == "diapo" then
- cur_image:draw(0,0,WIDTH,HEIGHT)
- font:write(730,580,time,20,1,1,1,1)
- font:write(10,580,img_prog,20,1,1,1,1)
- elseif state == "pregunta" then
- preguntas:draw(0,0,WIDTH,HEIGHT)
- font:write(120,320,cur_preg,20,1,1,1,1)
- end
- end
|