Posted 26 October 2013 - 02:03 AM
Title: attempt to call nil irregularity
This was intended for the "ask a pro" section, but I can't post any new topics yet.
I have a program I'm writing that is a menu of different functions to build and mine resources as needed, and I'm experiencing a strange issue.
I'm not sure the best way to ask this question, so I'll just jump right in; My menu system has a variable named work, and certain menu items set this to be a specific function (such as "buildHut" which builds a 7x7x5 hut). Once a function has been assigned to "work", it gets called and the function runs.
This is working as expected for the most part. But the strange thing is that if I run my program and select an option it invariably fails with error "attempt to call nil". Rerun the program and select the same option and it runs perfectly.
So… why would selecting the same option in the program twice result in two different outcomes?
Here's the code if anyone wants to play around with it. Currently the only working menu choices are buildHut (Buildings > Hut > Build Hut > Yes) and tunnel (Resource gathering > Mining > Tunnel > Yes)
http://pastebin.com/rc7zadub
Any insight or suggestions would be appreciated. Thanks in advance!
This was intended for the "ask a pro" section, but I can't post any new topics yet.
I have a program I'm writing that is a menu of different functions to build and mine resources as needed, and I'm experiencing a strange issue.
I'm not sure the best way to ask this question, so I'll just jump right in; My menu system has a variable named work, and certain menu items set this to be a specific function (such as "buildHut" which builds a 7x7x5 hut). Once a function has been assigned to "work", it gets called and the function runs.
This is working as expected for the most part. But the strange thing is that if I run my program and select an option it invariably fails with error "attempt to call nil". Rerun the program and select the same option and it runs perfectly.
So… why would selecting the same option in the program twice result in two different outcomes?
Here's the code if anyone wants to play around with it. Currently the only working menu choices are buildHut (Buildings > Hut > Build Hut > Yes) and tunnel (Resource gathering > Mining > Tunnel > Yes)
http://pastebin.com/rc7zadub
Any insight or suggestions would be appreciated. Thanks in advance!