glass.clear() is terminating Connection
Closed this issue · 9 comments
when I use this program: http://pastebin.com/PA92J9PH
it terminates the Connection after a few Seconds, when I wear the glasses.
The Errormessage from the console/log:http://pastebin.com/7YPmFzuB
Hope you can help me
Part or problem was your code, recreating objects every tick instead of updating fields, like this:
label = p.addText(10, 10, `Hello`)
label.setText('World')
Object creation is very "heavy" operation, changing single attribute (text, color, position) - not.
Other part of problem was race condition in our code. I fixed it, but now every change has to be manually send to players with .sync()
command. This function is limited to one call per tick - don't use it very often in loop.
So I won't be able to run my program without a sleep(0.5) anymore or it is possible to keep up the live notification system without that sleep?
No. As I said, updates are no longer send automatically, you need to call .sync()
on peripheral - and this command is automatically limiting update rate to one per tick (execution of program will momentarily pause). No extra limiting needed.
So I can just keep spamming .sync()?
They aren't cheap (one call - one net packet), so no. Once per loop should be enough. One after every addSomething
- total waste of bandwidth.
That was what I meant with spamming. Once per loop without a sleep.
Tried updating fields in latest verson from jenkins and as soon as i call
l = glass.setText(1,255,"Morning")
l.setText("TEST")
i get the error
lua:1:attempt to call nil
what am i doing wrong?
For some time OpenPeripheralCore returned strings instead of objects. Please update that too.
thanks, now it is working