Posted 25 October 2012 - 06:13 PM
I am trying to put together a script so that the screen in my spawn area displays info on an infinite loop and starts up when the server goes through its scheduled reboot.
what i have gotten so far is how to display the text to the top monitor with this code
local tText = {
"multiple",
"lines",
" of info"
}
local sSide = "top"
local nTextSize = 1.5 – change the text size here (from 1 to 5)
local function printCenter(mon, t)
local w, h = mon.getSize()
local y = math.floor((h / 2) - (#t / 2)) - 1
for i, line in ipairs(t) do
local x = math.floor((w / 2) - (#line / 2))
mon.setCursorPos(x, y + i)
mon.write(line)
end
end
local mon = peripheral.wrap(sSide)
mon.setTextScale(nTextSize)
printCenter(mon, tText)
what i would also like to do is have the script display 3 different screens of info with a timer between each page being displayed, i did some searching and i think im supposed to use os.sleep for the timer, just not sure how or where to put the code for the second page, i assume i need to clear screen b4 each display with monitor.clear
as for infinite loop i have seen some post to use something like: local function infiniteloop while true do do stuff, and what would i need to do to make this start when my server goes through its scheduled restarts
im just not sure how to put all this information together to make a workable script as i have no coding experience
thanks for any help
what i have gotten so far is how to display the text to the top monitor with this code
local tText = {
"multiple",
"lines",
" of info"
}
local sSide = "top"
local nTextSize = 1.5 – change the text size here (from 1 to 5)
local function printCenter(mon, t)
local w, h = mon.getSize()
local y = math.floor((h / 2) - (#t / 2)) - 1
for i, line in ipairs(t) do
local x = math.floor((w / 2) - (#line / 2))
mon.setCursorPos(x, y + i)
mon.write(line)
end
end
local mon = peripheral.wrap(sSide)
mon.setTextScale(nTextSize)
printCenter(mon, tText)
what i would also like to do is have the script display 3 different screens of info with a timer between each page being displayed, i did some searching and i think im supposed to use os.sleep for the timer, just not sure how or where to put the code for the second page, i assume i need to clear screen b4 each display with monitor.clear
as for infinite loop i have seen some post to use something like: local function infiniteloop while true do do stuff, and what would i need to do to make this start when my server goes through its scheduled restarts
im just not sure how to put all this information together to make a workable script as i have no coding experience
thanks for any help