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

My monitor only show one "m.write" and not the next four

Started by Dovhian, 01 December 2012 - 01:56 AM
Dovhian #1
Posted 01 December 2012 - 02:56 AM
I'm trying to make a screen for a racetrack, it is supposed to count down, but it only displays "Let's start this race!" while the next three numbers of the countdown does not display on the monitor. How do i fix this?


m = peripheral.wrap("back")
m.clear()
m.setTextScale(5)
m.setCursorPos(6,1)
m.write("RACE")
x,y,z = rednet.receive()
if y == "startRace" then
   m.clear()
   m.setCursorPos(1,1)
   m.setTextScale(3)
   m.write "Let's start this race!"
   sleep(2)
   m.clear()
   m.write ("Three")
   sleep(2)
   m.clear()
   m.write "Two"
   sleep(2)
   m.clear()
   m.write "One"
   sleep(2)
   m.clear()
   m.write "GO!"
   rednet.broadcast("GO")
   shell.run("menu")
else
   shell.run("menu")
end
Kingdaro #2
Posted 01 December 2012 - 03:35 AM
You might need to reset the cursor position every time you write a new number. I'm thinking the numbers are being drawn off-screen. For these purposes, it'd be best to make a nice clear() function to make things convenient.


m = peripheral.wrap("back")
m.clear()
m.setTextScale(5)
m.setCursorPos(6,1)
m.write("RACE")

local function clear()
   m.clear()
   m.setCursorPos(1,1)
end

x,y,z = rednet.receive()
if y == "startRace" then
   clear()
   m.setTextScale(3)
   m.write "Let's start this race!"
   sleep(2)
   clear()
   m.write ("Three")
   sleep(2)
   clear()
   m.write "Two"
   sleep(2)
   clear()
   m.write "One"
   sleep(2)
   clear()
   m.write "GO!"
   rednet.broadcast("GO")
   shell.run("menu")
else
   shell.run("menu")
end