Posted 18 March 2014 - 07:29 PM
This is my first (public) program! It is intended to make your advanced monitor easy to use, without having to code complex stuff all the time.
1.0 - initial release!
2.0 - added scrolling text & bugfixes
2.1 - bugfixes added check-for-valid stuffFuture Plans:
Adding a scrolling text utility (need help with debugging current code for this, please enter "no" when asked) Done!
Maybe auto detect monitor? (problem is, what if you have multiple monitors??)
http://pastebin.com/ii02ZH2g
pastebin get ii02ZH2g mon
Video
[media]http://youtu.be/M9-x4HwOSp8[/media]Code
t = term
t.sCP = t.setCursorPos
t.w = t.write
t.clear()
t.sCP(1, 1)
print("This program is provided by KingofGamesYami for personal use, please do not distribute. If your program is not working, check that you are using the correct syntax. If you use the scroll function, you must hold down control+t to stop the program. Press any key to continue")
os.pullEvent(key)
sleep(0.1)
t.clear()
t.sCP(1, 1)
t.w("Side: ") --side of your monitor
local side = string.lower(read())
if side == "top" or "right" or "left" or "back" or "bottom" or "front" then --check side is valid
--do nothing
else
print("Invalid side!")
sleep(10)
os.shutdown()
end
m = peripheral.wrap(side)
m.clear()
m.setCursorPos(1, 1)
t.sCP(1, 2)
t.w("Text Color: ") --Color of text
local input = string.lower(read())
local tcolor
if (colors[input] and type(colors[input]) == "number") or (colours[input] and type(colours[input]) == "number") then
tcolor = colors[input] or colours[input]
elseif tonumber(input) then
tcolor = tonumber(input)
else
print("Not a number or color!")
end
m.setTextColor(tcolor)
t.sCP(1, 3)
t.w("Background Color: ")
local input = string.lower(read())
local bcolor
if (colors[input] and type(colors[input]) == "number") or (colours[input] and type(colours[input]) == "number") then
bcolor = colors[input] or colours[input]
elseif tonumber(input) then
bcolor = tonumber(input)
else
print("Not a number or color!")
end
m.setBackgroundColor(bcolor) --Set Background Color
m.clear()
t.sCP(1, 4)
t.w("Text Size: ") --Size of Text (1 - 5)
local size = tonumber(read())
if size >= 0.5 and size <= 5 then --check size is valid
--do nothing
else
print("Your size isn't within the limits... 0.5 - 5")
sleep(10)
os.shutdown()
end
m.setTextScale(size)
t.sCP(1, 5)
t.w("Text: ") --Text that will be printed
local stuff = read()
t.sCP(1, 6) --Scroll
t.w("Would you like your text to scroll?: ")
local scroll = string.lower(read())
if scroll == "yes" then
t.sCP(1, 7)
t.w("Speed: ")
speed = tonumber(read())
local tlen = string.len(stuff)
local mwidth, mheight = m.getSize()
if mheight/2 == 0.5 then
mheight = 2
end
local tpos = mwidth
while true do --loop
if tpos == 0-tlen then --reset position
tpos = mwidth
end
m.clear()
m.setCursorPos(tpos, mheight/2)
m.write(stuff)
tpos = tpos-1
os.sleep(0.5/speed)
end
elseif scroll == "no" then
sleep(0.1)
else
print("Invalid answer, use yes or no")
end
t.redirect(m)
print(stuff)
t.restore()
Changelog
Changelog:1.0 - initial release!
2.0 - added scrolling text & bugfixes
2.1 - bugfixes added check-for-valid stuff
Maybe auto detect monitor? (problem is, what if you have multiple monitors??)
http://pastebin.com/ii02ZH2g
pastebin get ii02ZH2g mon
Edited on 22 March 2014 - 02:34 AM