Lua Script Migration: Difference between revisions
stub |
categories |
||
Line 2: | Line 2: | ||
When you reserialize mods between these versions, the lua scripts will go through an automatic conversion. | When you reserialize mods between these versions, the lua scripts will go through an automatic conversion. | ||
== Diff Modding == | |||
In the new system, lua scripts are diff modded. This means that instead of having to replace the entire file in the base game, you can chose to just add or redefine functions that you want. | In the new system, lua scripts are diff modded. This means that instead of having to replace the entire file in the base game, you can chose to just add or redefine functions that you want. | ||
Line 7: | Line 9: | ||
For example... | For example... | ||
[example] | |||
Previously, if the base game updated any method in common.lua, you would have to repeat that change in your mod. Now, as long that that method isn't changed in your mod, you don't have to make the manual change yourself. | |||
You can still copy common.lua wholesale in your mod if you want. It's just not recommended for the aforementioned maintainability reason. | |||
This works on common, init, include, and event scripts on the top level (as well as the scripts they call), ground map scripts, and zone scripts. | This works on common, init, include, and event scripts on the top level (as well as the scripts they call), ground map scripts, and zone scripts. | ||
Services behave slightly differently: they used to . Now they . | Services behave slightly differently: they used to . Now they . | ||
Line 29: | Line 38: | ||
== Automatic Conversion == | |||
Lua scripts are saved in a subfolder based on the mod's namespace. | Lua scripts are saved in a subfolder based on the mod's namespace. |
Revision as of 18:32, 9 June 2024
Between 0.8.1 and 0.8.2, the lua scripting system has changed. When you reserialize mods between these versions, the lua scripts will go through an automatic conversion.
Diff Modding
In the new system, lua scripts are diff modded. This means that instead of having to replace the entire file in the base game, you can chose to just add or redefine functions that you want.
For example...
[example]
Previously, if the base game updated any method in common.lua, you would have to repeat that change in your mod. Now, as long that that method isn't changed in your mod, you don't have to make the manual change yourself.
You can still copy common.lua wholesale in your mod if you want. It's just not recommended for the aforementioned maintainability reason.
This works on common, init, include, and event scripts on the top level (as well as the scripts they call), ground map scripts, and zone scripts.
Services behave slightly differently: they used to . Now they .
However, this means that your mod must include the common scripts yourself.
Before you could just override common_vars, and the base game's common.lua would call it.
Now you have to load it yourself.
init.lua must require common, event, and include
Additionally, all lua scripts are namespaced. This way, you can reference methods from the base game specifically. The caveat is that all scripts need to be moved.
Automatic Conversion
Lua scripts are saved in a subfolder based on the mod's namespace.
References to require "common"
become require "origin.common"
MapStrings is deprecated. This means the initial variable declaration is removed
the initialization method is removed
And Instead, use STRINGS.MapStrings