13 posts
Posted 19 December 2012 - 01:12 PM
Okay so this line of code keeps returning a nil error:
shell.run(programname)
My exact error message is:
myapi: 27 : attempt to index ? (a nil value)
Programname is part of an input of a function:
function login(programname, u1, p1)
clearall()
center("Please login to use "..programname, 1)
center("", 3)
write("Username: ")
local u = read()
center("", 5)
write("Password ")
local p = read("*")
sleep(1)
if u == (u1) and p == (p1) then
center("Login successful, please continue.", 7)
sleep(.7)
shell.run(programname) -- this is line 27
else
center("Login unsuccessful, access denied.", &)
shell.run("maingui")
end
end
I need quick help if possible, programname is called in another spot and works, but I don't know how to use it in shell.run..I just want it to boot a program that's name is the input of the function
1214 posts
Location
The Sammich Kingdom
Posted 19 December 2012 - 01:13 PM
The "Ask A Pro" section is for asking questions when you have problems. The "Programs" section is for released code.
997 posts
Location
Wellington, New Zealand
Posted 19 December 2012 - 01:14 PM
Post the whole code of your program and the exact error message.
Also this should be in Ask a Pro, I've reported it to get a moderator's attention so they can move it. (Edit: Ninja'd)
13 posts
Posted 19 December 2012 - 01:15 PM
I'm sorry, I didn't realize, I was in such a rush that I didn't notice, I'll update my post one sec.
3790 posts
Location
Lincoln, Nebraska
Posted 19 December 2012 - 01:21 PM
Mind postign the rest of the code, or at least the function? Kinda hard to troubleshoot with that little amount of info.
13 posts
Posted 19 December 2012 - 01:21 PM
Code was posted.
1214 posts
Location
The Sammich Kingdom
Posted 19 December 2012 - 01:28 PM
Did you use os.loadAPI() or did you just run it? If you use os.loadAPI then the shell functions don't work.
13 posts
Posted 19 December 2012 - 01:29 PM
Did you use os.loadAPI() or did you just run it? If you use os.loadAPI then the shell functions don't work.
I used os.loadAPI because I needed the function to be used in other programs. Is there an easier way of doing this?
1214 posts
Location
The Sammich Kingdom
Posted 19 December 2012 - 01:36 PM
Did you use os.loadAPI() or did you just run it? If you use os.loadAPI then the shell functions don't work.
I used os.loadAPI because I needed the function to be used in other programs. Is there an easier way of doing this?
This is how I do it:
API = {}
API.func = function()
print("test")
end
Then you just run the script. That is how I do it.
13 posts
Posted 19 December 2012 - 01:38 PM
Did you use os.loadAPI() or did you just run it? If you use os.loadAPI then the shell functions don't work.
I used os.loadAPI because I needed the function to be used in other programs. Is there an easier way of doing this?
This is how I do it:
API = {}
API.func = function()
print("test")
end
Then you just run the script. That is how I do it.
Okay but where do I put that and would it just be:
API = {}
API.func = login(programname, u1, p1)
[...]
1214 posts
Location
The Sammich Kingdom
Posted 19 December 2012 - 01:42 PM
Did you use os.loadAPI() or did you just run it? If you use os.loadAPI then the shell functions don't work.
I used os.loadAPI because I needed the function to be used in other programs. Is there an easier way of doing this?
This is how I do it:
API = {}
API.func = function()
print("test")
end
Then you just run the script. That is how I do it.
Okay but where do I put that and would it just be:
API = {}
API.func = login(programname, u1, p1)
[...]
Top of the file will have the APINAME = {} then after that have all your functions.
So like this:
APINAME = {}
APINAME.login = function(pname, u1, p1)
-- Stuffz goes here
end
13 posts
Posted 19 December 2012 - 01:44 PM
Sorry for all the confusion, so after that I can load that API from any program using:
myapi.login(pname, u1, p1)
Correct?
1214 posts
Location
The Sammich Kingdom
Posted 19 December 2012 - 01:45 PM
Sorry for all the confusion, so after that I can load that API from any program using:
myapi.login(pname, u1, p1)
Correct?
Yes, after you run the script that contains the functions.
13 posts
Posted 19 December 2012 - 01:47 PM
Sorry for all the confusion, so after that I can load that API from any program using:
myapi.login(pname, u1, p1)
Correct?
Yes, after you run the script that contains the functions.
Aight thank you for all your help mate! :)/> Cheers!