mirror of
https://github.com/minetest-mods/technic.git
synced 2024-11-17 15:58:37 +01:00
add drawers support for wrench (also fix a missing constants issue)
This commit is contained in:
parent
8fc58be03b
commit
df25b91beb
@ -26,7 +26,7 @@ read_globals = {
|
|||||||
|
|
||||||
"protector", "isprotect",
|
"protector", "isprotect",
|
||||||
"homedecor_expect_infinite_stacks",
|
"homedecor_expect_infinite_stacks",
|
||||||
"monitoring"
|
"monitoring", "drawers"
|
||||||
}
|
}
|
||||||
|
|
||||||
files["concrete/init.lua"].ignore = { "steel_ingot" }
|
files["concrete/init.lua"].ignore = { "steel_ingot" }
|
||||||
|
@ -3,4 +3,4 @@ technic?
|
|||||||
technic_chests?
|
technic_chests?
|
||||||
technic_worldgen?
|
technic_worldgen?
|
||||||
intllib?
|
intllib?
|
||||||
|
drawers?
|
||||||
|
45
wrench/drawers.lua
Normal file
45
wrench/drawers.lua
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
if not minetest.get_modpath("drawers") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local INT, STRING =
|
||||||
|
wrench.META_TYPE_INT,
|
||||||
|
wrench.META_TYPE_STRING
|
||||||
|
|
||||||
|
-- assemble definitions for type 1,2 and 4
|
||||||
|
for _, drawer_type in ipairs({1,2,4}) do
|
||||||
|
|
||||||
|
local def = {
|
||||||
|
lists = {"upgrades"},
|
||||||
|
metas = {},
|
||||||
|
after_place = drawers.spawn_visuals
|
||||||
|
}
|
||||||
|
|
||||||
|
for i=1,drawer_type do
|
||||||
|
|
||||||
|
local suffix
|
||||||
|
if drawer_type == 1 then
|
||||||
|
-- no suffix for base type
|
||||||
|
suffix = ""
|
||||||
|
else
|
||||||
|
-- index as suffix
|
||||||
|
suffix = i
|
||||||
|
end
|
||||||
|
|
||||||
|
def.metas["name" .. suffix] = STRING
|
||||||
|
def.metas["count" .. suffix] = INT
|
||||||
|
def.metas["max_count" .. suffix] = INT
|
||||||
|
def.metas["base_stack_max" .. suffix] = INT
|
||||||
|
def.metas["entity_infotext" .. suffix] = STRING
|
||||||
|
def.metas["stack_max_factor" .. suffix] = INT
|
||||||
|
def.metas["meta_itemstack" .. suffix] = INT
|
||||||
|
def.metas["itemstack_wear" .. suffix] = INT
|
||||||
|
end
|
||||||
|
|
||||||
|
wrench:register_node("drawers:wood" .. drawer_type, def)
|
||||||
|
wrench:register_node("drawers:acacia_wood" .. drawer_type, def)
|
||||||
|
wrench:register_node("drawers:aspen_wood" .. drawer_type, def)
|
||||||
|
wrench:register_node("drawers:junglewood" .. drawer_type, def)
|
||||||
|
wrench:register_node("drawers:pine_wood" .. drawer_type, def)
|
||||||
|
|
||||||
|
end
|
@ -18,6 +18,7 @@ wrench = {}
|
|||||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||||
dofile(modpath.."/support.lua")
|
dofile(modpath.."/support.lua")
|
||||||
dofile(modpath.."/technic.lua")
|
dofile(modpath.."/technic.lua")
|
||||||
|
dofile(modpath.."/drawers.lua")
|
||||||
|
|
||||||
-- Boilerplate to support localized strings if intllib mod is installed.
|
-- Boilerplate to support localized strings if intllib mod is installed.
|
||||||
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
|
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
|
||||||
@ -79,7 +80,18 @@ for name, info in pairs(wrench.registered_nodes) do
|
|||||||
newdef.groups.not_in_creative_inventory = 1
|
newdef.groups.not_in_creative_inventory = 1
|
||||||
newdef.on_construct = nil
|
newdef.on_construct = nil
|
||||||
newdef.on_destruct = nil
|
newdef.on_destruct = nil
|
||||||
newdef.after_place_node = restore
|
newdef.after_place_node = function(pos, placer, itemstack)
|
||||||
|
|
||||||
|
-- call restoration function with on_plcae callbacks
|
||||||
|
local new_stack = restore(pos, placer, itemstack)
|
||||||
|
|
||||||
|
if type(info.after_place) == "function" then
|
||||||
|
-- call custom after_place function
|
||||||
|
info.after_place(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
return new_stack
|
||||||
|
end
|
||||||
minetest.register_node(":"..get_pickup_name(name), newdef)
|
minetest.register_node(":"..get_pickup_name(name), newdef)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -17,6 +17,7 @@ Syntax:
|
|||||||
|
|
||||||
wrench.META_TYPE_FLOAT = 1
|
wrench.META_TYPE_FLOAT = 1
|
||||||
wrench.META_TYPE_STRING = 2
|
wrench.META_TYPE_STRING = 2
|
||||||
|
wrench.META_TYPE_INT = 3
|
||||||
|
|
||||||
local STRING, FLOAT =
|
local STRING, FLOAT =
|
||||||
wrench.META_TYPE_STRING,
|
wrench.META_TYPE_STRING,
|
||||||
@ -68,4 +69,3 @@ function wrench:register_node(name, def)
|
|||||||
self.registered_nodes[name] = def
|
self.registered_nodes[name] = def
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user