Skip to content

Commit

Permalink
make the wifi chest pipeworkable (#16)
Browse files Browse the repository at this point in the history
* Make the wifi chest pipeworkable

* fix mod crashing without pipeworks
  • Loading branch information
Desour committed Oct 25, 2020
1 parent f7cfee8 commit cac8cdd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions mod.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name = more_chests
description = Adds several chests that behave differently, and can be used to donate items, share items, hide chests, make secret chests, and more.
depends = default
optional_depends = pipeworks
43 changes: 42 additions & 1 deletion wifi.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,55 @@
-- Load support for translation.
local S = minetest.get_translator("more_chests")

local pipeworks_enabled = minetest.global_exists("pipeworks")

minetest.register_node("more_chests:wifi", {
description = S("Wifi Chest"),
tiles = {"wifi_top.png", "wifi_top.png", "wifi_side.png",
"wifi_side.png", "wifi_side.png",
{name="wifi_front_animated.png", animation={type="vertical_frames",
aspect_w=16, aspect_h=16, length=2.0}}},
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,},
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, tubedevice = 1, tubedevice_receiver = 1},
-- Pipeworks
tube = pipeworks_enabled and {
insert_object = function(pos, node, stack, direction, owner)
if not owner then
return stack
end
local player = minetest.get_player_by_name(owner)
if not player then
return stack
end
local inv = player:get_inventory()
return inv:add_item("more_chests:wifi", stack)
end,
can_insert = function(pos, node, stack, direction, owner)
if not owner then
return false
end
local player = minetest.get_player_by_name(owner)
if not player then
return false
end
local inv = player:get_inventory()
return inv:room_for_item("more_chests:wifi", stack)
end,
input_inventory = "more_chests:wifi",
return_input_invref = function(pos, node, direction, player_name)
if not player_name then
return false
end
local player = minetest.get_player_by_name(player_name)
if not player then
return false
end
return player:get_inventory()
end,
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
} or nil,
after_place_node = pipeworks_enabled and pipeworks.after_place or nil,
after_dig_node = pipeworks_enabled and pipeworks.after_dig or nil,
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
Expand Down

0 comments on commit cac8cdd

Please sign in to comment.