Compare commits

...

8 Commits

Author SHA1 Message Date
1F616EMO 882108e8bf Alias for wagon types 2024-09-03 00:04:04 +02:00
1F616EMO fe7e25c995 Add direct recipe for every orientation of wallmounted signals 2024-09-02 22:51:43 +02:00
Y. Wang dd883c5b5e Clear tcbs.route_rsn when a route is set
This appears to fix the issue where route_rsn is not cleared and later
shown on the train HUD even when the route is set.

Note that this only works if the route is (successfully) set after this
patch is applied - it does not clear route_rsn for routes that are
already set.

How to test:
* Set a conflicting route for the train.
* Set a route for the train. Note that a message appears on the train
  HUD explaining that the route cannot be set (this is also the current
  behavior without the patch).
* Cancel the conflicting route. Note that the message on the train HUD
  is cleared.
2024-09-02 22:50:22 +02:00
1F616EMO fcfe21f197 Fix Ks Shunting Signal collision box 2024-09-02 22:25:51 +02:00
Maverick2797 852e2f4219 LuaATC add trainparts(train_id)
Returns a copy of the trainparts table to allow tracking individual wagon ids
Also fixed a couple of file permissions from previous commits
2024-09-02 22:25:05 +02:00
Maverick2797 55108ae38e LuaATC set_fc(): add argument to reset fc index to 1 2024-09-02 22:22:38 +02:00
Maverick2797 3b83580fac Fix LuaATC set_fc() only working on loaded entites 2024-09-02 22:20:42 +02:00
erstazi 0c7e0f322b Move the Train ID information to a textarea[] without a name attribute so it remains transparent and the player can copy the Train ID. 2024-09-02 22:19:48 +02:00
8 changed files with 65 additions and 11 deletions

View File

