aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation
diff options
context:
space:
mode:
authorMaverick2797 <git.maverick2797@gmail.com>2024-08-16 20:47:17 +0800
committerorwell <orwell@bleipb.de>2024-09-02 22:20:42 +0200
commit3b83580faccfbe5b23cea04bd3e6e0810572c7c0 (patch)
treeb1be12dd48b9ab8fd068aeb8fccb173adb2ea1c2 /advtrains_luaautomation
parent0c7e0f322b3f52f3a5f5071cd4c93c8aa7be893a (diff)
downloadadvtrains-3b83580faccfbe5b23cea04bd3e6e0810572c7c0.tar.gz
advtrains-3b83580faccfbe5b23cea04bd3e6e0810572c7c0.tar.bz2
advtrains-3b83580faccfbe5b23cea04bd3e6e0810572c7c0.zip
Fix LuaATC set_fc() only working on loaded entites
Diffstat (limited to 'advtrains_luaautomation')
-rw-r--r--[-rwxr-xr-x]advtrains_luaautomation/atc_rail.lua11
1 files changed, 6 insertions, 5 deletions
diff --git a/advtrains_luaautomation/atc_rail.lua b/advtrains_luaautomation/atc_rail.lua
index aac11f0..ead1031 100755..100644
--- a/advtrains_luaautomation/atc_rail.lua
+++ b/advtrains_luaautomation/atc_rail.lua
@@ -113,11 +113,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
+ --direct copy from wagons.lua, allowing for the :split function
+ data.fc = fc_list[index]:split("!")
+ if not data.fcind then
+ data.fcind = 1
+ elseif data.fcind > #data.fc then
+ data.fcind = #data.fc
end
end
end