Prototype Lua mod loader

Discuss and distribute tools and methods for modding.
User avatar
stickthemantis
Posts: 37
Joined: Wed Jan 29, 2014 4:16 pm

Prototype Lua mod loader

Postby stickthemantis » Sun Mar 04, 2018 11:11 am

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
Last edited by stickthemantis on Mon Mar 26, 2018 6:49 pm, edited 6 times in total.
I'm Cyberboy2000, known as a modder and community leader of Invisible Inc.
I'm using this old account because I've been unable to get any verification email for a new account. Help with changing my name would be appreciated.
tom_gamebanana
Posts: 3
Joined: Mon Mar 05, 2018 3:23 am

Re: Prototype Lua mod loader

Postby tom_gamebanana » Mon Mar 05, 2018 2:31 pm

Hey this awesome, thank you!
Auxarch
Posts: 7
Joined: Mon Mar 05, 2018 3:56 pm

Re: Prototype Lua mod loader

Postby Auxarch » Mon Mar 05, 2018 4:29 pm

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
User avatar
stickthemantis
Posts: 37
Joined: Wed Jan 29, 2014 4:16 pm

Re: Prototype Lua mod loader

Postby stickthemantis » Tue Mar 06, 2018 9:59 am

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")
I'm Cyberboy2000, known as a modder and community leader of Invisible Inc.
I'm using this old account because I've been unable to get any verification email for a new account. Help with changing my name would be appreciated.
AUTOMATIC
Posts: 24
Joined: Sun Mar 04, 2018 11:59 am

Re: Prototype Lua mod loader

Postby AUTOMATIC » Tue Mar 06, 2018 12:19 pm

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.
AUTOMATIC
Posts: 24
Joined: Sun Mar 04, 2018 11:59 am

Re: Prototype Lua mod loader

Postby AUTOMATIC » Tue Mar 06, 2018 3:50 pm

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.
User avatar
stickthemantis
Posts: 37
Joined: Wed Jan 29, 2014 4:16 pm

Re: Prototype Lua mod loader

Postby stickthemantis » Tue Mar 06, 2018 8:59 pm

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.
I'm Cyberboy2000, known as a modder and community leader of Invisible Inc.
I'm using this old account because I've been unable to get any verification email for a new account. Help with changing my name would be appreciated.
tom_gamebanana
Posts: 3
Joined: Mon Mar 05, 2018 3:23 am

Re: Prototype Lua mod loader

Postby tom_gamebanana » Tue Mar 06, 2018 10:18 pm

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
Haven
Posts: 4
Joined: Thu Mar 08, 2018 2:37 am

Re: Prototype Lua mod loader

Postby Haven » Thu Mar 08, 2018 3:23 pm

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?
User avatar
Chrisy15
Posts: 7
Joined: Sun Mar 04, 2018 5:07 pm

Re: Prototype Lua mod loader

Postby Chrisy15 » Thu Mar 08, 2018 5:15 pm

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.
Civ V and VI modder enticed by the idea of giant mech suits suplexing giant insects into each other's paths.

Where the Korean Flower roams, it seems Lua follows...
...no sign of a database yet though...

Who is online

Users browsing this forum: No registered users and 5 guests