mirror of
https://github.com/minetest-mods/technic.git
synced 2024-11-19 22:03:53 +01:00
Add external machine registration support (#557)
New 'technic.register_base_machine' definition table value: 'modname' (defaults to current run mod)
This commit is contained in:
parent
88f2bc388f
commit
438c0877f6
@ -38,6 +38,8 @@ function technic.register_base_machine(data)
|
|||||||
local machine_desc = data.machine_desc
|
local machine_desc = data.machine_desc
|
||||||
local tier = data.tier
|
local tier = data.tier
|
||||||
local ltier = string.lower(tier)
|
local ltier = string.lower(tier)
|
||||||
|
|
||||||
|
data.modname = data.modname or minetest.get_current_modname()
|
||||||
|
|
||||||
local groups = {cracky = 2, technic_machine = 1, ["technic_"..ltier] = 1}
|
local groups = {cracky = 2, technic_machine = 1, ["technic_"..ltier] = 1}
|
||||||
if data.tube then
|
if data.tube then
|
||||||
@ -82,7 +84,7 @@ function technic.register_base_machine(data)
|
|||||||
local eu_input = meta:get_int(tier.."_EU_input")
|
local eu_input = meta:get_int(tier.."_EU_input")
|
||||||
|
|
||||||
local machine_desc_tier = machine_desc:format(tier)
|
local machine_desc_tier = machine_desc:format(tier)
|
||||||
local machine_node = "technic:"..ltier.."_"..machine_name
|
local machine_node = data.modname..":"..ltier.."_"..machine_name
|
||||||
local machine_demand = data.demand
|
local machine_demand = data.demand
|
||||||
|
|
||||||
-- Setup meta data if it does not exist.
|
-- Setup meta data if it does not exist.
|
||||||
@ -157,15 +159,15 @@ function technic.register_base_machine(data)
|
|||||||
tentry = ""
|
tentry = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("technic:"..ltier.."_"..machine_name, {
|
minetest.register_node(data.modname..":"..ltier.."_"..machine_name, {
|
||||||
description = machine_desc:format(tier),
|
description = machine_desc:format(tier),
|
||||||
tiles = {
|
tiles = {
|
||||||
"technic_"..ltier.."_"..machine_name.."_top.png"..tentry,
|
data.modname.."_"..ltier.."_"..machine_name.."_top.png"..tentry,
|
||||||
"technic_"..ltier.."_"..machine_name.."_bottom.png"..tentry,
|
data.modname.."_"..ltier.."_"..machine_name.."_bottom.png"..tentry,
|
||||||
"technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
data.modname.."_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
||||||
"technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
data.modname.."_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
||||||
"technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
data.modname.."_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
||||||
"technic_"..ltier.."_"..machine_name.."_front.png"
|
data.modname.."_"..ltier.."_"..machine_name.."_front.png"
|
||||||
},
|
},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = groups,
|
groups = groups,
|
||||||
@ -227,18 +229,18 @@ function technic.register_base_machine(data)
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("technic:"..ltier.."_"..machine_name.."_active",{
|
minetest.register_node(data.modname..":"..ltier.."_"..machine_name.."_active",{
|
||||||
description = machine_desc:format(tier),
|
description = machine_desc:format(tier),
|
||||||
tiles = {
|
tiles = {
|
||||||
"technic_"..ltier.."_"..machine_name.."_top.png"..tentry,
|
data.modname.."_"..ltier.."_"..machine_name.."_top.png"..tentry,
|
||||||
"technic_"..ltier.."_"..machine_name.."_bottom.png"..tentry,
|
data.modname.."_"..ltier.."_"..machine_name.."_bottom.png"..tentry,
|
||||||
"technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
data.modname.."_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
||||||
"technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
data.modname.."_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
||||||
"technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
data.modname.."_"..ltier.."_"..machine_name.."_side.png"..tentry,
|
||||||
"technic_"..ltier.."_"..machine_name.."_front_active.png"
|
data.modname.."_"..ltier.."_"..machine_name.."_front_active.png"
|
||||||
},
|
},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
drop = "technic:"..ltier.."_"..machine_name,
|
drop = data.modname..":"..ltier.."_"..machine_name,
|
||||||
groups = active_groups,
|
groups = active_groups,
|
||||||
connect_sides = data.connect_sides or connect_default,
|
connect_sides = data.connect_sides or connect_default,
|
||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
@ -249,7 +251,7 @@ function technic.register_base_machine(data)
|
|||||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
technic_run = run,
|
technic_run = run,
|
||||||
technic_disabled_machine_name = "technic:"..ltier.."_"..machine_name,
|
technic_disabled_machine_name = data.modname..":"..ltier.."_"..machine_name,
|
||||||
on_receive_fields = function(pos, formname, fields, sender)
|
on_receive_fields = function(pos, formname, fields, sender)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if not pipeworks.may_configure(pos, sender) then return end
|
if not pipeworks.may_configure(pos, sender) then return end
|
||||||
@ -271,8 +273,8 @@ function technic.register_base_machine(data)
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.register_machine(tier, "technic:"..ltier.."_"..machine_name, technic.receiver)
|
technic.register_machine(tier, data.modname..":"..ltier.."_"..machine_name, technic.receiver)
|
||||||
technic.register_machine(tier, "technic:"..ltier.."_"..machine_name.."_active", technic.receiver)
|
technic.register_machine(tier, data.modname..":"..ltier.."_"..machine_name.."_active", technic.receiver)
|
||||||
|
|
||||||
end -- End registration
|
end -- End registration
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user