i'm trying to learn this lua on my own a bit, and taking by error and trial.
i've gotten as far as monitors and playing a bit with them
im trying to write a program that
1: wraps the monitor to the right (Done - works)
2: sets the background color to blue (cant get it to work, did it in another program, and copied the line from that program)
3: finds the monitor and writes on the monitor, which side it is located (Done works)
4: finds the monitors height and width and writes it onscree (Done works)
Entire code so far, including the notes i made myself
-- wrapping monitor, clearing it and setting cursor pos to top left
local monitor = peripheral.wrap("right")
monitor.setBackgroundColor(colors.Blue) --this line i cant get to work
monitor.clear()
monitor.setCursorPos(1,1)
-- write on the monitor, which side of the computer it is
local sides = { "top", "bottom", "left", "right", "front", "back" }
monitor.write("Finding monitors...")
monitor.setCursorPos(1,2)
for i = 1, #sides do
if peripheral.isPresent(sides[i]) then
if peripheral.getType(sides[i]) == "monitor" then
monitor.write("Fundet: "..sides[i])
end
end
end
-- Writing to screen how big it is
local widthA, heightA = monitor.getSize()
monitor.setCursorPos(1,1)
monitor.write("hvor stor er den")
monitor.setCursorPos(1,3)
monitor.write("vandret = "..widthA)
monitor.setCursorPos(1,4)
monitor.write("lodret = "..heightA)
-- clears screen after 10 seconds
sleep(10)
monitor.clear()
Edited by Dustmuz, 11 September 2014 - 11:55 AM.












