least18 Posted November 2, 2018 Share Posted November 2, 2018 Hello, I am trying to use lua's next() function to check whether a table is empty, but I get the "attempt to call global 'next' (a nil value)" error. I've looked through some other lua files and next() is used all over the place, but it doesn't work in the modmain. I think this is because next() is not defined for the environment created in the mods.lua file. As a test, I edited the mods.lua file directly and defined 'next' in the CreateEnvironment function, which fixed my error. Changing files directly is obviously bad practice, so I am wondering if it is possible to update the mods.lua file from within my mod, or if I should pursue some alternate solution. I have tried placing an edited mods.lua file in the scripts folder of my mod, and then I require() it from the modmain, but that didn't work out. Could anyone provide any insight on this? Link to comment Share on other sites More sharing options...
Developer bizziboi Posted November 2, 2018 Developer Share Posted November 2, 2018 Does GLOBAL.next work? Link to comment Share on other sites More sharing options...
least18 Posted November 3, 2018 Author Share Posted November 3, 2018 It does work! I thought I had tried that already, but I guess I must have done something wrong the first time. Thanks for the help!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now