mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-27 21:11:05 +01:00
Fix placed rail conversion, start automatic inventory rail conversion
This commit is contained in:
parent
a980446315
commit
1054d38b4e
3 changed files with 29 additions and 4 deletions
|
@ -3,7 +3,7 @@ local modpath = minetest.get_modpath(modname)
|
|||
local mod = mcl_minecarts
|
||||
local S = minetest.get_translator(modname)
|
||||
|
||||
local mcl_log = mcl_util.make_mcl_logger("mcl_logging_minecarts", "Minecarts")
|
||||
local mcl_log,DEBUG = mcl_util.make_mcl_logger("mcl_logging_minecarts", "Minecarts")
|
||||
|
||||
-- Imports
|
||||
local CART_BLOCK_SIZE = mod.CART_BLOCK_SIZE
|
||||
|
@ -612,6 +612,7 @@ minetest.register_globalstep(function(dtime)
|
|||
end)
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
-- Try cart reattachment
|
||||
local player_name = player:get_player_name()
|
||||
local player_meta = mcl_playerinfo.get_mod_meta(player_name, modname)
|
||||
local cart_uuid = player_meta.attached_to
|
||||
|
|
|
@ -652,7 +652,10 @@ local CURVY_RAILS_MAP = {
|
|||
["mcl_minecarts:rail"] = "mcl_minecarts:rail_v2",
|
||||
}
|
||||
for old,new in pairs(CURVY_RAILS_MAP) do
|
||||
minetest.register_alias(old, new)
|
||||
minetest.register_node(old, {
|
||||
inventory_image = minetest.registered_nodes[new].inventory_image,
|
||||
groups = { rail = 1 }
|
||||
})
|
||||
end
|
||||
minetest.register_lbm({
|
||||
name = "mcl_minecarts:update_legacy_curvy_rails",
|
||||
|
@ -674,8 +677,14 @@ local STRAIGHT_RAILS_MAP ={
|
|||
["mcl_minecarts:detector_rail_on"] = "mcl_minecarts:detector_rail_v2_on",
|
||||
}
|
||||
for old,new in pairs(STRAIGHT_RAILS_MAP) do
|
||||
minetest.register_alias(old, new)
|
||||
minetest.register_node(old, {
|
||||
inventory_image = minetest.registered_nodes[new].inventory_image,
|
||||
groups = { rail = 1 }
|
||||
})
|
||||
end
|
||||
local TRANSLATE_RAILS_MAP = table.copy(STRAIGHT_RAILS_MAP)
|
||||
table_merge(TRANSLATE_RAILS_MAP, CURVY_RAILS_MAP)
|
||||
|
||||
minetest.register_lbm({
|
||||
name = "mcl_minecarts:update_legacy_straight_rails",
|
||||
nodenames = mcl_util.table_keys(STRAIGHT_RAILS_MAP),
|
||||
|
@ -699,3 +708,18 @@ minetest.register_lbm({
|
|||
end
|
||||
end
|
||||
})
|
||||
|
||||
-- Convert old rail in the player's inventory to new rail
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local inv = player:get_inventory()
|
||||
local size = inv:get_size("main")
|
||||
for i=1,size do
|
||||
local stack = inv:get_stack("main", i)
|
||||
|
||||
local new_name = TRANSLATE_RAILS_MAP[stack:get_name()]
|
||||
if new_name then
|
||||
stack:set_name(new_name)
|
||||
inv:set_stack("main", i, stack)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -386,7 +386,7 @@ local tab_icon = {
|
|||
blocks = "mcl_core:brick_block",
|
||||
deco = "mcl_flowers:peony",
|
||||
redstone = "mesecons:redstone",
|
||||
rail = "mcl_minecarts:golden_rail",
|
||||
rail = "mcl_minecarts:golden_rail_v2",
|
||||
misc = "mcl_buckets:bucket_lava",
|
||||
nix = "mcl_compass:compass",
|
||||
food = "mcl_core:apple",
|
||||
|
|
Loading…
Reference in a new issue