Posted 27 March 2013 - 11:36 AM
At the moment, I'm working on an elevator control turtle that will take touchscreen input. I plan to have it simply write floor numbers to the monitor, and have the player click the appropriate number. However, monitor.write() is behaving strangely. If I pass it an integer to write, in this case 5, it will return "5.0". Is there a way I can make it return simply "5", and as such avoid having to reposition the cursor and overwrite the decimal with whitespace?
Will post code shortly, Chrome has a tendency to crash on me.
Edit: Code:
Will post code shortly, Chrome has a tendency to crash on me.
Edit: Code:
m = peripheral.wrap("left") --Wrapping the monitor
w = peripheral.wrap("right") --Wrapping the REther module
local floor = 1 --Turtle starts at floor 1. Will play with filesystem so that I dont have to replace it every time the world loads
local floors= 5 --Highest Floor
local draw = 1
function drawing() --Relevant Code
m.setTextScale(2) --Just a bit easier to click
while draw <= floors do --Start the loop
m.setCursorPos((draw*2)-1,1) --Set the position - I want output in odd numbered positions only!
m.write(draw) --Assume draw is 5. This writes "5.0" to the monitor
write(draw) -- This outputs "5" to the console. How can I do this on the monitor?
--wait = read("*") -- Just for debug
draw = draw + 1 -- Advance the loop
end
draw = 1 -- Reset the variable so that this function can run again at the next floor
end
drawing()