Posted 13 November 2013 - 02:46 PM
Okay so in essence I am making a program that will open a door by emitting a redstone pulse. Now I am using a config file called: ".uLockConf". Before you so anything the config is working and then API is correct. I keep getting an error saying:
Now i don't understand this cause the actual program works fine, until I enter the password and hit enter, it gets to emitting the signal but then errors, now i thought it was probably something to do with the sleep() function as I am using:
but another coder has done the same and it works :S so yeah I am a bit stuck! Anyway here is the program code:
and here is the finished config file (AN EXAMPLE):
Please help! Thanks
BIOS:132: Expected Number
Now i don't understand this cause the actual program works fine, until I enter the password and hit enter, it gets to emitting the signal but then errors, now i thought it was probably something to do with the sleep() function as I am using:
sleep(config.redPulse)
but another coder has done the same and it works :S so yeah I am a bit stuck! Anyway here is the program code:
-- Simple Door Lock
-- Created by DannySMc
-- Version 1.1
-- Platform: Lua Virtual Machine
-- Security Method
oldEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
-- Check for API
if fs.exists("uapi") == false then
print("Missing uAPI!")
print("Attempting to download..")
getGit = http.get("https://raw.github.com/dannysmc95/uprograms/master/uapi")
getGit = getGit.readAll()
file = fs.open("uapi", "w")
file.write(getGit)
file.close()
print("Done!")
sleep(0.5)
end
os.loadAPI("uapi")
-- Installer for Configuration File
if fs.exists(".uLockConf") == false then
uapi.cs()
print("Running Installer...")
sleep(0.5)
term.setCursorPos(1,3)
term.write("Redstone output side: ")
strSide = read()
term.setCursorPos(1,5)
term.write("Redstone pulse time: ")
strPulse = read()
term.setCursorPos(1,7)
term.write("Terminal Label: ")
strName = read()
term.setCursorPos(1,9)
term.write("Password for unlock: ")
strPassword = read("*")
term.setCursorPos(1,11)
print("What is the name this program is saved as?")
term.setCursorPos(1,12)
term.write("Program Name: ")
strProgName = read()
-- Create Configuration File
uapi.saveConfig({['progName']=strProgName, ['terminalName']=strName, ['redSide']=strSide, ['redPulse']=strPulse, ['lockPassword']=strPassword}, ".uLockConf")
-- Startup File
term.setCursorPos(1,14)
print("Do you wish to create a startup file?")
term.setCursorPos(1,15)
repeat
term.write("YES/NO: ")
startupAnswer = read()
until ((startupAnswer == "YES") or (startupAnswer == "NO"))
if startupAnswer == "YES" then
startFile = fs.open("startup", "w")
startFile.writeLine('os.loadAPI("uapi")')
startFile.writeLine('config = uapi.loadConfig(".uLockConf")')
startFile.writeLine("shell.run(config.progName)")
startFile.close()
print("Install Complete!")
sleep(0.5)
else
print("Install Complete!")
sleep(0.5)
end
print("Rebooting the terminal...")
sleep(1)
os.reboot()
end
-- Load Configuration File
config = uapi.loadConfig(".uLockConf")
-- Password Lock Program
uapi.cs()
uapi.setCol("white", "blue")
print(" ")
print(" ")
uapi.printC(config.terminalName, 2, false, "white", "blue")
print(" ")
print(" ")
uapi.resetCol()
term.setCursorPos(1,19)
uapi.setCol("white", "blue")
print(" Password Lock -> Created By DannySMc -> Ver: 1.21 ")
uapi.resetCol()
term.setCursorPos(1,8)
repeat
term.write("Password: ")
password = read("*")
until((password == config.lockPassword))
if password == config.lockPassword then
term.setCursorPos(1,10)
print("Password Correct!")
rs.setOutput(config.redSide, true)
sleep(config.redPulse)
rs.setOutput(config.redSide, false)
sleep(0.5)
os.reboot()
else
term.setCursorPos(1,10)
print("Password Incorrect!")
sleep(1.5)
os.reboot()
end
and here is the finished config file (AN EXAMPLE):
{["terminalName"]="Danny tester",["lockPassword"]="testing",["redSide"]="back",["progName"]="lock",["redPulse"]="5",}
Please help! Thanks
Edited on 13 November 2013 - 02:19 PM