Intro
As a modder, I restart game a lot of times and packing lua files back takes away my free time. That's why I had to make a loader, which reads lua scripts situated outside *.dat archives. It also is capable of binding functions used in external lua files to key combinations. Keys can be defined in a separate config file, stored outside of archives as well. The only thing you'll ever need to pack is the loader itself (and assets if you use them in your mod).
Installation
Manual
- Place all lua files from here
into 00.dat,
/Assets/tpp/script/lib/
- drop it there.
GzsTool:
Add
to your 00.dat.xml<Entry FilePath="/Assets/tpp/script/lib/script_loader.lua" Compressed="false" /> <Entry FilePath="/Assets/tpp/script/lib/helpers.lua" Compressed="false" /> <Entry FilePath="/Assets/tpp/script/lib/json.lua" Compressed="false" />
MGS_QAR_TOOL:
Add
to your 00.inf.18e34bb1306b261b|00\Assets\tpp\script\lib\script_loader.lua key=0 version=0 compressed=0 18e29a375a6fa972|00\Assets\tpp\script\lib\helpers.lua key=0 version=0 compressed=0 18e2a6153e1da644|00\Assets\tpp\script\lib\json.lua key=0 version=0 compressed=0
- Open
00\Assets\tpp\script\lib\Tpp.lua
and find"/Assets/tpp/script/lib/TppMbFreeDemo.lua"
. Add after it:
(yes, with a comma)., "/Assets/tpp/script/lib/scriptloader.lua"
- Open
00\Assets\tpp\script\lib\TppMain.lua
and find"TppMission.UpdateForMissionLoad"
. Add after it:
(with comma as well).,DropWeapon.Update
- Pack your 00.dat.
- Create folder 'lua' in your game directory (
SteamApps\common\MGS_TPP\lua
) and put script_loader.json there (config file).
Snakebite
- Install script_loader.mgsv using Snakebite (script_loader_IH.mgsv - Infinite Heaven compatible version)
- Create folder 'lua' in your game directory (
SteamApps\common\MGS_TPP\lua
) and put script_loader.json there.
Usage
Hold ZOOM+ACTION
(V+E) to bind functions to keys, then hold ZOOM+_your_key
to call your function.
Script loader will look for your lua files in different directories
(listed in LUA variable _G['package']['path']
), I use main game
directory (SteamApps\common\MGS_TPP\lua). You will need to create 'lua' folder
there and put your scripts there along with provided config.
An example script is included.
Every time you bind functions to keys, script loader reloads all modules listed in config file, so it is perfect for debugging your awesome mod. No game restart, no packing, no loading.
It also announces typical errors in your code (ie division by zero, wrong syntax or stuff like that) - just like regular interpreter does. It won't catch errors from MGSV functions though, so don't expect much.
Everyting you call can be logged in MGS_TPP\log.txt
file.
Add local helpers = require("helpers")
,
then
use helpers.log(str, announce, level)
in your code to put log messages into the log, no more waiting for slow terminal output.You will need to create that file by yourself.
Config file
Config is written in json because it allows me to use nested arrays. Not a fan of INI and YAML looks uncomfortable.
Structure:
keys
- array of bindable keys-
_key_
- key as represented in the game, see link for all key names. Example:PlayerPad.UP
module
- name of your imported lua module. Example:example_script
function
- function which will be called after holdingZOOM+_key_
. Example:test
config
- loader's configplay_sound
- true/false, if set to true, plays a clacking terminal sound when you execute your function
Hold ZOOM+ACTION
(V+E) to bind functions to keys listed in config file.
Binding more keys
Just add a new entry into keys
section based on example above then hold ZOOM+ACTION
to apply changes.
Important note: functions with arguments have to be wrapped into a wrapper function without arguments. Example: your function do_awesome_stuff(1,2,3)
has to be wrapped in another function do_something()
, which will be referenced in config.