seperate lua-scripts for mods

Place to get help with not working mods / modding interface.
Post Reply
drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

seperate lua-scripts for mods

Post by drs9999 »

Hello, just a quick question:
Is it possible to execute a lua script in a freeplay without editing the freeplay.lua?

For example the unlimited ammo mod from the mod-manager thread has its own lua file:

Code: Select all

InfiniteAmmoMod = {}
function InfiniteAmmoMod.onTick()
	if game.getplayer().getitemcount("basic-bullet-magazine") < 2 then
		game.getplayer().insert{name="basic-bullet-magazine", count=1}
	end
end
only way i made it working is adding
InfiniteAmmoMod.onTick() in the freeplay.lua

Reason why i ask is that i dont want to change the vanilla files. also if you want to add more than one mod that both changing the freeplay.lua, you have to edit the file by hand so both mods will work correctly.

A solution so far to bypass the vanilla- editing problem i can see is to start a new freeplay, save it and then overwrite the control.lua in the save with the mod script, but that doesnt solve the more then one mod problem.

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: seperate lua-scripts for mods

Post by kovarex »

It is not possible to do it now, but having special lua file for mod that could react to events seems to be natural, so we will add it sooner or later.

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: seperate lua-scripts for mods

Post by drs9999 »

Thanks for the quick answer, i thought that, but nice to hear that you will change that in the future.

Post Reply

Return to “Modding help”