Code: Select all
require '__SomeOtherMod__/api.lua'
Code: Select all
require '__SomeOtherMod__/api.lua'
It won't allow people to alter the state within another mod, it just allows them to require a file from that mod as if it were in their own mod, in much the same way that prototypes can pull graphics and sounds from other mods.Allowing access to other mods' files may lead to some security issues as everyone can mess with other modder's files.
aubergine18 wrote:It won't allow people to alter the state within another mod, it just allows them to require a file from that mod as if it were in their own mod, in much the same way that prototypes can pull graphics and sounds from other mods.
The remote interface and events would still remain the only way to affect the state of another mod, and even then only if the mod allows it.
For example, in the updated EvoGUI I've been chipping away at, I want to provide an API that lets mods define sensors in a much simpler manner (early draft from a few weeks ago). In this example, things like events are all abstracted away - the mod merely needs to provide the relevant methods and properties when defining the sensor. The 'require'd API takes a sensor definition object, and wires up the events and remote calls, leaving the code of the mod using it much cleaner and more semantic. The sensor mod has no access to the internal state of EvoGUI, it can do things via the API it's pulled in, which in turn just uses remote calls and events, but in no way can the sensor mod go poking around the state of EvoGUI.
Another example is StdLib - currently mod developers have to clone it's scripts in to their own mod... would it not be better if they could simply `require` them fron a published StdLib mod?
Yes, that would be acceptable. I'd prefer the folder to be called `api` to avoid confusion with `remote` interfaces.If we really need this feature, maybe control the accessibility so that we can only read files inside a certain folder, like "remote"? This also matches the encapsulation principle in OOP I guess.
Yes, it's already all based on remote methods (and some events) and anyone who wants to implement things the hard way can still do all the manual leg work rather than using the api.But before we have it, would it be possible to achieve your example with multiple remote methods?
When you consider how many mods have done the same, and how many have duplicated the code and not kept it up to date, it starts to become more apparent why we need the ability to include libraries from mods. I think the real problem here is that the current in-game mod manager is a bit pants when it comes to installing / activating dependencies - once that functionality is improved, it will become much less hassle for players when choosing mods with dependencies.About the StdLib, for now, I have only used one of its string methods (starts_with), so I haven't cloned the entire library. I just copied the method and gave credit in the comment. Rather than having an additional mod and requiring players to download it before playing ours, it would be better that the devs implement the library in their core lib
Sometimes, not keeping it up to date is also an option. I say this because I am using Unity in my company. Although the recent updates (actually, the whole Unity 5 series) have introduced some new features, more bugs appeared, and some of them were so serious that those versions are not usable.When you consider how many mods have done the same, and how many have duplicated the code and not kept it up to date