Jump to content

Simple trick to make mods load first or last just before any event triggers.


jianmingyong

Recommended Posts

I expected some mods that have global tables and worried that it loads in the wrong order. Fear not. You can always trick the game to load first or last depending on the file name.

 

There are mods that prepend numbers to be first. Obviously nobody would try to outsmart your idea and that's fine by any means.

 

From the ascii chart:

! is the first printable and valid file name.

~ is the last printable and valid file name (excluding other chars that aren't on keyboard).

 

The more you append the specific char, the more you guarantee that it always load first/last!

 

Nested folder will also have the same effect but the order remains as:

 

shared/<files>

shared/<folders>

 

client/<files>

client/<folders>

 

server/<files>

server/<folders>

 

Now with this idea, let say you want to call something before anyone overrides it, you can now name your file "!MyModule.lua" to avoid that trouble.

 

If you need to ensure it is first, prepend more "!!!MyModules.lua" and it will be first no matter what.

Link to comment
Share on other sites

IMO, this should only really be used when defining global tables and functions, so other mods have access to those and can intentionally override them if needed (generally for compatibility reasons).

Any code that actually runs as the file is loaded should be delayed using normal file names, unless the whole purpose of that code is to insert values into those global tables. 

ORGM v3.00 is using a very similar method to ensure all mods have access to the ORGM global table (and subtables), and delaying its overwrites as long as possible.

Another point of note is different OS's have different valid characters allowed in filenames and directories. IE: linux vs windows. Linux is much more permissive on characters, and allows creating filenames that windows simply fails when trying to open. If using special characters to prefix file/folder names, a windows filesystem should be assumed as the majority of users will probably be using that.

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
×
×
  • Create New...