Fix sloped power,activator and detector rails, remove debug print

This commit is contained in:
teknomunk 2024-04-11 13:49:00 +00:00
parent b0fff9f3e9
commit fba49df2f0
2 changed files with 54 additions and 16 deletions

View file

@ -149,7 +149,6 @@ function DEFAULT_CART_DEF:_mcl_entity_invs_load_items()
end end
function DEFAULT_CART_DEF:_mcl_entity_invs_save_items(items) function DEFAULT_CART_DEF:_mcl_entity_invs_save_items(items)
local staticdata = self._staticdata local staticdata = self._staticdata
print("Saving entity inventory items="..dump(items))
staticdata.inventory = table.copy(items) staticdata.inventory = table.copy(items)
end end

View file

@ -261,11 +261,12 @@ function mod.register_straight_rail(base_name, tiles, def)
}) })
-- Sloped variant -- Sloped variant
mod.register_rail_sloped(base_name.."_sloped", table_merge(table.copy(base_def),{ mod.register_rail_sloped(base_name.."_sloped", table_merge(table.copy(sloped_def),{
description = S("Sloped Rail"), -- Temporary name to make debugging easier description = S("Sloped Rail"), -- Temporary name to make debugging easier
_mcl_minecarts = { _mcl_minecarts = {
get_next_dir = rail_dir_sloped, get_next_dir = rail_dir_sloped,
}, },
mesecons = def.mesecons_sloped,
tiles = { tiles[1] }, tiles = { tiles[1] },
_mcl_minecarts = { _mcl_minecarts = {
railtype = "sloped", railtype = "sloped",
@ -444,7 +445,15 @@ mod.register_straight_rail("mcl_minecarts:golden_rail_v2",{ "mcl_minecarts_rail_
conductor = { conductor = {
state = mesecon.state.off, state = mesecon.state.off,
offstate = "mcl_minecarts:golden_rail_v2", offstate = "mcl_minecarts:golden_rail_v2",
onstate = "mcl_minecarts:golden_rail_v2_on", onstate = "mcl_minecarts:golden_rail_v2_on",
rules = rail_rules_long,
},
},
mesecons_sloped = {
conductor = {
state = mesecon.state.off,
offstate = "mcl_minecarts:golden_rail_v2_sloepd",
onstate = "mcl_minecarts:golden_rail_v2_on_sloped",
rules = rail_rules_long, rules = rail_rules_long,
}, },
}, },
@ -471,7 +480,15 @@ mod.register_straight_rail("mcl_minecarts:golden_rail_v2_on",{ "mcl_minecarts_ra
conductor = { conductor = {
state = mesecon.state.on, state = mesecon.state.on,
offstate = "mcl_minecarts:golden_rail_v2", offstate = "mcl_minecarts:golden_rail_v2",
onstate = "mcl_minecarts:golden_rail_v2_on", onstate = "mcl_minecarts:golden_rail_v2_on",
rules = rail_rules_long,
},
},
mesecons_sloped = {
conductor = {
state = mesecon.state.on,
offstate = "mcl_minecarts:golden_rail_v2_sloped",
onstate = "mcl_minecarts:golden_rail_v2_on_sloped",
rules = rail_rules_long, rules = rail_rules_long,
}, },
}, },
@ -488,7 +505,15 @@ mod.register_straight_rail("mcl_minecarts:activator_rail_v2", {"mcl_minecarts_ra
conductor = { conductor = {
state = mesecon.state.off, state = mesecon.state.off,
offstate = "mcl_minecarts:activator_rail_v2", offstate = "mcl_minecarts:activator_rail_v2",
onstate = "mcl_minecarts:activator_rail_v2_on", onstate = "mcl_minecarts:activator_rail_v2_on",
rules = rail_rules_long,
},
},
mesecons_sloped = {
conductor = {
state = mesecon.state.off,
offstate = "mcl_minecarts:activator_rail_v2_sloped",
onstate = "mcl_minecarts:activator_rail_v2_on_sloped",
rules = rail_rules_long, rules = rail_rules_long,
}, },
}, },
@ -503,6 +528,16 @@ mod.register_straight_rail("mcl_minecarts:activator_rail_v2", {"mcl_minecarts_ra
}) })
-- Activator rail (on) -- Activator rail (on)
local function activator_rail_action_on(pos, node)
local pos2 = { x = pos.x, y =pos.y + 1, z = pos.z }
local objs = minetest.get_objects_inside_radius(pos2, 1)
for _, o in pairs(objs) do
local l = o:get_luaentity()
if l and string.sub(l.name, 1, 14) == "mcl_minecarts:" and l.on_activate_by_rail then
l:on_activate_by_rail()
end
end
end
mod.register_straight_rail("mcl_minecarts:activator_rail_v2_on", {"mcl_minecarts_rail_activator_powered.png"},{ mod.register_straight_rail("mcl_minecarts:activator_rail_v2_on", {"mcl_minecarts_rail_activator_powered.png"},{
_doc_items_create_entry = false, _doc_items_create_entry = false,
groups = { groups = {
@ -512,21 +547,25 @@ mod.register_straight_rail("mcl_minecarts:activator_rail_v2_on", {"mcl_minecarts
conductor = { conductor = {
state = mesecon.state.on, state = mesecon.state.on,
offstate = "mcl_minecarts:activator_rail_v2", offstate = "mcl_minecarts:activator_rail_v2",
onstate = "mcl_minecarts:activator_rail_v2_on", onstate = "mcl_minecarts:activator_rail_v2_on",
rules = rail_rules_long, rules = rail_rules_long,
}, },
effector = { effector = {
-- Activate minecarts -- Activate minecarts
action_on = function(pos, node) action_on = activator_rail_action_on,
local pos2 = { x = pos.x, y =pos.y + 1, z = pos.z } },
local objs = minetest.get_objects_inside_radius(pos2, 1)
for _, o in pairs(objs) do },
local l = o:get_luaentity() mesecons_sloped = {
if l and string.sub(l.name, 1, 14) == "mcl_minecarts:" and l.on_activate_by_rail then conductor = {
l:on_activate_by_rail() state = mesecon.state.on,
end offstate = "mcl_minecarts:activator_rail_v2_sloped",
end onstate = "mcl_minecarts:activator_rail_v2_on_sloped",
end, rules = rail_rules_long,
},
effector = {
-- Activate minecarts
action_on = activator_rail_action_on,
}, },
}, },