advtrains_luaautomation_sync
A patch for the Minetest mod advtrains_luaautomation (which belongs to the advtrains modpack). advtrains adds trains and railway systems with interlocking to Minetest and advtrains_luaautomation is the component that enables players to program their own logic for setting routes and switches, e.g. when a train passes a special lua rail. This is organized in sandboxed environments. The code used in these environments can grow very complex very quickly, making it difficult to maintain (and maybe even collaborate on) within the limited interface the Minetest formspec API can provide.
This repository can be used to patch the advtrains_luaautomation mod to introduce a "Sync" button that fetches the init code for an environment from an external URL. This way, the environment code can be developed using external tools and collaborated on using version control systems, and brought up to date inside the game with a click of a button (e.g. when pointing to a raw file in master on GitLab).
The mod must be declared in secure.http_mods
to be able to use the http API.
Ensure your destination is reachable from within your Minetest servers network and your content doesn't need special cookies to view it.
advtrains_luaautomation
mod
Creating the patched - Run
create_env.sh
to initialize the submodule advtrains, fetch the newest changes and create a working copy of advtrains_luaautomation in the directorypatched/
. - Run
apply_patch.sh
to apply thesync.patch
file topatched/
. - Copy
patched/
to your Minetest mods folder and rename it toadvtrains_luaautomation_sync/
. - Disable the original advtrains_luaautomation of the advtrains modpack and enable advtrains_luaautomation_sync for your world.
This can be done directly in your worlds
world.mt
or from within your Minetest client (the latter for local games only). - Ensure advtrains_luaautomation_sync is listed in your
minetest.conf
(e.g.secure.http_mods = advtrains_luaautomation_sync,other_mod
) Otherwise, the sync option will be disabled.
advtrains
versions
Creating patches for new As the original code base changes over the course of the continued development, the old patches cannot be cleanly applied and/or may no longer have the desired effect. So the patch has to be continually verified to work with and, if necessary, adapted to new versions of advtrains.
- Run
clean.sh
to deletepatched/
and resetsync.patch
and the submodule to the commit recorded in HEAD of the superproject. - Run
create_env.sh
to ensure the submodule advtrains is initialized, fetch the newest changes and create a working copy of advtrains_luaautomation in the directorypatched/
. You might patch it withapply_patch.sh
and make a backup ofpatched/
to e.g.patched-2.3.0/
for reference. - Checkout the submodule in
advtrains/
to the desired commit to make the patch for. - Run
create_env.sh
again. This won't change the currently checked out commit but replacepatched/
with a new working copy ofadvtrains/advtrains_luaautomation/
. You can also copy this manually. - Try to apply the old patch with
apply_patch.sh
. This will most likely fail, leaving.orig
and.rej
files inpatched/
. Even if it doesn't, it might well be that other changes compromise the functionality of the patch. Study the patch and the diff for the original code base well and try to evaluate places where it might break. Testing the functionality is a necessity. - Modify the files in
patched/
. Fix the parts where the old patch couldn't be applied and where you have to add more changes to restore functionality. - Happy? Everything runs as planned?
Extract the minimal patch with
generate_patch.sh
and commit the result. Tag it with the version number of advtrains if your patch was for a release. Congrats! You're done! (Don't forget to push the commit though)
All shell scripts can be run from any directory, they will always execute where they are stored: In the project root.