mirror of
https://github.com/mt-mods/pipeworks.git
synced 2025-06-29 06:40:37 +02:00
Better Hades Revisited support (#30)
* Fix spaces vs tabs in crafts.lua * Fix recipes, add telepoter device for teleporter tube recipe. * Override chests and furnaces in Hades as well.
This commit is contained in:
@ -11,33 +11,72 @@ local tube_entry = "^pipeworks_tube_connection_wooden.png"
|
||||
-- Chest Locals
|
||||
local open_chests = {}
|
||||
|
||||
local function get_chest_formspec(pos)
|
||||
local spos = pos.x .. "," .. pos.y .. "," .. pos.z
|
||||
local formspec =
|
||||
"size[8,9]" ..
|
||||
default.gui_bg ..
|
||||
default.gui_bg_img ..
|
||||
default.gui_slots ..
|
||||
"list[nodemeta:" .. spos .. ";main;0,0.3;8,4;]" ..
|
||||
"list[current_player;main;0,4.85;8,1;]" ..
|
||||
"list[current_player;main;0,6.08;8,3;8]" ..
|
||||
"listring[nodemeta:" .. spos .. ";main]" ..
|
||||
"listring[current_player;main]" ..
|
||||
default.get_hotbar_bg(0,4.85)
|
||||
local get_chest_formspec
|
||||
|
||||
-- Pipeworks Switch
|
||||
formspec = formspec ..
|
||||
fs_helpers.cycling_button(
|
||||
minetest.get_meta(pos),
|
||||
pipeworks.button_base,
|
||||
"splitstacks",
|
||||
{
|
||||
pipeworks.button_off,
|
||||
pipeworks.button_on
|
||||
}
|
||||
)..pipeworks.button_label
|
||||
if minetest.get_modpath("default") then
|
||||
function get_chest_formspec(pos)
|
||||
local spos = pos.x .. "," .. pos.y .. "," .. pos.z
|
||||
local formspec =
|
||||
"size[8,9]" ..
|
||||
default.gui_bg ..
|
||||
default.gui_bg_img ..
|
||||
default.gui_slots ..
|
||||
"list[nodemeta:" .. spos .. ";main;0,0.3;8,4;]" ..
|
||||
"list[current_player;main;0,4.85;8,1;]" ..
|
||||
"list[current_player;main;0,6.08;8,3;8]" ..
|
||||
"listring[nodemeta:" .. spos .. ";main]" ..
|
||||
"listring[current_player;main]" ..
|
||||
default.get_hotbar_bg(0,4.85)
|
||||
|
||||
return formspec
|
||||
-- Pipeworks Switch
|
||||
formspec = formspec ..
|
||||
fs_helpers.cycling_button(
|
||||
minetest.get_meta(pos),
|
||||
pipeworks.button_base,
|
||||
"splitstacks",
|
||||
{
|
||||
pipeworks.button_off,
|
||||
pipeworks.button_on
|
||||
}
|
||||
)..pipeworks.button_label
|
||||
|
||||
return formspec
|
||||
end
|
||||
else
|
||||
local function get_hotbar_bg(x,y)
|
||||
local out = ""
|
||||
for i=0,7,1 do
|
||||
out = out .."image["..x+i..","..y..";1,1;gui_hb_bg.png]"
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
function get_chest_formspec(pos)
|
||||
local spos = pos.x .. "," .. pos.y .. "," .. pos.z
|
||||
local formspec =
|
||||
"size[10,9]" ..
|
||||
"background9[8,8;8,9;hades_chests_chestui.png;true;8]"..
|
||||
"list[nodemeta:" .. spos .. ";main;0,0.3;10,4;]" ..
|
||||
"list[current_player;main;0,4.85;10,1;]" ..
|
||||
"list[current_player;main;0,6.08;10,3;10]" ..
|
||||
"listring[nodemeta:" .. spos .. ";main]" ..
|
||||
"listring[current_player;main]" ..
|
||||
get_hotbar_bg(0,4.85)
|
||||
|
||||
-- Pipeworks Switch
|
||||
formspec = formspec ..
|
||||
fs_helpers.cycling_button(
|
||||
minetest.get_meta(pos),
|
||||
pipeworks.button_base,
|
||||
"splitstacks",
|
||||
{
|
||||
pipeworks.button_off,
|
||||
pipeworks.button_on
|
||||
}
|
||||
)..pipeworks.button_label
|
||||
|
||||
return formspec
|
||||
end
|
||||
end
|
||||
|
||||
local function chest_lid_obstructed(pos)
|
||||
@ -71,7 +110,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
end
|
||||
end
|
||||
minetest.after(0.2, function()
|
||||
minetest.swap_node(pos, { name = "default:" .. swap, param2 = node.param2 })
|
||||
if minetest.get_modpath("default") then
|
||||
minetest.swap_node(pos, { name = "default:" .. swap, param2 = node.param2 })
|
||||
end
|
||||
|
||||
-- Pipeworks notification
|
||||
pipeworks.after_place(pos)
|
||||
@ -88,10 +129,18 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
end)
|
||||
|
||||
-- Original Definitions
|
||||
local old_chest_def = table.copy(minetest.registered_items["default:chest"])
|
||||
local old_chest_open_def = table.copy(minetest.registered_items["default:chest_open"])
|
||||
local old_chest_locked_def = table.copy(minetest.registered_items["default:chest_locked"])
|
||||
local old_chest_locked_open_def = table.copy(minetest.registered_items["default:chest_locked_open"])
|
||||
local old_chest_def, old_chest_open_def, old_chest_locked_def, old_chest_locked_open_def
|
||||
if minetest.get_modpath("default") then
|
||||
old_chest_def = table.copy(minetest.registered_items["default:chest"])
|
||||
old_chest_open_def = table.copy(minetest.registered_items["default:chest_open"])
|
||||
old_chest_locked_def = table.copy(minetest.registered_items["default:chest_locked"])
|
||||
old_chest_locked_open_def = table.copy(minetest.registered_items["default:chest_locked_open"])
|
||||
elseif minetest.get_modpath("hades_chests") then
|
||||
old_chest_def = table.copy(minetest.registered_items["hades_chests:chest"])
|
||||
old_chest_open_def = table.copy(minetest.registered_items["hades_chests:chest"])
|
||||
old_chest_locked_def = table.copy(minetest.registered_items["hades_chests:chest_locked"])
|
||||
old_chest_locked_open_def = table.copy(minetest.registered_items["hades_chests:chest_locked"])
|
||||
end
|
||||
|
||||
-- Override Construction
|
||||
local override_protected, override, override_open, override_protected_open
|
||||
@ -116,9 +165,11 @@ override_protected = {
|
||||
minetest.sound_play(old_chest_locked_def.sound_open, {gain = 0.3,
|
||||
pos = pos, max_hear_distance = 10})
|
||||
if not chest_lid_obstructed(pos) then
|
||||
minetest.swap_node(pos,
|
||||
{ name = "default:" .. "chest_locked" .. "_open",
|
||||
param2 = node.param2 })
|
||||
if minetest.get_modpath("default") then
|
||||
minetest.swap_node(pos,
|
||||
{ name = "default:" .. "chest_locked" .. "_open",
|
||||
param2 = node.param2 })
|
||||
end
|
||||
end
|
||||
minetest.after(0.2, minetest.show_formspec,
|
||||
clicker:get_player_name(),
|
||||
@ -160,9 +211,11 @@ override = {
|
||||
minetest.sound_play(old_chest_def.sound_open, {gain = 0.3, pos = pos,
|
||||
max_hear_distance = 10})
|
||||
if not chest_lid_obstructed(pos) then
|
||||
minetest.swap_node(pos, {
|
||||
name = "default:" .. "chest" .. "_open",
|
||||
param2 = node.param2 })
|
||||
if minetest.get_modpath("default") then
|
||||
minetest.swap_node(pos, {
|
||||
name = "default:" .. "chest" .. "_open",
|
||||
param2 = node.param2 })
|
||||
end
|
||||
end
|
||||
minetest.after(0.2, minetest.show_formspec,
|
||||
clicker:get_player_name(),
|
||||
@ -236,8 +289,15 @@ for _,v in ipairs({override_protected, override, override_open, override_protect
|
||||
end
|
||||
|
||||
-- Override with the new modifications.
|
||||
minetest.override_item("default:chest", override)
|
||||
minetest.override_item("default:chest_open", override_open)
|
||||
minetest.override_item("default:chest_locked", override_protected)
|
||||
minetest.override_item("default:chest_locked_open", override_protected_open)
|
||||
if minetest.get_modpath("default") then
|
||||
minetest.override_item("default:chest", override)
|
||||
minetest.override_item("default:chest_open", override_open)
|
||||
minetest.override_item("default:chest_locked", override_protected)
|
||||
minetest.override_item("default:chest_locked_open", override_protected_open)
|
||||
elseif minetest.get_modpath("hades_chests") then
|
||||
minetest.override_item("hades_chests:chest", override)
|
||||
--minetest.override_item("hades_chests:chest_open", override_open)
|
||||
minetest.override_item("hades_chests:chest_locked", override_protected)
|
||||
--minetest.override_item("hades_chests:chest_locked_open", override_protected_open)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user