-
Notifications
You must be signed in to change notification settings - Fork 2
/
loader.html
136 lines (120 loc) · 7.7 KB
/
loader.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="description" content="Metal Gear Solid V: The Phantom Pain technical information : ">
<link rel="stylesheet" type="text/css" media="screen" href="stylesheets/stylesheet.css">
<title>Metal Gear Solid V: The Phantom Pain technical information</title>
</head>
<body>
<!-- HEADER -->
<div id="header_wrap" class="outer">
<header class="inner">
<a id="forkme_banner" href="https://github.com/unknown321/mgsv_research">View on GitHub</a>
<h1 id="project_title">Metal Gear Solid V: The Phantom Pain technical information</h1>
<h2 id="project_tagline"></h2>
</header>
</div>
<!-- MAIN CONTENT -->
<div id="main_content_wrap" class="outer">
<section id="main_content" class="inner">
<h3>Intro</h3>
<p>
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).
</p>
<h3>Installation</h3>
<h4>Manual</h4>
<ul>
<li>Place <a href='https://github.com/unknown321/mgsv_research/tree/gh-pages/mods/script_loader'>all lua files from here</a>
into 00.dat, <code>/Assets/tpp/script/lib/</code> - drop it there.
<br><u>GzsTool</u>:<br>
Add <pre><code><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" /></code></pre> to your 00.dat.xml
<hr>
<br><u>MGS_QAR_TOOL</u>:<br>
Add <pre><code>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</code></pre> to your 00.inf.
</li>
<li>Open <code>00\Assets\tpp\script\lib\Tpp.lua</code> and find<br><code>"/Assets/tpp/script/lib/TppMbFreeDemo.lua"</code>. Add after it: <pre><code>, "/Assets/tpp/script/lib/scriptloader.lua"</code></pre> (yes, with a comma).</li>
<li>Open <code>00\Assets\tpp\script\lib\TppMain.lua</code> and find<br><code>"TppMission.UpdateForMissionLoad"</code>. Add after it:<pre><code>,DropWeapon.Update</code></pre> (with comma as well).</li>
<li>Pack your 00.dat.</li>
<li>Create folder 'lua' in your game directory (<code>SteamApps\common\MGS_TPP\lua</code>) and put <a href='https://github.com/unknown321/mgsv_research/tree/gh-pages/mods/script_loader/config/script_loader.json'>script_loader.json</a> there (config file).</li>
</ul>
<h4>Snakebite</h4>
<ul>
<li>Install <a href='https://unknown321.github.io/mgsv_research/mods/script_loader/snakebite_builds/script_loader.mgsv'>script_loader.mgsv</a> using Snakebite (<a href='https://unknown321.github.io/mgsv_research/mods/script_loader/snakebite_builds/script_loader_IH.mgsv'>script_loader_IH.mgsv</a> - Infinite Heaven compatible version)</li>
<li>Create folder 'lua' in your game directory (<code>SteamApps\common\MGS_TPP\lua</code>) and put
<a href='https://github.com/unknown321/mgsv_research/tree/gh-pages/mods/script_loader/config/script_loader.json'>script_loader.json</a> there.</li>
</ul>
<h3>Usage</h3>
<p>
Hold <code>ZOOM+ACTION</code> (V+E) to bind functions to keys, then hold <code>ZOOM+_your_key</code> to call your function.<br>
Script loader will look for your lua files in different directories
(listed in LUA variable <code>_G['package']['path']</code>), 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 <a href="https://github.com/unknown321/mgsv_research/tree/gh-pages/mods/script_loader/example/example_mod.lua">example script</a> is included.
</p>
<p>
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.
</p>
<p>
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.
</p>
<p>
Everyting you call can be logged in <code>MGS_TPP\log.txt</code> file. <br>Add <code>local helpers = require("helpers")</code>,
then <br>use <code>helpers.log(str, announce, level)</code>
in your code to put log messages into the log, no more waiting for slow terminal output.<b>You will need to create that file by yourself.</b>
</p>
<h4>Config file</h4>
<p>
Config is written in json because it allows me to use nested arrays.
Not a fan of INI and YAML looks uncomfortable.
</p>
<p>
Structure:
<ul>
<li><code>keys</code> - array of bindable keys</li>
<ul>
<li>
<code>_key_</code> - key as represented in the game, see
<a href="https://wiki.nexusmods.com/index.php/Input_handling">link</a> for all key names. Example: <code>PlayerPad.UP</code>
</li>
<ul>
<li><code>module</code> - name of your imported lua module. Example: <code>example_script</code></li>
<li><code>function</code> - function which will be called after holding <code>ZOOM+_key_</code>. Example: <code>test</code></li>
</ul>
</ul>
<li><code>config</code> - loader's config</li>
<ul>
<li><code>play_sound</code> - true/false, if set to true, plays a clacking terminal sound when you execute your function</li>
</ul>
</ul>
</p>
<p>
Hold <code>ZOOM+ACTION</code> (V+E) to bind functions to keys listed in config file.
</p>
<h3>Binding more keys</h3>
<p>
Just add a new entry into <code>keys</code> section based on example above then hold <code>ZOOM+ACTION</code> to apply changes.
</p>
<p>
Important note: functions with arguments have to be wrapped into a wrapper function without arguments. Example: your function <code>do_awesome_stuff(1,2,3)</code> has to be wrapped in another function <code>do_something()</code>, which will be referenced in config.
</p>
<h3>Links</h3>
</section>
</div>
<!-- FOOTER -->
<div id="footer_wrap" class="outer">
<footer class="inner">
<p class="copyright">Metal Gear Solid V: The Phantom Pain technical information maintained by <a href="https://github.com/unknown321">unknown321</a></p>
<p>Published with <a href="https://pages.github.com">GitHub Pages</a></p>
</footer>
</div>
</body>
</html>