mirror of
https://github.com/mt-mods/pipeworks.git
synced 2024-11-18 16:20:42 +01:00
MineClone containers support (#81)
* mcl_barrels compat * open barrel is not in creative inv * fix barrel drop content after dig * fix barrel local var * mcl_furnaces compat * optional depends mcl_barrels and mcl_furnaces * fixing luacheck * .luacheckrc update * renamed files to use _ * renamed files to init.lua * format improvement
This commit is contained in:
parent
cb3e7757fc
commit
500cce8668
@ -20,6 +20,6 @@ read_globals = {
|
||||
-- mods
|
||||
"default", "mesecon", "digiline",
|
||||
"screwdriver", "unified_inventory",
|
||||
"i3",
|
||||
"i3", "mcl_experience", "awards"
|
||||
|
||||
}
|
||||
|
6
init.lua
6
init.lua
@ -182,6 +182,12 @@ if pipeworks.enable_redefines and (minetest.get_modpath("default") or minetest.g
|
||||
dofile(pipeworks.modpath.."/compat-chests.lua")
|
||||
dofile(pipeworks.modpath.."/compat-furnaces.lua")
|
||||
end
|
||||
if pipeworks.enable_redefines and minetest.get_modpath("mcl_barrels") then
|
||||
dofile(pipeworks.modpath.."/mcl_barrels.lua")
|
||||
end
|
||||
if pipeworks.enable_redefines and minetest.get_modpath("mcl_furnaces") then
|
||||
dofile(pipeworks.modpath.."/mcl_furnaces.lua")
|
||||
end
|
||||
if pipeworks.enable_autocrafter then
|
||||
dofile(pipeworks.modpath.."/autocrafter.lua")
|
||||
end
|
||||
|
72
mcl_barrels.lua
Normal file
72
mcl_barrels.lua
Normal file
@ -0,0 +1,72 @@
|
||||
-- this bit of code modifies the mcl barrels to be compatible with
|
||||
-- pipeworks.
|
||||
|
||||
-- Pipeworks Specific
|
||||
local tube_entry = "^pipeworks_tube_connection_wooden.png"
|
||||
|
||||
-- Original Definitions
|
||||
local old_barrel = table.copy(minetest.registered_items["mcl_barrels:barrel_closed"])
|
||||
|
||||
local groups = old_barrel.groups
|
||||
groups["tubedevice"] = 1
|
||||
groups["tubedevice_receiver"] = 1
|
||||
local groups_open = table.copy(groups)
|
||||
groups_open["not_in_creative_inventory"] = 1
|
||||
|
||||
|
||||
-- Override Construction
|
||||
local override_barrel = {}
|
||||
|
||||
override_barrel.tiles = {
|
||||
"mcl_barrels_barrel_top.png^[transformR270",
|
||||
"mcl_barrels_barrel_bottom.png"..tube_entry,
|
||||
"mcl_barrels_barrel_side.png"..tube_entry
|
||||
}
|
||||
|
||||
override_barrel.after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
old_barrel.after_place_node(pos, placer, itemstack, pointed_thing)
|
||||
pipeworks.after_place(pos, placer, itemstack, pointed_thing)
|
||||
end
|
||||
|
||||
override_barrel.tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("main", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if meta:get_int("splitstacks") == 1 then
|
||||
stack = stack:peek_item(1)
|
||||
end
|
||||
return inv:room_for_item("main", stack)
|
||||
end,
|
||||
input_inventory = "main",
|
||||
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1}
|
||||
}
|
||||
|
||||
override_barrel.after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
old_barrel.after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
pipeworks.after_dig(pos)
|
||||
end
|
||||
|
||||
override_barrel.groups = table.copy(old_barrel.groups)
|
||||
|
||||
override_barrel.on_rotate = pipeworks.on_rotate
|
||||
|
||||
|
||||
local override_barrel_open = table.copy(override_barrel)
|
||||
|
||||
override_barrel_open.tiles = {
|
||||
"mcl_barrels_barrel_top_open.png",
|
||||
"mcl_barrels_barrel_bottom.png"..tube_entry,
|
||||
"mcl_barrels_barrel_side.png"..tube_entry
|
||||
}
|
||||
|
||||
override_barrel_open.groups = groups_open
|
||||
|
||||
|
||||
-- Override with the new modifications.
|
||||
minetest.override_item("mcl_barrels:barrel_closed", override_barrel)
|
||||
minetest.override_item("mcl_barrels:barrel_open", override_barrel_open)
|
132
mcl_furnaces.lua
Normal file
132
mcl_furnaces.lua
Normal file
@ -0,0 +1,132 @@
|
||||
|
||||
local old_furnace = table.copy(minetest.registered_nodes["mcl_furnaces:furnace"])
|
||||
|
||||
local tube_entry = "^pipeworks_tube_connection_stony.png"
|
||||
|
||||
local groups = old_furnace.groups
|
||||
groups["tubedevice"] = 1
|
||||
groups["tubedevice_receiver"] = 1
|
||||
local groups_active = table.copy(groups)
|
||||
groups_active["not_in_creative_inventory"] = 1
|
||||
|
||||
-- a hack to give the exp to fake players it's be dropped instead added to (fake) player inv
|
||||
local function give_xp(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local dir = vector.divide(minetest.facedir_to_dir(minetest.get_node(pos).param2),-1.95)
|
||||
local xp = meta:get_int("xp")
|
||||
if xp > 0 then
|
||||
mcl_experience.throw_xp(vector.add(pos, dir), xp)
|
||||
meta:set_int("xp", 0)
|
||||
end
|
||||
end
|
||||
|
||||
local override = {}
|
||||
|
||||
override.tiles = {
|
||||
"default_furnace_top.png"..tube_entry,
|
||||
"default_furnace_bottom.png"..tube_entry,
|
||||
"default_furnace_side.png"..tube_entry,
|
||||
"default_furnace_side.png"..tube_entry,
|
||||
"default_furnace_side.png"..tube_entry,
|
||||
"default_furnace_front.png"
|
||||
}
|
||||
|
||||
override.groups = groups
|
||||
|
||||
override.tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
if not timer:is_started() then
|
||||
timer:start(1.0)
|
||||
end
|
||||
if direction.y == 1 then
|
||||
return inv:add_item("fuel", stack)
|
||||
else
|
||||
return inv:add_item("src", stack)
|
||||
end
|
||||
end,
|
||||
can_insert = function(pos,node,stack,direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if direction.y == 1 then
|
||||
return inv:room_for_item("fuel", stack)
|
||||
else
|
||||
if meta:get_int("split_material_stacks") == 1 then
|
||||
stack = stack:peek_item(1)
|
||||
end
|
||||
return inv:room_for_item("src", stack)
|
||||
end
|
||||
end,
|
||||
input_inventory = "dst",
|
||||
connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
|
||||
}
|
||||
|
||||
override.after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
pipeworks.after_place(pos, placer, itemstack, pointed_thing)
|
||||
end
|
||||
|
||||
override.after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
old_furnace.after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
pipeworks.after_dig(pos)
|
||||
end
|
||||
|
||||
override.on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
if listname == "dst" then
|
||||
if stack:get_name() == "mcl_core:iron_ingot" then
|
||||
awards.unlock(player:get_player_name(), "mcl:acquireIron")
|
||||
elseif stack:get_name() == "mcl_fishing:fish_cooked" then
|
||||
awards.unlock(player:get_player_name(), "mcl:cookFish")
|
||||
end
|
||||
give_xp(pos, player)
|
||||
end
|
||||
end
|
||||
|
||||
override.on_rotate = pipeworks.on_rotate
|
||||
|
||||
|
||||
local override_active = table.copy(override)
|
||||
|
||||
override_active.tiles = {
|
||||
"default_furnace_top.png"..tube_entry,
|
||||
"default_furnace_bottom.png"..tube_entry,
|
||||
"default_furnace_side.png"..tube_entry,
|
||||
"default_furnace_side.png"..tube_entry,
|
||||
"default_furnace_side.png"..tube_entry,
|
||||
"default_furnace_front_active.png",
|
||||
}
|
||||
|
||||
override_active.groups = groups_active
|
||||
|
||||
override_active.tube = {
|
||||
insert_object = function(pos,node,stack,direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
if not timer:is_started() then
|
||||
timer:start(1.0)
|
||||
end
|
||||
if direction.y == 1 then
|
||||
return inv:add_item("fuel", stack)
|
||||
else
|
||||
return inv:add_item("src", stack)
|
||||
end
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if direction.y == 1 then
|
||||
return inv:room_for_item("fuel", stack)
|
||||
else
|
||||
return inv:room_for_item("src", stack)
|
||||
end
|
||||
end,
|
||||
input_inventory = "dst",
|
||||
connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
|
||||
}
|
||||
|
||||
|
||||
-- override
|
||||
minetest.override_item("mcl_furnaces:furnace", override)
|
||||
minetest.override_item("mcl_furnaces:furnace_active", override_active)
|
2
mod.conf
2
mod.conf
@ -1,5 +1,5 @@
|
||||
name = pipeworks
|
||||
description = This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them.
|
||||
depends = basic_materials
|
||||
optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3, hades_core, hades_furnaces, hades_chests, mcl_mapgen_core
|
||||
optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3, hades_core, hades_furnaces, hades_chests, mcl_mapgen_core, mcl_barrels, mcl_furnaces, mcl_experience
|
||||
min_minetest_version = 5.4.0
|
||||
|
Loading…
Reference in New Issue
Block a user