Posted 14 August 2012 - 12:29 PM
I spent the last hour or so repeatedly trying everything I can think of that could cause this. I'm trying to write a program to simply control 3 outputs from a bundled cable for our tekkit refinery. Currently the program is only have way done, but when I'm trying to test what I've written so far, it keeps calling nil on random lines for no apparant reason, at least to me. Please help me, I'd hate to see over 2 hours of my time be for nothing :P/>/> Maybe I'm just tired so I can't see the problem, it's around 4:30 am here atm. If you don't understand what a certain function is for feel free to ask me to clarify.
local clients = 31
local pass = "4808"
local modemside = "top"
local cableside = "left"
local oil = colors.green
local refinery = colors.blue
local fuel = colors.white
local oilstat = {}
oilstat[1] = on
local fuelstat = {}
fuelstat[1] = on
local refinerystat = {}
refinerystat[1] = on
local cablestat = {}
cablestat[1] = oil
cablestat[2] = refinery
cablestat[3] = fuel
function MainMenu()
while true do
term.clear()
term.setCursorPos(1, 1)
print("Refinery Control")
print("Please choose a system")
print("1. Oil Tank pumps")
print("2. Fuel Tank Pumps")
print("3. Refinery Control")
input = read()
if input == "1" then
OilChoice()
end
if input == "2" then
FuelChoice()
end
if input == "3" then
RefineryChoice()
end
end
function OilChoice()
while true do
term.clear()
term.setCursorPos(1, 1)
print("Oil Tank Pump Control")
if oilstat == "on" then
print("Pumps are currently on, would you like to disable? Y/N?")
input = read()
if input == "Y" then
print("Disabling Oil Pumps...")
table.remove(oilstat)
table.insert(oilstat,off)
table.insert(cablestat,1,oil)
sleep(1)
print("Oil Pumps disabled!")
sleep(2)
end
else
print(Ok)
sleep(2)
end
end
if oilstat[1] == off then
print("Pumps are currently off, would you like to enable? Y/N?")
input = read()
if input == "Y" then
print("Enabling Oil Pumps...")
table.remove(oilstat)
table.insert(oilstat,on)
table.remove(cablestat,1)
sleep(1)
print("Oil Pumps enabled!")
sleep(2)
end
else
print(Ok)
sleep(2)
end
end
function FuelChoice()
term.clear()
term.setCursorPos(1, 1)
print("Fuel Pump Control")
if fuelstat[1] == on then
print("Pumps are currently on, would you like to disable? Y/N?")
input = read()
if input == "Y" then
print("Disabling Fuel Pumps...")
table.remove(fuelstat)
table.insert(fuelstat,off)
table.insert(cablestat, 2, fuel)
sleep(1)
print("Fuel Pumps disabled!")
sleep(2)
end
else
print(Ok)
sleep(2)
end
if fuelstat[1] == off then
print("Pumps are currently off, would you like to enable? Y/N?")
input = read()
if input == "Y" then
print("Enabling Fuel Pumps...")
table.remove(fuelstat)
table.insert(fuelstat,on)
table.remove(cablestat, 2)
sleep(1)
print("Fuel Pumps enabled!")
sleep(2)
end
else
print(Ok)
sleep(2)
end
end
function RefineryChoice()
term.clear()
term.setCursorPos(1, 1)
print("Refinery Pump Control")
if refinerystat[1] == on then
print("Pumps are currently on, would you like to disable? Y/N?")
input = read()
if input == "Y" then
print("Disabling Refinery Pumps...")
table.remove(refinerystat)
table.insert(refinerystat,off)
table.insert(cablestat, 3, refinery)
sleep(1)
print("Refinery Pumps disabled!")
sleep(2)
end
else
print(Ok)
sleep(2)
end
end
if refinerystat[1] == off then
print("Pumps are currently off, would you like to enable? Y/N?")
input = read()
if input == Y then
print("Enabling Refinery Pumps...")
table.remove(refinerystat)
table.insert(refinerystat,on)
table.remove(cablestat, 3)
sleep(1)
print("Refinery Pumps enabled!")
sleep(2)
end
else
print(Ok)
sleep(2)
end
end
while true do
rednet.open(modemside)
term.clear()
term.setCursorPos(1, 1)
print("Refinery Control, please enter the password:")
input = read("*")
if input == pass then
print("Password Correct!")
sleep(1)
MainMenu()
if input == "Xieylu" then
break
end
else
print("Password Incorrect!")
sleep(2)
end
end