Forum Mod Bakery Docs

How to Redirect Files using LUA

Posted in Support
Please login to contribute to the conversation.
[deleted user]
8 yrs ago (Statistics)
Hello fellow modder, this tutorial was made due to some tutorials being incomplete!

Do you want to change something to another file that's already in the game, well you're in luck my friend, I'm here to help!

Step 1. Require LuaSupport as a hack

This hack will allow you to use LUA scripts in your mods.

Step.2 Make a Resources folder

this is like what CustomFiles folder is for .mfk files, it is for LUA scripts and their files that go with, and it is also used for your redirections

Step.3 get the mfk.LUA file

CREDIT: Donut Team

This will allow you to make your scripts for missions in LUA format without being .mfk files. Place it in your Resources folder.

Step. 4 use pathhandlers to redirect game files

Say I wanted to change the music in level 1 to level 2's music, just change the path to the music file extracted from the game. Simply make a file located: SOMEMOD/Resources/scripts/handlers/rms.lua
And simply write: Redirect(Resources .. "/sound/music/lY_music.rms") Y being whatever level's music you want.
This tells the game to read the file in the path you choose.

This can be used to change: sound, missions, etc.

Thanks for reading, any things you need cleared up leave a comment!

Thanks for reading,

Step 1
This isn't accurate. You just require CustomFiles and it'll handle requiring LuaSupport.

Step 2
The resources folder is not just for Lua files. Any files being handled with a Path Handler should almost always be in this folder.

Step 3
Lucas and I made that file, not legomariofanatic.

Step 4
If you're not dynamically redirecting anything doing it with a path handler is completely unnecessary. You can just add this to CustomFiles.ini:


Also you're using a variable named Resources in that example and you're not explaining how to define that variable at any point. It is not apart of LuaSupport by default.
The thing about the mfk.lua file is that is was created by the Donut Team. (I did link a download to it in one of my tutorials, but I did give credit to Donut Team for creating that file.)

Also, that tutorial that I put it in is the only place where you can get that file. You may want to include it on the Downloads page, Loren. It'll greatly help others.
May I ask what is the actual advantage of using LUA
Currently you can do things like randomizing missions or using settings to handle just about anything like how several mods on this forum have a difficulty setting that causes missions to have different timers and other things depending on the difficulty.

In the future you'll be able to do a lot more with it, more on that in the future.
[deleted user]
8 yrs ago (Statistics)
sorry, I thought I would try my hand at tutorials based on what I learned from recompiling some mods due to my inexperience. Well thanks for correcting me Lauren, you seem to help me alot! Sorry for the waste of forum space...

It's all good dude. We were inexperienced at one point too. We still learn new things everyday about this game.