Add on_blast handlers
This commit is contained in:
parent
3965933846
commit
e37a327252
@ -60,6 +60,7 @@ The following bugs of X-Decor (as of 30/06/2023) are fixed:
|
||||
* Fix boiling water sound not playing when rejoining
|
||||
* Fix rope and painting not compatible with itemframe
|
||||
* Fix itemframe, lever being offset when put into itemframe
|
||||
* Fix storage formspecs not closing if exploded
|
||||
* Show short item description in itemframe instead of itemstring
|
||||
* Made several strings translatable
|
||||
* Minor typo fixes
|
||||
@ -80,6 +81,7 @@ Maintenance updates:
|
||||
* Improved side texture of wood frame
|
||||
* Add honey and cushion block to creative inventory
|
||||
* Doors now count as nodes in creative inventory
|
||||
* Storage blocks now drop their inventory when exploded
|
||||
* Translation updates
|
||||
* Add support for playerphysics mod
|
||||
* Add description to every setting
|
||||
|
@ -58,3 +58,11 @@ function xdecor.stairs_valid_def(def)
|
||||
def.description ~= "" and
|
||||
def.light_source == 0
|
||||
end
|
||||
|
||||
function xdecor.get_inventory_drops(pos, listnames)
|
||||
local drops = {}
|
||||
for l=1, #listnames do
|
||||
default.get_inventory_drops(pos, listnames[l], drops)
|
||||
end
|
||||
return drops
|
||||
end
|
||||
|
@ -1422,6 +1422,10 @@ function realchess.dig(pos, player)
|
||||
timeout_format(timeout_limit)))
|
||||
end
|
||||
|
||||
function realchess.blast(pos)
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
|
||||
minetest.register_node(":realchess:chessboard", {
|
||||
description = S("Chess Board"),
|
||||
drawtype = "nodebox",
|
||||
@ -1436,6 +1440,7 @@ minetest.register_node(":realchess:chessboard", {
|
||||
node_box = {type = "fixed", fixed = {-.375, -.5, -.375, .375, -.4375, .375}},
|
||||
sunlight_propagates = true,
|
||||
on_rotate = screwdriver.rotate_simple,
|
||||
on_blast = realchess.blast,
|
||||
can_dig = realchess.dig,
|
||||
on_construct = realchess.init,
|
||||
on_receive_fields = realchess.fields,
|
||||
|
@ -133,6 +133,12 @@ function enchanting.dig(pos)
|
||||
return inv:is_empty("tool") and inv:is_empty("mese")
|
||||
end
|
||||
|
||||
function enchanting.blast(pos)
|
||||
local drops = xdecor.get_inventory_drops(pos, {"tool", "mese"})
|
||||
minetest.remove_node(pos)
|
||||
return drops
|
||||
end
|
||||
|
||||
local function allowed(tool)
|
||||
if not tool then return end
|
||||
|
||||
@ -226,6 +232,7 @@ xdecor.register("enchantment_table", {
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_rotate = screwdriver.rotate_simple,
|
||||
can_dig = enchanting.dig,
|
||||
on_blast = enchanting.blast,
|
||||
on_timer = enchanting.timer,
|
||||
on_construct = enchanting.construct,
|
||||
on_destruct = enchanting.destruct,
|
||||
|
@ -113,6 +113,12 @@ function hive.timer(pos)
|
||||
return true
|
||||
end
|
||||
|
||||
function hive.blast(pos)
|
||||
local drops = xdecor.get_inventory_drops(pos, {"honey"})
|
||||
minetest.remove_node(pos)
|
||||
return drops
|
||||
end
|
||||
|
||||
xdecor.register("hive", {
|
||||
description = S("Artificial Hive"),
|
||||
tiles = {"xdecor_hive_top.png", "xdecor_hive_top.png",
|
||||
@ -122,6 +128,7 @@ xdecor.register("hive", {
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = hive.construct,
|
||||
on_timer = hive.timer,
|
||||
on_blast = hive.blast,
|
||||
|
||||
can_dig = function(pos)
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
|
@ -152,6 +152,10 @@ function itemframe.dig(pos, player)
|
||||
return admin or player_name == owner
|
||||
end
|
||||
|
||||
function itemframe.blast(pos)
|
||||
return
|
||||
end
|
||||
|
||||
xdecor.register("itemframe", {
|
||||
description = S("Item Frame"),
|
||||
groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
|
||||
@ -169,6 +173,7 @@ xdecor.register("itemframe", {
|
||||
on_rightclick = itemframe.rightclick,
|
||||
on_punch = itemframe.punch,
|
||||
can_dig = itemframe.dig,
|
||||
on_blast = itemframe.blast,
|
||||
after_destruct = remove_item,
|
||||
_xdecor_itemframe_offset = -3.5,
|
||||
})
|
||||
|
@ -98,6 +98,10 @@ function mailbox.dig(pos, player)
|
||||
return inv:is_empty("mailbox") and player_name == owner
|
||||
end
|
||||
|
||||
function mailbox.blast(pos)
|
||||
return
|
||||
end
|
||||
|
||||
function mailbox.after_place_node(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local player_name = placer:get_player_name()
|
||||
@ -176,6 +180,7 @@ xdecor.register("mailbox", {
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
on_rotate = screwdriver.rotate_simple,
|
||||
can_dig = mailbox.dig,
|
||||
on_blast = mailbox.blast,
|
||||
on_rightclick = mailbox.rightclick,
|
||||
allow_metadata_inventory_take = mailbox.allow_take,
|
||||
allow_metadata_inventory_move = mailbox.allow_move,
|
||||
|
@ -78,6 +78,12 @@ xdecor.register("barrel", {
|
||||
sounds = default.node_sound_wood_defaults()
|
||||
})
|
||||
|
||||
local function blast_storage(pos)
|
||||
local drops = xdecor.get_inventory_drops(pos, {"main"})
|
||||
minetest.remove_node(pos)
|
||||
return drops
|
||||
end
|
||||
|
||||
local function register_storage(name, desc, def)
|
||||
xdecor.register(name, {
|
||||
description = desc,
|
||||
@ -88,6 +94,7 @@ local function register_storage(name, desc, def)
|
||||
node_box = def.node_box,
|
||||
on_rotate = def.on_rotate,
|
||||
on_place = def.on_place,
|
||||
on_blast = blast_storage,
|
||||
groups = def.groups or {choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
|
||||
sounds = default.node_sound_wood_defaults()
|
||||
})
|
||||
|
@ -156,6 +156,12 @@ function workbench.dig(pos)
|
||||
inv:is_empty("tool") and inv:is_empty("storage")
|
||||
end
|
||||
|
||||
function workbench.blast(pos)
|
||||
local drops = xdecor.get_inventory_drops(pos, {"input", "hammer", "tool", "storage"})
|
||||
minetest.remove_node(pos)
|
||||
return drops
|
||||
end
|
||||
|
||||
function workbench.timer(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
@ -257,6 +263,7 @@ xdecor.register("workbench", {
|
||||
},
|
||||
on_rotate = screwdriver.rotate_simple,
|
||||
can_dig = workbench.dig,
|
||||
on_blast = workbench.blast,
|
||||
on_timer = workbench.timer,
|
||||
on_construct = workbench.construct,
|
||||
on_receive_fields = workbench.fields,
|
||||
|
Loading…
Reference in New Issue
Block a user