Page 1 of 5

Prototype Lua mod loader

Posted: Sun Mar 04, 2018 11:11 am
by stickthemantis
It's no secret that I'm a fan of Lua modding, and since this game uses Lua, I of course had to take a look at its scripts. The results is this, something to hopefully make modding a little friendlier for other.
To install, unzip the attached file and move the files inside next to the game exe. Inside the mods folder you will put any mod that is compatible with this loader.
The mod loader contains both the loader itself and an API. The API is WIP but its purpose is to abstract some common mod functionality and make compability easier to maintain.

A test mod demonstrating how the mod loader is used can be found here: viewtopic.php?f=25&t=32838

When using mods that add more starting squads, exit the squad selection screen to the main menu and then re-enter squad selection to go to the next page.

Download: https://drive.google.com/open?id=10L98C ... r34wIsCpvo

Re: Prototype Lua mod loader

Posted: Mon Mar 05, 2018 2:31 pm
by tom_gamebanana
Hey this awesome, thank you!

Re: Prototype Lua mod loader

Posted: Mon Mar 05, 2018 4:29 pm
by Auxarch
stickthemantis wrote:Inside the mods folder you will put any mod that is compatible with this loader.

For those in the future who come across this thread:
to clarify how to make a mod compatible with the loader, your mod file structure needs to look like this:
itb/scripts (this is where you'll put the mod loader)
itb/mods (the mods folder goes into the same directory as the itb executable)
itb/mods/custom_mod (this is your named mod folder)
itb/mods/custom_mod/scripts (this is the key part; your scripts need to be wrapped within a 'scripts' folder within your mod directory)
itb/mods/custom_mod/scripts/init.lua (for example)
itb/mods/custom_mod/scripts/pawns.lua

Re: Prototype Lua mod loader

Posted: Tue Mar 06, 2018 9:59 am
by stickthemantis
Update: The API now supports the loading of images with modApi:appendAsset(<resource>,<filePath>) where resource is the path that is added to resource.dat (for example, "img/units/player/mech_punch.png" is the image for the normal Combat Mech) and filePath is the location of the resource you're writing from (so inside your init function you could write this as self.resourcePath.."/img/someFolder/newSprite.png")

Re: Prototype Lua mod loader

Posted: Tue Mar 06, 2018 12:19 pm
by AUTOMATIC
This is cool but generally as a mod author you'd want to specify a directory and have the mod loader process everything inside it recursively.

Re: Prototype Lua mod loader

Posted: Tue Mar 06, 2018 3:50 pm
by AUTOMATIC
Getting an error when starting the game:

https://i.imgur.com/ynAMVxT.png

Think you forgot to comment some code out.

For people strugging with the same error, here is a fix until OP updates his mod:

File ftldat.lua, line 7:
> LOG(stringize(FtlDat))

Remove that line and it should be working.

Re: Prototype Lua mod loader

Posted: Tue Mar 06, 2018 8:59 pm
by stickthemantis
The fixed version has been uploaded, sorry about that. It took a little longer than I wanted to get this update out but on the upside the mod loader is now much more resistant to updates. An update that changes resource.dat won't be overwritten by old backups anymore.

AUTOMATIC, the reason there isn't a way to automatically patch a whole directory is that by default lua doesn't have many operations for working with file systems. The method I use for detecting all the mods in the mods folder is already pretty hacky, I don't think I'm willing to try to make one that works recursively. At least not yet, I might come back to it in the future.

Re: Prototype Lua mod loader

Posted: Tue Mar 06, 2018 10:18 pm
by tom_gamebanana
Any chance you would consider adding web browser integration so the manager can launch out of the browser? We have integrated about 10 mod managers at gamebanana.com which launch from custom protocol handles (eg itbmm://) and pass mod download details to the application (e.g itbmm://[downloadUrl],[name],[author]). It's a huge benefit for fans - makes it more convenient for existing mod users and makes modding available to a huge amount of additional gamers who would normally never install mods (either couldn't be bothered learning how or don't feel competent enough or are scared they'll break something etc...). Would be sweet to have...

GameBanana also has an API you can call to get all kinds of additional info on the mod being installed.

Cheers

Re: Prototype Lua mod loader

Posted: Thu Mar 08, 2018 3:23 pm
by Haven
Hi! Thanks for your work so far. I've been a huge fan of FTL and the amazing mods that have been put out for it, and I'm excited to try my hand at modding (for the first time) with ITB.

I see your sample mod's .lua files seem to contain only additions to existing files; is there a way to replace existing sections of .lua files? I was hoping to get my feet wet by rewriting/expanding the dialogue options in text_population.lua to add a little more variety (since the existing dialogue gets recycled so quickly), but that would seem to necessitate replacing the existing lines. I'm seeing "modApi:overwriteText" in your mod's init.lua file; would I use "PopEvent" (the relevant section in text_population.lua) with that function to specify replacement of the existing dialogue?

Re: Prototype Lua mod loader

Posted: Thu Mar 08, 2018 5:15 pm
by Chrisy15
Haven wrote:Hi! Thanks for your work so far. I've been a huge fan of FTL and the amazing mods that have been put out for it, and I'm excited to try my hand at modding (for the first time) with ITB.

I see your sample mod's .lua files seem to contain only additions to existing files; is there a way to replace existing sections of .lua files? I was hoping to get my feet wet by rewriting/expanding the dialogue options in text_population.lua to add a little more variety (since the existing dialogue gets recycled so quickly), but that would seem to necessitate replacing the existing lines. I'm seeing "modApi:overwriteText" in your mod's init.lua file; would I use "PopEvent" (the relevant section in text_population.lua) with that function to specify replacement of the existing dialogue?


If the example in altered.lua is anything to go by, you should just be able to access the PopEvent table from your file and do something like:

Code: Select all

table.insert(PopEvent["Opening"], "Olook it's some mechs")


to remove you could use something like

Code: Select all

table.remove(PopEvent["Opening"], 2)


which would remove the second item in the list, although ofc you've got no idea if another mod has changed what that second item is...

As such, it might be easier to just start over by redefining the table at PopEvent["Opening"] if you're wanting to rewrite all the text entries.