Posted 04 July 2014 - 12:29 AM
I was trying out a notebook script I found earlier on the tekkit classic wiki (http://tekkitclassic.wikia.com/wiki/Tutorial/Notebook) and i've got it to open the first page. But when I type the numbers on the front page, I get these errors:
"1" - notebook:13: attempt to call nil
"2" - notebook:22: attempt to call nil
"3" - notebook:39: attempt to call nil
Here is the code I imputed:
done = false
print("Welcome to Notebook")
print("1. Read file")
print("2. Write file")
print("3. List documents")
print("4. Exit program") – Press any of these numbers to activate that function
while true do
event, key = os.pullEvent("char")
if key == "1" then
clear()
print("Which file do you want to read?")
sFile = read()
print("Standby, opening file")
sleep(1)
print(file.read("notes/"..sFile, "a")) – This is our API, remember?
return
elseif key == "2" then
clear()
print("What do you want to name the file? (No spaces)")
sFile = read()
print("Standby, opening file")
sleep(1)
clear()
print("Type exit() to quit editing document")
repeat
input = read()
if input == "exit()" then
done = true
else
file.write("notes/"..sFile, "w", input)– This is also our api
end
until done – Keep looping until the input is "exit()"
elseif key == "3" then
clear()
shell.run("list", "notes")
return
elseif key == "4" then
return
end
end
Any help would be Great. Thanks!
"1" - notebook:13: attempt to call nil
"2" - notebook:22: attempt to call nil
"3" - notebook:39: attempt to call nil
Here is the code I imputed:
done = false
print("Welcome to Notebook")
print("1. Read file")
print("2. Write file")
print("3. List documents")
print("4. Exit program") – Press any of these numbers to activate that function
while true do
event, key = os.pullEvent("char")
if key == "1" then
clear()
print("Which file do you want to read?")
sFile = read()
print("Standby, opening file")
sleep(1)
print(file.read("notes/"..sFile, "a")) – This is our API, remember?
return
elseif key == "2" then
clear()
print("What do you want to name the file? (No spaces)")
sFile = read()
print("Standby, opening file")
sleep(1)
clear()
print("Type exit() to quit editing document")
repeat
input = read()
if input == "exit()" then
done = true
else
file.write("notes/"..sFile, "w", input)– This is also our api
end
until done – Keep looping until the input is "exit()"
elseif key == "3" then
clear()
shell.run("list", "notes")
return
elseif key == "4" then
return
end
end
Any help would be Great. Thanks!