So tables are giving me issues again but differently I am trying to call from a table I have been trying to sort out the base code before adding the main loop and well. here it is…
-- Whitelist
-- whitelist = {"JustIan122", "GreenGoshawk", "GeekyDylan"} I tried calling this I think 'Global' variable at the begining of the code but I got ME 121 attempt to undex ? (a function value)
-- Bootstrapper
term.clear()
term.setTextColor(colors.cyan)
term.setCursorPos(12,4)
print("M.E Defence System")
term.setTextColor(colors.blue)
term.setCursorPos(16 ,7)
print("[Continue]")
os.pullEvent("mouse_click")
term.clear()
term.setCursorPos(15,5)
textutils.slowPrint("Activating")
sleep(1)
local x = 14
while x < 25 do
paintutils.drawPixel(x,7, colors.green)
sleep(0.2)
x = x + 1
end
-- breakInterface Function
function breakInterface()
term.clear()
term.setCursorPos(12,5)
term.setTextColor(colors.white)
write("Defence Operational")
term.setCursorPos(8,7)
write("Code > ")
local code = read()
if code == "Safe" then
term.clear()
term.setCursorPos(10,7)
print("Protection Deactivated")
sleep(1)
os.shutdown()
elseif code == "Vent" then
venting()
elseif code == "List" then
whitelist()
else
term.clear()
term.setCursorPos(10,7)
printError("Command Not Recognised")
sleep(1)
breakInterface()
end
end
-- venting Function
function venting()
term.clear()
term.setCursorPos(12,5)
term.setTextColor(colors.white)
write("Are you sure?")
term.setCursorPos(8,7)
write("[Y/N] > ")
local code = read()
if code == "Y" then
term.clear()
term.setCursorPos(17,5)
textutils.slowPrint("Venting")
for i = 0,4 do
rs.setOutput("back", true)
sleep(0.1)
rs.setOutput("back", false)
sleep(6)
end
term.clear()
term.setCursorPos(1,1)
shell.run("delete ME")
os.shutdown()
elseif code == "N" then
term.clear()
term.setCursorPos(12,5)
textutils.slowPrint("Venting Stopped")
sleep(1)
breakInterface()
else
term.clear()
term.setCursorPos(10,7)
printError("Command Not Recognised")
sleep(1)
venting()
end
end
-- whitelist Fucntion
function whitelist()
term.clear()
term.setCursorPos(2,2)
write("Whitelisted Players [Max 3]")
sleep(1)
whitelist = {"JustIan122", "GreenGoshawk", "GeekyDylan"} -- When it is here it works once then it breaks and when I call List it says ME:54: attempt to call table. Also, when I write Add or Remove it says command not recognized which is untrue.
for i = 1,3 do
term.setCursorPos(2,i+3)
textutils.slowPrint(whitelist[i])
sleep(0.3)
end
term.setCursorPos(2,8)
write("[Add/Remove] > ")
local code = read()
if code == Add then
term.clear()
term.setCursorPos(2,2)
write("Insert Player IGN > ")
local IGN = read()
table.insert(whitelist,"IGN")
elseif code == Remove then
term.clear()
term.setCursorPos(2,2)
write("Whitelisted Players [Max 3]")
sleep(1)
for i = 1,3 do
term.setCursorPos(2,i+3)
textutils.slowPrint(whitelist[i])
sleep(0.3)
end
term.setCursorPos(2,8)
write("Insert Player IGN > ")
local IGN read()
table.remove(whitelist,"IGN")
else
term.clear()
term.setCursorPos(10,7)
printError("Command Not Recognised")
sleep(1)
breakInterface()
end
end
-- Main Loop
breakInterface()
The Main issue happens when I enter the command List I want to be able to add and remove users from the table so I can compare them with the sensor data I have been trying to figure out prior to this.
Also after the loading bar my background is green…….
it was unintentional but I cant seem to get rid of it until the code ends.
Sorry for the inconvenience again…
- Ian