Posted 29 October 2015 - 10:20 AM
Hello, i made scoreboard for sport games. Check photos:
Ok, now you understand what i talking about. System are very simple, connect wired modem to bottom of computer and right side of monitor, connect with networking cable. Change in script monitor_2 to your monitor name. ( Change in 2 files: startup and m)
==Codes==
startup:
mon.clear()
mon.setCursorPos(1,1)
mon.write("CA 70")
term.clear()
print("CA700 scoreboard system.")
sleep(2)
print("Loading data.")
sleep(2)
print("Reseting time lamp.")
rs.setOutput("right",true)
sleep(2)
print("Launching scoreboard.")
mon.clear()
mon.setTextColor(colors.black)
mon.setCursorPos(1,2)
mon.setTextScale(5)
rs.setOutput("right",false)
sleep(3)
rs.setOutput("right",false)
rs.setOutput("right",true)
term.clear()
term.setCursorPos(1,1)
print("CA700") –only need minutes
print("1-nos 2- t 3-p 4- arez 5- brez")
local mon = peripheral.wrap('monitor_2')
mon.clear()
mon.setCursorPos(1,1)
mon.setTextScale(3)
mon.write("VEF INZENIERU CENTRS")
mon.setBackgroundColor(colors.black)
mon.setTextColor(colors.white)
mon.setTextScale(5)
mon.setCursorPos(1,1)
mon.write("CA70")
mon.setCursorPos(8,3)
mon.write("1")
mon.setCursorPos(1,1)
mon.setTextScale(5)
mon.setCursorPos(7,5)
mon.write("–")
mon.setCursorPos(8,5)
mon.write(":")
mon.setCursorPos(9,5)
mon.write("–")
mon.setCursorPos(4,3)
mon.write("0")
mon.setCursorPos(13,3)
mon.write("0")
term.clear()
sleep(2)
shell.run("m")
And command m
print("Tablo izveles iespējas")
local tSelections = {
"Default team names(HOME-GUEST)",
"Own team names",
"Home score",
"Guest score",
"Period",
"Scoreclock - time",
"Turn off scoreboard",
"Restart",
"FAQ",
}
local startYPos = 3
local startXPos = 5
local function startMenu( tMenu, sTitle )
– This function just prints the menu
local function printMenu( tMenu, sTitle, nSelected )
for index, text in pairs( tMenu ) do
term.setCursorPos( startXPos, startYPos + index - 1 )
write( (nSelected == index and '[' or ' ') .. text .. (nSelected == index and ']' or ' ') )
end
end
local selection = 1
while true do
printMenu( tMenu, sTitle, selection )
event, but = os.pullEvent("key")
if but == keys.up then
– Up
selection = selection - 1
elseif but == keys.down then
– Down
selection = selection + 1
elseif but == keys.enter then
– Enter
return tMenu[selection], selection – returns the text AND the number
end
selection = selection < 1 and #tMenu or selection > #tMenu and 1 or selection
end
end
term.clear()
sOption, nNumb = startMenu( tSelections ) – start the function … 'sOption' and 'nNumb'
term.clear()
term.setCursorPos(1, 1)
print(sOption)
print(nNumb)
if sOption == "Selection 1" then
shell.run("m")
mon.setCursorPos(1,1)
mon.write("HOME")
mon.setCursorPos(9,1)
mon.write("-")
mon.setCursorPos(11,1)
mon.write("GUEST")
elseif nNumb == 1 then
print("Done, returning to menu.")
mon.setCursorPos(1,1)
mon.write("HOME")
mon.setCursorPos(9,1)
mon.write("-")
mon.setCursorPos(11,1)
mon.write("GUEST")
sleep(2)
shell.run("m")
end
if sOption == "Selection 1" then
mon.write(input)
elseif nNumb == 2 then
print("Home team name")
write("-> ")
input = read()
mon.setCursorPos(1,1)
mon.write(input)
mon.setCursorPos(9,1)
mon.write("-")
print("Guest team name")
write("-> ")
input = read()
mon.setCursorPos(11,1)
mon.write(input)
print("Done, returning to menu.")
sleep(2)
shell.run("m")
end
if sOption == "Selection 1" then
elseif nNumb == 3 then
print("Home team score") –only need minutes
write("-> ")
input = read()
mon.setTextColor(colors.white)
mon.setCursorPos(4,3)
mon.write(input)
print("Done, returning to menu.")
sleep(2)
shell.run("m")
end
if sOption == "Selection 1" then
elseif nNumb == 4 then
print("Guest team score") –only need minutes
write("-> ")
input = read()
mon.setTextColor(colors.white)
mon.setCursorPos(13,3)
mon.write(input)
print("Done, returning to menu.")
sleep(2)
shell.run("m")
end
if sOption == "Selection 1" then
elseif nNumb == 5 then
print("Period") –only need minutes
write("-> ")
input = read()
mon.setTextColor(colors.white)
mon.setCursorPos(8,3)
mon.write(input)
print("Done, returning to menu.")
sleep(2)
shell.run("m")
end
if sOption == "Selection 1" then
elseif nNumb == 6 then
print("Set game time") –only need minutes
print("Minutes?") –only need minutes
write("-> ")
minute = tonumber(read()) –input directly as number(avoid string)
print("Seconds") –only need minutes
write("-> ")
sec = tonumber(read()) –input directly as number(avoid string)
local mon = peripheral.wrap('monitor_2')
local j = sec –declare seconds variable
local i = minute —declare minutes variable
min = i
sleep(1)
–Returning Results
mon.setTextScale(5)
mon.setCursorPos(7,5)
mon.write(min..":"..sec)
os.pullEvent("redstone")
if rs.getInput("left") then
rs.setOutput("right",false)
repeat
if i > 0 then
if j > 0 then
j = j - 1
else
j = 59
i = i - 1
end
else
if j > 0 then
j = j - 1
else
done = true
end
end
if j > 9 then
sec = j
else
sec = "0"..j
end
min = i
sleep(1)
if i < 10 then
mon.setCursorPos(11,5)
mon.write(".")
end
–Returning Results
mon.setTextScale(5)
mon.setCursorPos(7,5)
mon.write(min..":"..sec)
until j == 0 and i == 0
rs.setOutput("right",true) – trigger redstone output
sleep(1)
end
if i < 10 then
mon.setCursorPos(12,5)
mon.write(".")
end
shell.run("m")
end
if sOption == "Selection 1" then
elseif nNumb == 7 then
mon.clear()
rs.setOutput("right",false)
term.clear()
mon.clear()
os.shutdown()
mon.clear()
end
if sOption == "Selection 1" then
elseif nNumb == 8 then
os.reboot()
end
if sOption == "Selection 1" then
elseif nNumb == 9 then
print("=== Time ===")
print("If you run a time, you can stop it only terminating program (ctrl + t) than run command m for menu.")
print("Time have input format: mm:ss")
print("Max time for scoreboard are: 9:59")
print("If you have .nil. error than restart your scoreboard.")
print("=== TEAM NAMES ===")
print("Number of letters: Home:8 Guest:6")
print("Number of letters: Home:8 Guest:6")
sleep(4)
shell.run("m")
end
If you have questions fell free to ask. This scoreboard are made by myself but used internet for examples.P.S. Redstone ar for green lamps, from hockey if time stands(not running) green lamp works, when goes lamp not working( still making).
Have nice day
Latvians can!
Spoiler
Spoiler
Spoiler
Spoiler
Ok, now you understand what i talking about. System are very simple, connect wired modem to bottom of computer and right side of monitor, connect with networking cable. Change in script monitor_2 to your monitor name. ( Change in 2 files: startup and m)
==Codes==
startup:
Spoiler
local mon = peripheral.wrap('monitor_2')mon.clear()
mon.setCursorPos(1,1)
mon.write("CA 70")
term.clear()
print("CA700 scoreboard system.")
sleep(2)
print("Loading data.")
sleep(2)
print("Reseting time lamp.")
rs.setOutput("right",true)
sleep(2)
print("Launching scoreboard.")
mon.clear()
mon.setTextColor(colors.black)
mon.setCursorPos(1,2)
mon.setTextScale(5)
rs.setOutput("right",false)
sleep(3)
rs.setOutput("right",false)
rs.setOutput("right",true)
term.clear()
term.setCursorPos(1,1)
print("CA700") –only need minutes
print("1-nos 2- t 3-p 4- arez 5- brez")
local mon = peripheral.wrap('monitor_2')
mon.clear()
mon.setCursorPos(1,1)
mon.setTextScale(3)
mon.write("VEF INZENIERU CENTRS")
mon.setBackgroundColor(colors.black)
mon.setTextColor(colors.white)
mon.setTextScale(5)
mon.setCursorPos(1,1)
mon.write("CA70")
mon.setCursorPos(8,3)
mon.write("1")
mon.setCursorPos(1,1)
mon.setTextScale(5)
mon.setCursorPos(7,5)
mon.write("–")
mon.setCursorPos(8,5)
mon.write(":")
mon.setCursorPos(9,5)
mon.write("–")
mon.setCursorPos(4,3)
mon.write("0")
mon.setCursorPos(13,3)
mon.write("0")
term.clear()
sleep(2)
shell.run("m")
And command m
Spoiler
local mon = peripheral.wrap('monitor_2')print("Tablo izveles iespējas")
local tSelections = {
"Default team names(HOME-GUEST)",
"Own team names",
"Home score",
"Guest score",
"Period",
"Scoreclock - time",
"Turn off scoreboard",
"Restart",
"FAQ",
}
local startYPos = 3
local startXPos = 5
local function startMenu( tMenu, sTitle )
– This function just prints the menu
local function printMenu( tMenu, sTitle, nSelected )
for index, text in pairs( tMenu ) do
term.setCursorPos( startXPos, startYPos + index - 1 )
write( (nSelected == index and '[' or ' ') .. text .. (nSelected == index and ']' or ' ') )
end
end
local selection = 1
while true do
printMenu( tMenu, sTitle, selection )
event, but = os.pullEvent("key")
if but == keys.up then
– Up
selection = selection - 1
elseif but == keys.down then
– Down
selection = selection + 1
elseif but == keys.enter then
– Enter
return tMenu[selection], selection – returns the text AND the number
end
selection = selection < 1 and #tMenu or selection > #tMenu and 1 or selection
end
end
term.clear()
sOption, nNumb = startMenu( tSelections ) – start the function … 'sOption' and 'nNumb'
term.clear()
term.setCursorPos(1, 1)
print(sOption)
print(nNumb)
if sOption == "Selection 1" then
shell.run("m")
mon.setCursorPos(1,1)
mon.write("HOME")
mon.setCursorPos(9,1)
mon.write("-")
mon.setCursorPos(11,1)
mon.write("GUEST")
elseif nNumb == 1 then
print("Done, returning to menu.")
mon.setCursorPos(1,1)
mon.write("HOME")
mon.setCursorPos(9,1)
mon.write("-")
mon.setCursorPos(11,1)
mon.write("GUEST")
sleep(2)
shell.run("m")
end
if sOption == "Selection 1" then
mon.write(input)
elseif nNumb == 2 then
print("Home team name")
write("-> ")
input = read()
mon.setCursorPos(1,1)
mon.write(input)
mon.setCursorPos(9,1)
mon.write("-")
print("Guest team name")
write("-> ")
input = read()
mon.setCursorPos(11,1)
mon.write(input)
print("Done, returning to menu.")
sleep(2)
shell.run("m")
end
if sOption == "Selection 1" then
elseif nNumb == 3 then
print("Home team score") –only need minutes
write("-> ")
input = read()
mon.setTextColor(colors.white)
mon.setCursorPos(4,3)
mon.write(input)
print("Done, returning to menu.")
sleep(2)
shell.run("m")
end
if sOption == "Selection 1" then
elseif nNumb == 4 then
print("Guest team score") –only need minutes
write("-> ")
input = read()
mon.setTextColor(colors.white)
mon.setCursorPos(13,3)
mon.write(input)
print("Done, returning to menu.")
sleep(2)
shell.run("m")
end
if sOption == "Selection 1" then
elseif nNumb == 5 then
print("Period") –only need minutes
write("-> ")
input = read()
mon.setTextColor(colors.white)
mon.setCursorPos(8,3)
mon.write(input)
print("Done, returning to menu.")
sleep(2)
shell.run("m")
end
if sOption == "Selection 1" then
elseif nNumb == 6 then
print("Set game time") –only need minutes
print("Minutes?") –only need minutes
write("-> ")
minute = tonumber(read()) –input directly as number(avoid string)
print("Seconds") –only need minutes
write("-> ")
sec = tonumber(read()) –input directly as number(avoid string)
local mon = peripheral.wrap('monitor_2')
local j = sec –declare seconds variable
local i = minute —declare minutes variable
min = i
sleep(1)
–Returning Results
mon.setTextScale(5)
mon.setCursorPos(7,5)
mon.write(min..":"..sec)
os.pullEvent("redstone")
if rs.getInput("left") then
rs.setOutput("right",false)
repeat
if i > 0 then
if j > 0 then
j = j - 1
else
j = 59
i = i - 1
end
else
if j > 0 then
j = j - 1
else
done = true
end
end
if j > 9 then
sec = j
else
sec = "0"..j
end
min = i
sleep(1)
if i < 10 then
mon.setCursorPos(11,5)
mon.write(".")
end
–Returning Results
mon.setTextScale(5)
mon.setCursorPos(7,5)
mon.write(min..":"..sec)
until j == 0 and i == 0
rs.setOutput("right",true) – trigger redstone output
sleep(1)
end
if i < 10 then
mon.setCursorPos(12,5)
mon.write(".")
end
shell.run("m")
end
if sOption == "Selection 1" then
elseif nNumb == 7 then
mon.clear()
rs.setOutput("right",false)
term.clear()
mon.clear()
os.shutdown()
mon.clear()
end
if sOption == "Selection 1" then
elseif nNumb == 8 then
os.reboot()
end
if sOption == "Selection 1" then
elseif nNumb == 9 then
print("=== Time ===")
print("If you run a time, you can stop it only terminating program (ctrl + t) than run command m for menu.")
print("Time have input format: mm:ss")
print("Max time for scoreboard are: 9:59")
print("If you have .nil. error than restart your scoreboard.")
print("=== TEAM NAMES ===")
print("Number of letters: Home:8 Guest:6")
print("Number of letters: Home:8 Guest:6")
sleep(4)
shell.run("m")
end
If you have questions fell free to ask. This scoreboard are made by myself but used internet for examples.P.S. Redstone ar for green lamps, from hockey if time stands(not running) green lamp works, when goes lamp not working( still making).
Have nice day
Latvians can!
Edited on 29 October 2015 - 07:21 PM