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

trying to learn - monitor

Started by Dustmuz, 11 September 2014 - 10:52 AM
Dustmuz #1
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()
Edited on 11 September 2014 - 10:55 AM
Lignum #2
Posted 11 September 2014 - 01:16 PM
Lua is case sensitive. It should be colours.blue, not colours.Blue.
Dustmuz #3
Posted 11 September 2014 - 01:29 PM
Lua is case sensitive. It should be colours.blue, not colours.Blue.

Doh.. hehe.. didn't see that tiny mistake..

thanks alot for that :)/>
have been staring at this for the past 2 hours, trying to figure out what i did wrong :D/>
and then it was such a tiny thing.. whoops :D/>
Lignum #4
Posted 11 September 2014 - 02:41 PM
You're welcome! It's always the tiny things that break everything.