Kann mir jemand helfen. Ich arbeite das erste mal mit LUA. Möchte ein Programm machen für ein kleines Labor. Allerdings bekomme ich Probleme wenn ich die Funktionen aufrufen will. Es kommt immer: attempt to call nil! Hier das Programm. Das 2. funktionerte. Wollte es dann aber erweitern.
while true do
term.clear()
term.setCursorPos(1, 1)
print("Laboratory Lock-Version 1.0")
print""
sleep(0.5)
print("Welcome to the Security Login!")
print""
print""
sleep(0.5)
login()
end
function elevator()
if not hermeticStat then
rs.setBundledOutput("back", colors.black)
sleep(8)
sleep(2)
rs.setBundledOutput("back", colors.white)
sleep(8)
return
end
end
function button()
local callStat = redstone.testBundledInput ("back", colors.blue, true)
if callStat and loginStat then
shell.run("clear")
print("Elevator called")
sleep(2)
end
end
function hermetic()
local hermeticStat = redstone.testBundledInput("back", colors.red, true)
if hermeticStat then
shell.run("clear")
print("Hermetically sealed")
print""
print("Access System Locked")
end
end
while true do
term.clear()
term.setCursorPos(1, 1)
0
while true do
term.clear()
term.setCursorPos(1, 1)
print("Laboratory Lock-Version 1.0")
print""
sleep(0.5)
print("Welcome to the Security Login!")
print""
print""
sleep(0.5)
login()
end
function login()
local loginStat = false
usertable = {Admin="1942", Dexter="1942", BlackFox="0000",Sapphire="0000", Rotfuchs="0000", Raze="0000", Franky="0000", BlackDragon="0000"}
key = 1234
textutils.slowPrint ("...............", 9)
print("Username: ") term.setCursorPos(11, 6) username = read()
print("Access Code: ") term.setCursorPos(14, 7) code = read("*")
print("Security Key: ") term.setCursorPos(15, 8) key = read("*")
if usertable[username] == code and key then
loginStat = true
print""
print("Access Granted!")
sleep(1)
print""
print("Welcome "..username)
sleep(1)
print""
print("Enter Laboratory in..")
sleep(1)
print("----- 5 -----")
sleep(1)
print("----- 4 -----")
sleep(1)
print("----- 3 -----")
sleep(1)
print("----- 2 -----")
sleep(1)
print("----- 1 -----")
sleep(1)
shell.run("clear")
elevator()
else
print("Access Denied!")
rs.setBundledOutput("back", colors.orange) --Noteblock
sleep(1)
rs.setBundledOutput("back", colors.orange) --Noteblock
sleep(2)
return login()
end
end
function elevator()
if not hermeticStat then
rs.setBundledOutput("back", colors.black)
sleep(8)
sleep(2)
rs.setBundledOutput("back", colors.white)
sleep(8)
return
end
end
function button()
local callStat = redstone.testBundledInput ("back", colors.blue, true)
if callStat and loginStat then
shell.run("clear")
print("Elevator called")
sleep(2)
end
end
function hermetic()
local hermeticStat = redstone.testBundledInput("back", colors.red, true)
if hermeticStat then
shell.run("clear")
print("Hermetically sealed")
print""
print("Access System Locked")
end
end
while true do
term.clear()
term.setCursorPos(1, 1)
print("Laboratory Lock-Version 1.0")
print""
sleep(0.5)
print("Welcome to the Security Login!")
print""
print""
sleep(0.5)
usertable = {Dexter="1942", BlackFox="0815",Sapphire="nix", Rotfuchs="0000", Raze="0000", Franky="0000", BlackDragon="0000"}
securitykey = 2012
print("Username: ") term.setCursorPos(11, 6)
username = read()
print("Access Code: ") term.setCursorPos(14, 7)
code = read("*")
print("Security Key: ") term.setCursorPos(15, 8)
key = read("*")
if usertable[username] == code and key then
print""
print("Access Granted!")
sleep(1)
print""
print("Welcome "..username)
sleep(1)
print""
print("Enter Laboratory in..")
sleep(1)
print("5")
sleep(1)
print("4")
sleep(1)
print("3")
sleep(1)
print("2")
sleep(1)
print("1")
sleep(1)
rs.setBundledOutput("back", colors.black)
sleep(8)
rs.setBundledOutput("back", colors.black)
sleep(3)
rs.setBundledOutput("back", colors.white)
sleep(8)
rs.setBundledOutput("back", colors.white)
os.shutdown()
else
print("Access Denied!")
rs.setBundledOutput("back", colors.orange)
sleep(1)
rs.setBundledOutput("back", colors.orange)
sleep(2)
os.reboot()
end
end
0