This resource is a Lua script that makes it easy to script levels and missions in Custom Files Lua Path Handler scripts by obscuring the calls to the Output Lua function available in Custom Files Lua path handler scripts.
This script is available from the Donut Team downloads page.
Simply place the script somewhere in your mod's "Resources" folder and load it in
dofile(GetModPath() .. "/Resources/scripts/game.lua")
Then you can add a
[PathHandlers] entry for any MFK script and write scripts in more or less the same way with some notable differences:
- All commands must be prefixed with
Game.since the script stores them in a table called
Gamefor organizational reasons.
- You don't need to have
;after function calls because Lua doesn't require them (though it doesn't hurt to have them).
- Unlike MFK, strings must always be in quotes.
- This is notable because Radical omits quotes in a few places as their basic scripting didn't require it.
\must be escaped with another backslash like
Here's some example comparisons of one of Radical's function calls and how it would look in Lua:
// Radical often didn't use quotes on their locator names for this command.
GagSetTrigger("action", JasperTrig, 2);
-- So you would need to add them for Lua.
Game.GagSetTrigger("action", "JasperTrig", 2)
Now here's a full example of a path handler script:
Game.SelectMission("m0") Game.SetMissionResetPlayerInCar("level1_carstart") Game.SetDynaLoadData("l1z1.p3d;l1r1.p3d;l1r7.p3d;") Game.UsePedGroup(0) Game.AddStage(1) Game.RESET_TO_HERE() Game.SetHUDIcon("kwike") Game.SetStageMessageIndex(131) Game.AddObjective("dummy") Game.CloseObjective() Game.CloseStage() Game.CloseMission()
The script has two local functions
AddCommands once with a table containing the names of all of Radical's script commands.
It also calls it a second time if the Additional Script Functionality hack is loaded with a table containing the names of all of the hack's commands.
AddCommands function loops through all of the names and registers a function for each one inside a table named
This is done for organizational reasons as flooding the global table with 250-300 functions would be messy.
The registered functions call
OutputCommand with the given function name and any arguments given to it. This function then assembles a string of the command call and then calls Output to write it to the virtual script.
This script was created by Donut Team.
July 28th, 2019