diff options
Diffstat (limited to 'advtrains_luaautomation/atc_rail.lua')
-rw-r--r--[-rwxr-xr-x] | advtrains_luaautomation/atc_rail.lua | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/advtrains_luaautomation/atc_rail.lua b/advtrains_luaautomation/atc_rail.lua index aac11f0..dd26f51 100755..100644 --- a/advtrains_luaautomation/atc_rail.lua +++ b/advtrains_luaautomation/atc_rail.lua @@ -95,11 +95,19 @@ function r.fire_event(pos, evtdata, appr_internal) if not train_id then return end local fc_list = {} for index,wagon_id in ipairs(train.trainparts) do - fc_list[index] = table.concat(advtrains.wagons[wagon_id].fc,"!") or "" + fc_list[index] = table.concat(advtrains.wagons[wagon_id].fc or {},"!") end return fc_list end, - set_fc = function(fc_list) + get_fc_index = function() + if not train_id then return end + local fc_index_list = {} + for widx, wagon_id in ipars(train.trainparts) do + fc_index_list[widx] = advtrains.wagons[wagon_id].fcind or 1 + end + return fc_index_list + end, + set_fc = function(fc_list,reset_index) assertt(fc_list, "table") if not train_id then return false end -- safety type-check for entered values @@ -113,11 +121,12 @@ function r.fire_event(pos, evtdata, appr_internal) if fc_list[index] then -- has FC to enter to this wagon local data = advtrains.wagons[wagon_id] if data then -- wagon actually exists - for _,wagon in pairs(minetest.luaentities) do -- find wagon entity - if wagon.is_wagon and wagon.initialized and wagon.id==wagon_id then - wagon.set_fc(data,fc_list[index]) -- overwrite to new FC - break -- no point cycling through every other entity. we found our wagon - end + --effectively copyied from wagons.lua, allowing for the :split function and reset_index + data.fc = fc_list[index]:split("!") + if reset_index or not data.fcind then + data.fcind = 1 + elseif data.fcind > #data.fc then + data.fcind = #data.fc end end end @@ -219,7 +228,7 @@ advtrains.register_tracks("default", { models_prefix="advtrains_dtrack", models_suffix=".b3d", shared_texture="advtrains_dtrack_shared_atc.png", - description=atltrans("LuaATC Rail"), + description=atltrans("LuaATC Track"), formats={}, get_additional_definiton = function(def, preset, suffix, rotation) return { |