This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
How to make os.sleep, os.startTimer?
Started by LeDark Lua, 02 January 2016 - 09:53 AMPosted 02 January 2016 - 10:53 AM
Ok I'm making a project, and I need to make os.sleep and os.startTimer, but how?
Posted 02 January 2016 - 11:41 AM
Why would you want to make it? Sleep works like this:
local timer = os.startTimer()
repeat
local event, tmr = coroutine.yield("timer")
until tmr == timer
local timer = os.startTimer()
repeat
local event, tmr = coroutine.yield("timer")
until tmr == timer
Edited on 02 January 2016 - 10:42 AM
Posted 02 January 2016 - 11:50 AM
I know how it works, but I want to make it, because it bugs out the buffer I made. Or its my buffer, can't tell
Posted 02 January 2016 - 12:56 PM
It's usually a good idea to blame your own code until you can solidly prove that it's someone else's code's fault. So it's probably your buffer.I know how it works, but I want to make it, because it bugs out the buffer I made. Or its my buffer, can't tell
Anyway, there is no way to reimplement os.startTimer without using os.startTimer. The actual timer stuff is done natively.
Posted 02 January 2016 - 01:01 PM
So the question is. What are you trying to do with your buffer and how its bugging?It's usually a good idea to blame your own code until you can solidly prove that it's someone else's code's fault. So it's probably your buffer.I know how it works, but I want to make it, because it bugs out the buffer I made. Or its my buffer, can't tell
Anyway, there is no way to reimplement os.startTimer without using os.startTimer. The actual timer stuff is done natively.
Posted 02 January 2016 - 01:33 PM
I'm trying to run worm on it, or any program that uses term/paintutils.
Bug: it like shifts itself upwards
Bug: it like shifts itself upwards
Edited on 02 January 2016 - 01:21 PM
Posted 02 January 2016 - 05:06 PM
Definitely a problem in your code. Post your code.
Posted 02 January 2016 - 05:56 PM
My code: pastebin
or
Usage:
Make a main buffer according to your screen, then make a program buffer and draw that on the main buffer.
or
pastebin get LAejwLBZ gl
Usage:
os.loadAPI( "gl" )
local buffer = gl.create(x, y, width, height)
buffer:clear( backgroundColor, textColor )
buffer:clearLine( y, backgroundColor, textColor )
buffer:drawChar( x, y, char, backgroundColor, textColor )
buffer:drawText( x, y, text, backgroundColor, textColor )
local aTerm = buffer:getTerm()
buffer:draw( term )
Make a main buffer according to your screen, then make a program buffer and draw that on the main buffer.
Edited on 02 January 2016 - 05:01 PM