[ Error ] [ Solved ] Why is my program returning attempt to call nil?
#1
Posted 10 February 2013 - 02:14 PM
multi:80: attempt to call nil
I've tried moving the functions that each function needs above each other.
Example:
drawTitle() function needs the space() & cPrint function to work, so I moved those up to the top of the code so It can use those functions
But I still don't know why I get the attempt to call nil when I try use the Programs Selection.
Pastebin link:
http://pastebin.com/8dNJdrRz
Thanks, AnthonyD98
#2
Posted 10 February 2013 - 02:25 PM
#4
Posted 10 February 2013 - 02:42 PM
Also both need to be below mainOptions
edit: There are also problems with this function... gui is declared below it, and your not modifying the var and numvar variables, you have made them local to that scope (function) so it doesn't change the ones in the program scope
local function drawPrograms() local var = programOptions local numvar = #programOptions gui() end
#5
Posted 10 February 2013 - 02:56 PM
TheOriginalBIT, on 10 February 2013 - 02:42 PM, said:
Also both need to be below mainOptions
edit: There are also problems with this function... gui is declared below it, and your not modifying the var and numvar variables, you have made them local to that scope (function) so it doesn't change the ones in the program scope
local function drawPrograms() local var = programOptions local numvar = #programOptions gui() end
Okay now my code looks like this
http://pastebin.com/FsRXifw0
How do I fix the drawPrograms() function
Every place I put it at, it errors.
#6
Posted 10 February 2013 - 03:09 PM
If I write drawPrograms() in a different program as a global function it works!!
EDIT: Now just need to find out how to make it work within the program as a global function!
#7
Posted 10 February 2013 - 03:17 PM
#8
Posted 10 February 2013 - 03:28 PM
#9
Posted 10 February 2013 - 03:29 PM
#10
Posted 10 February 2013 - 03:39 PM
remiX, on 10 February 2013 - 03:28 PM, said:
If you don't mind could you put that code on pastebin for me?
Doyle3694, on 10 February 2013 - 03:29 PM, said:
I meant have the drawPrograms() function working within the orginal program and not having to be used outside of the program as a global function
#12
Posted 10 February 2013 - 03:54 PM
remiX, on 10 February 2013 - 03:50 PM, said:
I saw you changed the center function slighty. What does the col part of it do?
I also noticed whenever I use a function / selection it prints whats happening
Is that a feature that I can turn off and when needed turn on for debugging purposes?
#13
Posted 10 February 2013 - 04:57 PM
Yeah, was a debug line I used:
print(type(_table[s][2])) sleep(1)
You can delete it
#14
Posted 10 February 2013 - 05:00 PM
remiX, on 10 February 2013 - 04:57 PM, said:
Yeah, was a debug line I used:
print(type(_table[s][2])) sleep(1)
You can delete it
No its fine, I added some tArgs to the beggining of the program.
if you run with -debug the you can see the printing of functions
if you run without the -debug it runs normally.
local tArgs = (...) if tArgs == "-debug" then debug = true else debug = false end
#15
Posted 10 February 2013 - 05:14 PM
local tArgs = ... local debug = (tArgs == "-debug")This can be used because an if statement uses a true false to know what it's to do, so why have an if, to then assign a Boolean... May as well just put the condition in the variable assignment
This is how I normally do it, mind you I normally allow for more args like '-help'
local tArgs = {...}
if #tArgs == 1 then
if tArgs[1] == "-debug" then
debug = true
-- elseif other args checking and such
else
-- print usage
end
elseif #tArgs ~= 0 then -- if they entered something more than 1 arg
-- print usage
end
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