@ -21,6 +21,14 @@ minetest.register_craft({
}, },
}) })
--Wallmounted Signal --Wallmounted Signal
minetest.register_craft({
output = 'advtrains:signal_wall_l_off 2',
recipe = {
{'default:steel_ingot', 'default:steel_ingot', 'dye:red'},
{'', 'default:steel_ingot', ''},
{'default:steel_ingot', 'default:steel_ingot', 'dye:dark_green'},
},
})
minetest.register_craft({ minetest.register_craft({
output = 'advtrains:signal_wall_r_off 2', output = 'advtrains:signal_wall_r_off 2',
recipe = { recipe = {
@ -29,6 +37,15 @@ minetest.register_craft({
{'dye:dark_green', 'default:steel_ingot', 'default:steel_ingot'}, {'dye:dark_green', 'default:steel_ingot', 'default:steel_ingot'},
}, },
}) })
minetest.register_craft({
output = 'advtrains:signal_wall_t_off 2',
recipe = {
{'default:steel_ingot', '', 'default:steel_ingot'},
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
{'dye:dark_green', '', 'dye:red'},
},
})
--Wallmounted Signals can be converted into every orientation by shapeless crafting --Wallmounted Signals can be converted into every orientation by shapeless crafting
minetest.register_craft({ minetest.register_craft({

View File

@ -13,7 +13,20 @@ local GETOFF_TP_DELAY = 0.5
local IGNORE_WORLD = advtrains.IGNORE_WORLD local IGNORE_WORLD = advtrains.IGNORE_WORLD
advtrains.wagons = {} advtrains.wagons = {}
advtrains.wagon_prototypes = {} advtrains.wagon_alias = {}
advtrains.wagon_prototypes = setmetatable({}, {
__index = function(t, k)
local rtn_val = rawget(t, k)
if rtn_val ~= nil then
return rtn_val
end
local alias = advtrains.wagon_alias[k]
if alias then
return rawget(t, alias)
end
return nil
end
})
advtrains.wagon_objects = {} advtrains.wagon_objects = {}
local unload_wgn_range = advtrains.wagon_load_range + 32 local unload_wgn_range = advtrains.wagon_load_range + 32
@ -971,7 +984,8 @@ function wagon:show_bordcom(pname)
local data = advtrains.wagons[self.id] local data = advtrains.wagons[self.id]
local linhei local linhei
local form = "size[11,9]label[0.5,0;AdvTrains Boardcom v0.1 | "..attrans("Train ID")..": "..(minetest.formspec_escape(train.id or "")).."]" local form = "size[11,9]label[0.5,0;AdvTrains Boardcom v0.1]"
form=form.."textarea[7.5,0.05;10,1;;"..attrans("Train ID")..": "..(minetest.formspec_escape(train.id or ""))..";]"
form=form.."textarea[0.5,1.5;7,1;text_outside;"..attrans("Text displayed outside on train")..";"..(minetest.formspec_escape(train.text_outside or "")).."]" form=form.."textarea[0.5,1.5;7,1;text_outside;"..attrans("Text displayed outside on train")..";"..(minetest.formspec_escape(train.text_outside or "")).."]"
form=form.."textarea[0.5,3;7,1;text_inside;"..attrans("Text displayed inside train")..";"..(minetest.formspec_escape(train.text_inside or "")).."]" form=form.."textarea[0.5,3;7,1;text_inside;"..attrans("Text displayed inside train")..";"..(minetest.formspec_escape(train.text_inside or "")).."]"
form=form.."field[7.5,1.75;3,1;line;"..attrans("Line")..";"..(minetest.formspec_escape(train.line or "")).."]" form=form.."field[7.5,1.75;3,1;line;"..attrans("Line")..";"..(minetest.formspec_escape(train.line or "")).."]"
@ -1325,6 +1339,10 @@ function advtrains.get_wagon_prototype(data)
return wt, advtrains.wagon_prototypes[wt] return wt, advtrains.wagon_prototypes[wt]
end end
function advtrains.register_wagon_alias(src, dst)
advtrains.wagon_alias[src] = dst
end
function advtrains.standard_inventory_formspec(self, pname, invname) function advtrains.standard_inventory_formspec(self, pname, invname)
--[[minetest.chat_send_player(pname, string.format("self=%s, pname=%s, invname=%s", self, pname, invname)) --[[minetest.chat_send_player(pname, string.format("self=%s, pname=%s, invname=%s", self, pname, invname))
for k,v in pairs(self) do for k,v in pairs(self) do

View File

@ -113,6 +113,7 @@ function ilrs.set_route(signal, route, try)
if c_tcbs.signal then if c_tcbs.signal then
c_tcbs.route_committed = true c_tcbs.route_committed = true
c_tcbs.aspect = route.aspect or advtrains.interlocking.GENERIC_FREE c_tcbs.aspect = route.aspect or advtrains.interlocking.GENERIC_FREE
c_tcbs.route_rsn = nil
c_tcbs.route_origin = signal c_tcbs.route_origin = signal
advtrains.interlocking.update_signal_aspect(c_tcbs) advtrains.interlocking.update_signal_aspect(c_tcbs)
end end

View File

@ -93,6 +93,9 @@ Removes any pending interrupts of this node.
Make this active component send a digiline message on the specified channel. Make this active component send a digiline message on the specified channel.
Not available in init code. Not available in init code.
- `trainparts(train_id)`
returns a table with the ids of the cars the train is composed of, or false if `train_id` is invalid. `train_id` can be replaced with `atc_id` when used in LuaATC Rails.
- `atc_send_to_train(<train_id>, <atc_command>)` - `atc_send_to_train(<train_id>, <atc_command>)`
Sends the specified ATC command to the train specified by its train id. This happens regardless of where the train is in the world, and can be used to remote-control trains. Returns true on success. If the train ID does not exist, returns false and does nothing. See [atc_command.txt](../atc_command.txt) for the ATC command syntax. Sends the specified ATC command to the train specified by its train id. This happens regardless of where the train is in the world, and can be used to remote-control trains. Returns true on success. If the train ID does not exist, returns false and does nothing. See [atc_command.txt](../atc_command.txt) for the ATC command syntax.
@ -274,9 +277,11 @@ Each wagon has a current FC, indicating its next destination.
Command: `get_fc()` Command: `get_fc()`
Result: `{"", "foo!bar", "testing", "fc_1!fc_2!fc_3!?", "hello_world"}` Result: `{"", "foo!bar", "testing", "fc_1!fc_2!fc_3!?", "hello_world"}`
- `set_fc(fc_list)` - `set_fc(fc_list, reset_index)`
Overwrites the FC list according to a table `fc_list`. A false or nil entry will leave the wagon unaffected, however all others will be overwritten. Overwrites the FC list according to a table `fc_list`. A false or nil entry will leave the wagon unaffected, however all others will be overwritten.
Useful for mass-programming freight trains that use FC-shunting instead of walking to each wagon individually. Useful for mass-programming freight trains that use FC-shunting instead of walking to each wagon individually. If the new FC entry for a wagon is shorter than the old entry, the index will clip to the last FC in the new entry.
If `reset_index` is true, all Current FC values will reset to the first entry in the list, instead of remaining at the current index.
Example: train has FC lists: `"", "foo!bar", "testing", "fc_1!fc_2!fc_3!?", "hello_world"` Example: train has FC lists: `"", "foo!bar", "testing", "fc_1!fc_2!fc_3!?", "hello_world"`
Command: `set_fc({"", "foo!turtle", nil, "4tehlulz", false})` Command: `set_fc({"", "foo!turtle", nil, "4tehlulz", false})`
Result: `""` `"foo!turtle"` `"testing"` `"4tehlulz"` `"hello_world"` Result: `""` `"foo!turtle"` `"testing"` `"4tehlulz"` `"hello_world"`

13
advtrains_luaautomation/atc_rail.lua Executable file → Normal file
View File

@ -99,7 +99,7 @@ function r.fire_event(pos, evtdata, appr_internal)
end end
return fc_list return fc_list
end, end,
set_fc = function(fc_list) set_fc = function(fc_list,reset_index)
assertt(fc_list, "table") assertt(fc_list, "table")
if not train_id then return false end if not train_id then return false end
-- safety type-check for entered values -- safety type-check for entered values
@ -113,11 +113,12 @@ function r.fire_event(pos, evtdata, appr_internal)
if fc_list[index] then -- has FC to enter to this wagon if fc_list[index] then -- has FC to enter to this wagon
local data = advtrains.wagons[wagon_id] local data = advtrains.wagons[wagon_id]
if data then -- wagon actually exists if data then -- wagon actually exists
for _,wagon in pairs(minetest.luaentities) do -- find wagon entity --effectively copyied from wagons.lua, allowing for the :split function and reset_index
if wagon.is_wagon and wagon.initialized and wagon.id==wagon_id then data.fc = fc_list[index]:split("!")
wagon.set_fc(data,fc_list[index]) -- overwrite to new FC if reset_index or not data.fcind then
break -- no point cycling through every other entity. we found our wagon data.fcind = 1
end elseif data.fcind > #data.fc then
data.fcind = #data.fc
end end
end end
end end

View File

@ -153,6 +153,12 @@ local static_env = {
local pos=atlatc.pcnaming.resolve_pos(parpos, "interrupt_pos") local pos=atlatc.pcnaming.resolve_pos(parpos, "interrupt_pos")
atlatc.interrupt.add(0, pos, {type="ext_int", ext_int=true, message=imesg}) atlatc.interrupt.add(0, pos, {type="ext_int", ext_int=true, message=imesg})
end, end,
train_parts = function(train_id)
if not train_id then return false end
local train = advtrains.trains[train_id]
if not train then return false end
return table.copy(train.trainparts or {})
end,
-- sends an atc command to train regardless of where it is in the world -- sends an atc command to train regardless of where it is in the world
atc_send_to_train = function(train_id, command) atc_send_to_train = function(train_id, command)
assertt(command, "string") assertt(command, "string")

0
advtrains_luaautomation/operation_panel.lua Executable file → Normal file
View File

View File

@ -210,6 +210,8 @@ for _, rtab in ipairs({
danger = {asp = { main = false, shunt = false }, n = "shuntd", ici=true}, danger = {asp = { main = false, shunt = false }, n = "shuntd", ici=true},
shuntd = {asp = { main = false, shunt = true } , n = "danger"}, shuntd = {asp = { main = false, shunt = true } , n = "danger"},
}) do }) do
local sbox = table.copy(rtab.sbox)
sbox[5] = 0
minetest.register_node("advtrains_signals_ks:ra_"..typ.."_"..rot, { minetest.register_node("advtrains_signals_ks:ra_"..typ.."_"..rot, {
description = "Ks Shunting Signal", description = "Ks Shunting Signal",
drawtype = "mesh", drawtype = "mesh",
@ -223,7 +225,11 @@ for _, rtab in ipairs({
paramtype2 = "facedir", paramtype2 = "facedir",
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = {-1/4, -1/2, -1/4, 1/4, 0, 1/4} fixed = {sbox, rotation_sbox}
},
collision_box = {
type = "fixed",
fixed = sbox,
}, },
groups = { groups = {
cracky = 2, cracky = 2,