Jump to content

Standard lua function is undefined in modmain. Possible to change the mods.lua file?


Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...