Posted 11 September 2014 - 12:52 PM
Hello fellow crafters :D/>
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) then
if peripheral.getType(sides) == "monitor" then
monitor.write("Fundet: "..sides)
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()
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) then
if peripheral.getType(sides) == "monitor" then
monitor.write("Fundet: "..sides)
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 on 11 September 2014 - 10:55 AM