Compare commits

...

5 Commits

Author SHA1 Message Date
Maverick2797 c7ed099e11 Fix nil loco_id crash when loco is removed from world 2022-05-08 20:17:14 +08:00
Maverick2797 a69120307a Licenses and Attrributions
- Attribute oneself
 - Acknowledge yw05's inspiration
2022-05-08 07:10:22 +00:00
Maverick2797 8bae12b13e Update screenshot URL 2022-05-07 15:38:00 +00:00
Maverick2797 c526f94cdd Small whitespace needed in Readme 2022-05-07 15:27:26 +00:00
Maverick2797 f87c4e308b Extend readme with how-to and explanation of fields 2022-04-28 12:13:40 +00:00
2 changed files with 37 additions and 6 deletions

View File

@ -1,17 +1,40 @@
# Advtrains Train Controller
![Screenshot from git repo](https://notabug.org/Maverick2797/advtrains_train_controller/raw/master/screenshot.png)
![Screenshot from git repo](https://notabug.org/Maverick2797/advtrains_portable_remote_control/raw/master/screenshot.png)
This mod provides a rebindable remote control for use with the advtrains mod.
## How To Use
### Binding To A Train
Punch a locomotive with the controller to bind it to that locomotive. The controller will remain bound to the locomotive specifically, not the train as a whole, enabling the user to retain control of the locomotive during shunting when the train id may change.
Note: the controller will **only** bind to locomotives, i.e. anything with `is_locomotive = true` in the advtrains registered definition.
### Rebinding To A New Train
To rebind the controller to another locomotive simply click the `Bind To New Train` button. The saved locomotive will be erased from memory, ready for the user to rebind as above.
### Train Information
The `External Display`, `Internal Display`, `Routing Code` and `Line` fields are read from the bound train when the user punches to use the controller. If any of these fields change between reading from the train and when the user clicks `Update Train Info` then the changes made will be written to the train, overwriting any changes that the train may have accumulated in the meantime (e.g. Inside Display text being changed by a station track.)
### Train Control
The `Set Speed` field is also read from the train when the user uses the controller, except that it will read the train's actual speed at the time. The speed will only be sent to the train when the `Confirm` button is clicked.
The `Send ATC` field performs exactly as if the train passed over an ATC track section in the direction of the arrow. The user can use this to pre-program manoeuvres instead of constantly returning to the controller. See the documentation for the [ATC Controller](https://advtrains.de/wiki/doku.php?id=usage:nodes:atc_controller) for commands and syntax. The command is immediately sent to the train when `Send` is clicked and not kept in memory across controller uses.
The `Disable ARS` and `Autocouple` checkboxes also will be read from the train when the user uses the controller. `Autocouple` will show as ticked if the train has been set to couple by either the `Cpl` ATC command or `set_autocouple()` LuaATC command. Manually ticking the checkbox has the same effect as `set_autocouple()`. `Disable ARS` requires the `advtrains_interlocking` sub-mod to be enabled to be effective, and has the equivalent effect as the `A` ATC command and `atc_set_ars_disable()` LuaATC command.
## Priv Requirements
Due to the ability to control a train from anywhere on the server, the `train_admin` priv is required to use this tool.
## Dependencies:
- advtrains
- default & advtrains_luaautomation for craft recipe
- default & advtrains_luaautomation for craft recipe only (not required for the code to work)
## Licenses:
## Licenses and Attributions:
This work is protected under the following licenses:
- Code: MIT
- Artwork: CC-BY-SA-4.0
- Code: MIT (Maverick2797)
- Artwork: CC-BY-SA-4.0 (Maverick2797)
A copy of each license is included in the `LICENSES` folder
A copy of each license is included in the `LICENSES` folder
Thanks to yw05 for the inspiration from the original [train_remote](https://gitlab.com/yw05/minetest-mod-train-remote) mod which was written in Lisp.

View File

@ -236,6 +236,14 @@ minetest.register_craftitem(modname..":remote_control",{
end
end
else
if not advtrains.wagons[bound_loco] then --loco has been removed from the world. set to unbound
meta:set_string("bound_loco","")
meta:set_string("roadnumber","")
meta:set_string("description",trans("Unbound Controller"))
minetest.chat_send_player(pname,trans("The locomotive has been removed from the world. Controller is unbound"))
return itemstack
end
if meta:get("roadnumber") ~= advtrains.wagons[bound_loco].roadnumber then --update roadnumber for item description
meta:set_string("roadnumber",advtrains.wagons[bound_loco].roadnumber)
end