Calling my mod from another mod?

Place to get help with not working mods / modding interface.
blah900
Burner Inserter
Burner Inserter
Posts: 7
Joined: Sat May 31, 2014 12:42 am
Contact:

Calling my mod from another mod?

Post by blah900 »

Hi all, I am currently working on a mod called EndlessWaltz that basically implements tower defense features to the game.
http://i.imgur.com/OVWjCus.jpg (The wave didn't start yet so I went hunting for units with grenades to test if the kills were being counted properly.)

Being the lazy guy I am, I doubt I will actually go into creating more units/items. However I would like to make this mod available for other people to be able to hook into if they wish.

What would be the best way of doing this? From having interacted with the story elements in the campaign and trying to mix it together with this, I've come across some problems whereby any mod that registers any onevent can overwrrite my lua code. Is there a way to protect my function from being overwritten?

Also I have a few functions where the users can pass in their own arguments to set what units spawn, how much reward point(in progress) is rertrieved, what items can be bought with, how much points each type gives, etc. Is there a way user can call my functions from their mod?

Thanks in advance!
blah900
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Calling my mod from another mod?

Post by FreeER »

blah900 wrote:Is there a way user can call my functions from their mod?
Yes, all you do is provide a script interface, which basically means wrap the functions that you want other mods to be able to call in

Code: Select all

remote.addinterface("interface_name_typically_mod_name", {
--functions here (in "name = function(args) --code end" format) seperated by ','s
})
as described on the wiki here. Of course doing so would mean that you have to change how you call those functions within your own code, or you could instead provide 'proxy' functions within the interface that call those functions (you wouldn't have to change your function calls and it might make it easier to change the functions later without breaking mods that use that interface).
blah900 wrote:I've come across some problems whereby any mod that registers any onevent can overwrrite my lua code.
Really? They shouldn't be able to overwrite it, they are simply able to run their own code 'simultaneously' (wow, I spelled that properly the first time!), while they might be able to overwrite a change that your function performed they are not actually overwriting your function, there is a slight difference :) An example of what you meant might be a little more helpful here, but honestly I'm not sure you could prevent that...
Post Reply

Return to “Modding help”