The development wiki suggests using a /data folder in the addon root to store new classes and/or raw data files. How do I then access those files from another?
I've got a helper class in /data/myclass.lua I'm trying to require into my /hooks/load.lua, but no matter what I put it tells me that this file is not found.
Is "require" the wrong keyword? Is there some sort of unix-like ../ equivalent I'm missing?
Dum Question: Using the Data folder
Moderator: Moderator
Dum Question: Using the Data folder
Currently developing the Player AI addon. You can get it from the T-Engine Addon Hub or Steam
You can also view the source code.
You can also view the source code.
-
- Sher'Tul Godslayer
- Posts: 2521
- Joined: Thu Jan 23, 2003 8:13 pm
- Location: A shallow water area south of Bree
- Contact:
Re: Dum Question: Using the Data folder
Files in an addon's data/ folder are visible to the engine by the name "/data-<short_name>/path/to/filename", where <short_name> is as defined in your init.lua. data/ is just for data, though (hence the name); for new classes, you probably want overload/. So for instance, you might have overload/mod/class/MyClass.lua, and you would access that from other code via e.g.:Charidan wrote:The development wiki suggests using a /data folder in the addon root to store new classes and/or raw data files. How do I then access those files from another?
I've got a helper class in /data/myclass.lua I'm trying to require into my /hooks/load.lua, but no matter what I put it tells me that this file is not found.
Is "require" the wrong keyword? Is there some sort of unix-like ../ equivalent I'm missing?
Code: Select all
local MyClass = require 'mod.class.MyClass'
"Blessed are the yeeks, for they shall inherit Arda..."
Re: Dum Question: Using the Data folder
Ah, I knew I needed to put the addon-name in there somewhere, but I didn't try hyphenating it.
That said, good call on using an overload instead. I wasn't sure you could overload a file that didn't exist, but I should have just tried it.
That said, good call on using an overload instead. I wasn't sure you could overload a file that didn't exist, but I should have just tried it.
Currently developing the Player AI addon. You can get it from the T-Engine Addon Hub or Steam
You can also view the source code.
You can also view the source code.