Posted 12 February 2012 - 09:05 PM
Here are the programs I've coded so far.
Master Control Terminal
The variable "x" is colors. ; to make this work, all colors are set to black, you should change this to suit your setup.
The variable "y" is [Machine] ; Replace [Machine] with the name of the machine.
The variable "z" is the side the bundled cable is on in quotes.
This code is able to control up to 30 machines at once. Referring to any machine that can be affected by a redstone current (industrialcraft, buildcraft, redpower, etc.)
Floppy Disk Lock
This is a simple-ish program to lock a door using the label on a floppy disk.
Master Control Terminal
Spoiler
function main1()
while true do
term.clear()
term.setCursorPos( 1, 1)
print("Master Control Unit Page 1")
print("What Machine would you like to access?")
print("_______________________________")
print("")
print("[1] ")
print("[2] ")
print("[3] ")
print("[4] ")
print("[5] ")
print("[6] ")
print("[7] ")
print("[8] ")
print("[9] ")
print("[0] ")
print("Hit [SPACE] for next page")
print("Hit [R] to reset machines on this page")
print("")
event, param1, param2, param3 = os.pullEvent()
if event == "char" and param1 == "1" then one() end
if event == "char" and param1 == "2" then two() end
if event == "char" and param1 == "3" then three() end
if event == "char" and param1 == "4" then four() end
if event == "char" and param1 == "5" then five() end
if event == "char" and param1 == "6" then six() end
if event == "char" and param1 == "7" then seven() end
if event == "char" and param1 == "8" then eight() end
if event == "char" and param1 == "9" then nine() end
if event == "char" and param1 == "0" then zero() end
if event == "char" and param1 == " " then main2() end
if event == "char" and param1 == "r" then reset("back") end
end
end
function main2()
while true do
term.clear()
term.setCursorPos( 1, 1)
print("Master Control Unit Page 2")
print("What Machine would you like to access?")
print("_______________________________")
print("")
print("[1] ")
print("[2] ")
print("[3] ")
print("[4] ")
print("[5] ")
print("[6] ")
print("[7] ")
print("[8] ")
print("[9] ")
print("[0] ")
print("Hit [SPACE] for next page")
print("Hit [B] for previous page")
print("Hit [R] to reset machines on this page")
event, param1, param2, param3 = os.pullEvent()
if event == "char" and param1 == "1" then one1() end
if event == "char" and param1 == "2" then two1() end
if event == "char" and param1 == "3" then three1() end
if event == "char" and param1 == "4" then four1() end
if event == "char" and param1 == "5" then five1() end
if event == "char" and param1 == "6" then six1() end
if event == "char" and param1 == "7" then seven1() end
if event == "char" and param1 == "8" then eight1() end
if event == "char" and param1 == "9" then nine1() end
if event == "char" and param1 == "0" then zero1() end
if event == "char" and param1 == "b" then main1() end
if event == "char" and param1 == " " then main3() end
if event == "char" and param1 == "r" then reset("left") end
end
end
function main3()
while true do
term.clear()
term.setCursorPos( 1, 1)
print("Master Control Unit Page 3")
print("What Machine would you like to access?")
print("_______________________________")
print("")
print("[1] ")
print("[2] ")
print("[3] ")
print("[4] ")
print("[5] ")
print("[6] ")
print("[7] ")
print("[8] ")
print("[9] ")
print("[0] ")
print("Hit [B] for previous page")
print("Hit [R] to reset machines on this page")
print("")
event, param1, param2, param3 = os.pullEvent()
if event == "char" and param1 == "1" then one2() end
if event == "char" and param1 == "2" then two2() end
if event == "char" and param1 == "3" then three2() end
if event == "char" and param1 == "4" then four2() end
if event == "char" and param1 == "5" then five2() end
if event == "char" and param1 == "6" then six2() end
if event == "char" and param1 == "7" then seven2() end
if event == "char" and param1 == "8" then eight2() end
if event == "char" and param1 == "9" then nine2() end
if event == "char" and param1 == "0" then zero2() end
if event == "char" and param1 == "b" then main2() end
if event == "char" and param1 == "r" then reset("right") end
end
end
function on(x, y, z)
if rs.testBundledInput(z, x)==true then
print(y.." already on")
sleep(1)
main1()
else
rs.setBundledOutput(z, rs.getBundledOutput(z) + x)
print(y.." on")
sleep(1)
main1()
end
end
function off(x, y, z)
if rs.testBundledInput(z, x)==false then
print(y.." already off")
sleep(1)
main1()
else
rs.setBundledOutput(z, rs.getBundledOutput(z) - x)
print(y.." off")
sleep(1)
main1()
end
end
function check(x, y, z)
if rs.testBundledInput(z, x)==false then
print(y.." off")
sleep(2)
term.clear()
term.setCursorPos( 1, 1)
main1()
end
if rs.testBundledInput(z, x)==true then
print(y.." on")
sleep(2)
term.clear()
term.setCursorPos( 1, 1)
main1()
end
end
function menu(x, y, z)
while true do
term.clear()
term.setCursorPos( 1, 1)
print(y.." Control Selected")
print("")
print("[1] Turn on " ..y)
print("[2] Turn off " ..y)
print("[3] Check Status")
print("[4] Return to Main Menu")
event, param1, param2, param3 = os.pullEvent()
if event == "char" and param1 == "1" then on(x, y, z) end
if event == "char" and param1 == "2" then off(x, y, z) end
if event == "char" and param1 == "3" then check(x, y, z) end
if event == "char" and param1 == "4" then main1() end
end
end
function reset(z)
rs.setBundledOutput(z ,0)
print("Machines reset")
term.setCursorPos( 1, 18)
term.clearLine()
sleep(1)
end
function one()
menu(colors.black, "[Machine]", "back")
end
function two()
menu(colors.black, "[Machine]", "back")
end
function three()
menu(colors.black, "[Machine]", "back")
end
function four()
menu(colors.black, "[Machine]", "back")
end
function five()
menu(colors.black, "[Machine]", "back")
end
function six()
menu(colors.black, "[Machine]", "back")
end
function seven()
menu(colors.black, "[Machine]", "back")
end
function eight()
menu(colors.green, "[Machine]", "back")
end
function nine()
menu(colors.black, "[Machine]", "back")
end
function zero()
menu(colors.black, "[Machine]", "back")
end
function one1()
menu(colors.black, "[Machine]", "left")
end
function two1()
menu(colors.black, "[Machine]", "left")
end
function three1()
menu(colors.black, "[Machine]", "left")
end
function four1()
menu(colors.black, "[Machine]", "left")
end
function five1()
menu(colors.black, "[Machine]", "left")
end
function six1()
menu(colors.black, "[Machine]", "left")
end
function seven1()
menu(colors.black, "[Machine]", "left")
end
function eight1()
menu(colors.green, "[Machine]", "left")
end
function nine1()
menu(colors.black, "[Machine]", "left")
end
function zero1()
menu(colors.black, "[Machine]", "left")
end
function one2()
menu(colors.black, "[Machine]", "right")
end
function two2()
menu(colors.black, "[Machine]", "right")
end
function three2()
menu(colors.black, "[Machine]", "right")
end
function four2()
menu(colors.black, "[Machine]", "right")
end
function five2()
menu(colors.black, "[Machine]", "right")
end
function six2()
menu(colors.black, "[Machine]", "right")
end
function seven2()
menu(colors.black, "[Machine]", "right")
end
function eight2()
menu(colors.green, "[Machine]", "right")
end
function nine2()
menu(colors.black, "[Machine]", "right")
end
function zero2()
menu(colors.black, "[Machine]", "right")
end
main1()
The variable "y" is [Machine] ; Replace [Machine] with the name of the machine.
The variable "z" is the side the bundled cable is on in quotes.
This code is able to control up to 30 machines at once. Referring to any machine that can be affected by a redstone current (industrialcraft, buildcraft, redpower, etc.)
Floppy Disk Lock
Spoiler
function main()
term.clear()
term.setCursorPos(1, 1)
pass = "password"
super = "root"
if disk.isPresent("right") == true then
label = disk.getLabel("right")
if disk.hasData("right") == true then
if label == pass then
password()
else
incorrect()
end
end
else
print("Please insert a Disk")
while true do
event, param1 = os.pullEvent()
if event == "disk" then
main()
end
if event == "char" and param1 == "a" then
nData()
end
end
end
end
function password()
print("Disk accepted, access granted")
sleep(1)
disk.eject("right")
print("Please take your disk")
rs.setOutput("left",true)
sleep(10)
os.shutdown()
end
function incorrect()
print("Disk not recognized, access denied")
sleep(3)
disk.eject("right")
main()
end
function nData()
print("Enter Admin password now")
write("> ")
input = io.read()
if input == super then
print("Now accessing admin mode")
sleep(2)
admin()
else
print("Incorrect password")
sleep(2)
main()
end
end
function admin()
print("Please insert disk to continue")
while true do
event, param1 = os.pullEvent()
if event == "disk" then
break
end
end
print("Would you like to create a password disk?")
input = io.read()
write("> ")
if input == "yes" then
print("Copying password files to disk")
sleep(3)
disk.setLabel("right",pass)
print("Disk created, please take the disk")
sleep(5)
disk.eject("right")
sleep(.5)
main()
elseif input == "no" then
print("Now exiting Admin mode")
sleep(2)
main()
end
end
main()