réplica de
https://github.com/minetest-mods/moreblocks.git
sincronizado 2025-07-02 16:10:44 +02:00
fix a bunch of bugs. still need to do more work on the station/circular saw distinction
Este cometimento está contido em:
@ -7,6 +7,15 @@ function api.register_alias_single(old_node, new_node, shape)
|
||||
local new_shaped_node = api.format_name(new_node, shape)
|
||||
|
||||
minetest.register_alias(old_shaped_node, new_shaped_node)
|
||||
|
||||
local shape_def = api.registered_shapes[shape]
|
||||
if shape_def.aliases then
|
||||
local old_mod, old_name = old_node:match("^([^:]+):(.*)$")
|
||||
for _, alias in ipairs(shape_def.aliases) do
|
||||
old_shaped_node = ("%s:%s"):format(old_mod, alias:format(old_name))
|
||||
minetest.register_alias(old_shaped_node, new_shaped_node)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function api.register_alias_all(old_node, new_node)
|
||||
@ -39,6 +48,15 @@ function api.register_alias_force_single(old_node, new_node, shape)
|
||||
|
||||
minetest.register_alias_force(old_shaped_node, new_shaped_node)
|
||||
|
||||
local shape_def = api.registered_shapes[shape]
|
||||
if shape_def.aliases then
|
||||
local old_mod, old_name = old_node:match("^([^:]+):(.*)$")
|
||||
for _, alias in ipairs(shape_def.aliases) do
|
||||
old_shaped_node = ("%s:%s"):format(old_mod, alias:format(old_name))
|
||||
minetest.register_alias_force(old_shaped_node, new_shaped_node)
|
||||
end
|
||||
end
|
||||
|
||||
local nodes = api.nodes_by_shape[shape] or {}
|
||||
if nodes[old_node] then
|
||||
nodes[old_node] = nil
|
||||
|
@ -41,7 +41,7 @@ function api.build_groups(node, shape)
|
||||
|
||||
local groups = {
|
||||
[("shape_%s"):format(shape)] = 1,
|
||||
not_in_creative_inventory = in_creative_inventory and 1,
|
||||
not_in_creative_inventory = in_creative_inventory and 1 or nil,
|
||||
}
|
||||
|
||||
local shape_def = api.registered_shapes[shape]
|
||||
|
@ -179,6 +179,11 @@ function api.register_single(node, shape, overrides, meta)
|
||||
|
||||
-- register node
|
||||
local shaped_name = api.format_name(node, shape)
|
||||
for k, v in pairs(def.groups) do
|
||||
if type(v) ~= "number" then
|
||||
error(("%s %s group:%s = %s"):format(node, shape, k, v))
|
||||
end
|
||||
end
|
||||
minetest.register_node(":" .. shaped_name, def)
|
||||
|
||||
-- alias old name formats
|
||||
@ -228,7 +233,9 @@ function api.register_groups(node, groups, overrides, meta)
|
||||
end
|
||||
|
||||
function api.get_shapes(node)
|
||||
return table_sort_keys(api.shapes_by_node[node])
|
||||
if api.shapes_by_node[node] then
|
||||
return table_sort_keys(api.shapes_by_node[node])
|
||||
end
|
||||
end
|
||||
|
||||
-- warning: don't mutate the return value
|
||||
|
@ -62,7 +62,7 @@ local function verify_schema(schema)
|
||||
end
|
||||
|
||||
function api.register_on_register_craft_schema(func)
|
||||
table.insert(api.registered_on_register_craft_schema, func)
|
||||
table.insert(api.registered_on_register_craft_schemas, func)
|
||||
end
|
||||
|
||||
function api.register_craft_schema(schema)
|
||||
@ -157,7 +157,7 @@ function api.register_schema_crafts_for_node(node)
|
||||
local shapes = api.get_shapes_hash(node)
|
||||
for _, schema in ipairs(api.registered_recipe_schemas) do
|
||||
if has_the_right_shapes(schema, shapes) then
|
||||
stairsplus.log("debug", "using schema %q", minetest.serialize(schema):sub(#("return ")))
|
||||
stairsplus.log("verbose", "using schema %s", minetest.serialize(schema):sub(#("return ")))
|
||||
register_for_schema(node, schema)
|
||||
end
|
||||
end
|
||||
@ -195,7 +195,7 @@ function api.register_crafts_for_shapes(def)
|
||||
output = api.get_schema_recipe_item(def.output, shape),
|
||||
recipe = api.get_schema_recipe_item(def.recipe, shape),
|
||||
cooktime = def.cooktime(api.registered_shapes[shape].eighths),
|
||||
groups = (not recipes_in_creative_inventory) and {not_in_creative_inventory = 1}
|
||||
groups = (not recipes_in_creative_inventory) and {not_in_creative_inventory = 1} or nil
|
||||
})
|
||||
end
|
||||
|
||||
@ -207,7 +207,7 @@ function api.register_crafts_for_shapes(def)
|
||||
type = "fuel",
|
||||
recipe = api.get_schema_recipe_item(def.recipe, shape),
|
||||
burntime = def.burntime(api.registered_shapes[shape].eighths),
|
||||
groups = (not recipes_in_creative_inventory) and {not_in_creative_inventory = 1}
|
||||
groups = (not recipes_in_creative_inventory) and {not_in_creative_inventory = 1} or nil
|
||||
})
|
||||
end
|
||||
|
||||
|
Criar uma nova questão referindo esta
Bloquear um utilizador