"require" is one of the most commonly used functions in lua.
It's like #include in C.
However, it appears that if you want to see a map script in the world builder or Civ V proper, it must not contain, at the time that the list of possible scripts is created, the line
require "math".
Possibly true of other packages too.
If you delete that line and add it later, it works fine (the scripts are parsed again when you change them).
But you can't use require.
You can, however, use include instead, which is a nonstandard and unknown method that probably does the same thing.
I suppose that, maybe for some weird reason, at the moment the script files are scanned, they are loaded, and at that time the lua runtime isn't totally set up so that require "math" doesn't work. Why didn't they replace _G["require"] with their own include function so that this issue wouldn't be seen by the end user I have no idea.
So be warned. If you're used to lua, don't use "require" when scripting lua for CivV, it will make your script unavailable.
You can probably work around it... If the script is loaded after the launch screens, it might even work.
Overall, this is a very good way to cause people to lose a few hours, thank you Firaxis.
It's like #include in C.
However, it appears that if you want to see a map script in the world builder or Civ V proper, it must not contain, at the time that the list of possible scripts is created, the line
require "math".
Possibly true of other packages too.
If you delete that line and add it later, it works fine (the scripts are parsed again when you change them).
But you can't use require.
You can, however, use include instead, which is a nonstandard and unknown method that probably does the same thing.
I suppose that, maybe for some weird reason, at the moment the script files are scanned, they are loaded, and at that time the lua runtime isn't totally set up so that require "math" doesn't work. Why didn't they replace _G["require"] with their own include function so that this issue wouldn't be seen by the end user I have no idea.
So be warned. If you're used to lua, don't use "require" when scripting lua for CivV, it will make your script unavailable.
You can probably work around it... If the script is loaded after the launch screens, it might even work.
Overall, this is a very good way to cause people to lose a few hours, thank you Firaxis.