1
0
mirror of https://github.com/mt-mods/homedecor_modpack.git synced 2024-12-22 16:10:18 +01:00

Merge pull request #314 from t4im/fix/itemstack

Various maintenance and fixes
This commit is contained in:
Vanessa Ezekowitz 2016-07-31 14:23:12 -04:00 committed by GitHub
commit 957ff25b9f
22 changed files with 88 additions and 49 deletions

View File

@ -70,7 +70,7 @@ minetest.register_node("chains:chain_top_brass", {
minetest.register_node("chains:chandelier", {
description = "Chandelier (wrought iron)",
paramtype = "light",
light_source = LIGHT_MAX-2,
light_source = default.LIGHT_MAX-2,
walkable = false,
climbable = true,
sunlight_propagates = true,
@ -97,7 +97,7 @@ minetest.register_node("chains:chandelier", {
minetest.register_node("chains:chandelier_brass", {
description = "Chandelier (brass)",
paramtype = "light",
light_source = LIGHT_MAX-2,
light_source = default.LIGHT_MAX-2,
walkable = false,
climbable = true,
sunlight_propagates = true,

View File

@ -29,6 +29,7 @@ minetest.register_node("computer:vanio", {
on_rightclick = function(pos, node, clicker, itemstack)
node.name = "computer:vanio_off"
minetest.set_node(pos, node)
return itemstack
end
})
@ -48,6 +49,7 @@ minetest.register_node("computer:vanio_off", {
on_rightclick = function(pos, node, clicker, itemstack)
node.name = "computer:vanio"
minetest.set_node(pos, node)
return itemstack
end
})
@ -168,6 +170,7 @@ minetest.register_node("computer:monitor", {
on_rightclick = function(pos, node, clicker, itemstack)
node.name = "computer:monitor_on"
minetest.set_node(pos, node)
return itemstack
end
})
@ -186,6 +189,7 @@ minetest.register_node("computer:monitor_on", {
on_rightclick = function(pos, node, clicker, itemstack)
node.name = "computer:monitor"
minetest.set_node(pos, node)
return itemstack
end
})
@ -294,12 +298,13 @@ minetest.register_node("computer:server", {
on_rightclick = function(pos, node, clicker, itemstack)
node.name = "computer:server_on"
minetest.set_node(pos, node)
return itemstack
end,
on_place = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.above
if minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name ~= "air" then
minetest.chat_send_player( placer:get_player_name(), "Not enough vertical space to place a server!" )
return
return itemstack
end
return minetest.item_place(itemstack, placer, pointed_thing)
end
@ -333,5 +338,6 @@ minetest.register_node("computer:server_on", {
on_rightclick = function(pos, node, clicker, itemstack)
node.name = "computer:server"
minetest.set_node(pos, node)
return itemstack
end
})

View File

@ -27,11 +27,12 @@ computer.register = function (name, def)
node_box = def.node_box,
selection_box = def.node_box,
on_rightclick = function (pos, node, clicker, itemstack)
if (def.on_turn_off) then
if (def.on_turn_off(pos, node, clicker, itemstack)) then return end
if def.on_turn_off and def.on_turn_off(pos, node, clicker, itemstack) then
return itemstack
end
node.name = OFFSTATE
minetest.set_node(pos, node)
return itemstack
end
})
minetest.register_node(OFFSTATE, {
@ -50,11 +51,12 @@ computer.register = function (name, def)
node_box = def.node_box_off or def.node_box,
selection_box = def.node_box_off or def.node_box,
on_rightclick = function (pos, node, clicker, itemstack)
if (def.on_turn_on) then
if (def.on_turn_on(pos, node, clicker, itemstack)) then return end
if def.on_turn_on and def.on_turn_on(pos, node, clicker, itemstack) then
return itemstack
end
node.name = ONSTATE
minetest.set_node(pos, node)
return itemstack
end,
drop = ONSTATE
})

View File

@ -276,7 +276,8 @@ minetest.register_node("computer:tetris_arcade", {
end
if minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name ~= "air" then
minetest.chat_send_player(placer:get_player_name(), "No room for place the Arcade!")
return end
return itemstack
end
local dir = placer:get_look_dir()
local node = {name="computer:tetris_arcade", param1=0, param2 = minetest.dir_to_facedir(dir)}
minetest.set_node(pos, node)

View File

@ -84,8 +84,9 @@ for _, f in ipairs(flame_types) do
{name=f.."_fire_animated.png", animation={type="vertical_frames",
aspect_w=16, aspect_h=16, length=1.5}},
},
on_rightclick = function (pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
start_smoke(pos, node, clicker)
return itemstack
end,
on_destruct = function (pos)
stop_smoke(pos)
@ -113,8 +114,9 @@ minetest.register_node("fake_fire:fancy_fire", {
tiles = {
{name="fake_fire_animated.png",
animation={type='vertical_frames', aspect_w=16, aspect_h=16, length=1}}, {name='fake_fire_logs.png'}},
on_rightclick = function (pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
start_smoke(pos, node, clicker)
return itemstack
end,
on_destruct = function (pos)
stop_smoke(pos)
@ -161,9 +163,10 @@ for _, m in ipairs(materials) do
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
on_rightclick = function (pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local chimney = 1
start_smoke(pos, node, clicker, chimney)
return itemstack
end,
on_destruct = function (pos)
stop_smoke(pos)

View File

@ -114,7 +114,7 @@ homedecor.register("sink", {
--Taps
local function taps_on_rightclick(pos, node, clicker)
local function taps_on_rightclick(pos, node, clicker, itemstack, pointed_thing)
local below = minetest.get_node_or_nil({x=pos.x, y=pos.y-1, z=pos.z})
if below and
below.name == "homedecor:shower_tray" or
@ -129,6 +129,7 @@ local function taps_on_rightclick(pos, node, clicker)
}
homedecor.start_particle_spawner(pos, node, particledef, "homedecor_faucet")
end
return itemstack
end
homedecor.register("taps", {
@ -225,7 +226,7 @@ homedecor.register("shower_head", {
selection_box = sh_cbox,
walkable = false,
on_rotate = screwdriver.disallow,
on_rightclick = function (pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local below = minetest.get_node_or_nil({x=pos.x, y=pos.y-2.0, z=pos.z})
if below and below.name == "homedecor:shower_tray" then
local particledef = {
@ -237,6 +238,7 @@ homedecor.register("shower_head", {
}
homedecor.start_particle_spawner(pos, node, particledef, "homedecor_shower")
end
return itemstack
end,
on_destruct = function(pos)
homedecor.stop_particle_spawner(pos)

View File

@ -79,10 +79,11 @@ for i in ipairs(bedcolors) do
after_dig_node = function(pos)
homedecor.unextend_bed(pos, color)
end,
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
if minetest.get_modpath("beds") then
beds.on_rightclick(pos, clicker)
else return end
end
return itemstack
end
})
@ -104,10 +105,11 @@ for i in ipairs(bedcolors) do
after_dig_node = function(pos)
homedecor.unextend_bed(pos, color)
end,
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
if minetest.get_modpath("beds") then
beds.on_rightclick(pos, clicker)
else return end
end
return itemstack
end,
drop = "homedecor:bed_"..color.."_regular"
})
@ -137,10 +139,11 @@ for i in ipairs(bedcolors) do
inv:add_item("main", "homedecor:bed_"..color.."_regular 2")
end
end,
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
if minetest.get_modpath("beds") then
beds.on_rightclick(pos, clicker)
else return end
end
return itemstack
end
})

View File

@ -112,7 +112,7 @@ for c in ipairs(bookcolors) do
drop = "homedecor:book_"..color,
walkable = false,
on_dig = book_dig,
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local meta = minetest.get_meta(pos)
local player_name = clicker:get_player_name()
local title = meta:get_string("title") or ""
@ -136,6 +136,7 @@ for c in ipairs(bookcolors) do
end
player_current_book[player_name] = pos
minetest.show_formspec(player_name, BOOK_FORMNAME, formspec)
return itemstack
end,
on_punch = function(pos, node, puncher, pointed_thing)
local fdir = node.param2

View File

@ -111,7 +111,7 @@ homedecor.register("ceiling_fan", {
}
},
groups = { snappy = 3 },
light_source = LIGHT_MAX-1,
light_source = default.LIGHT_MAX-1,
sounds = default.node_sound_glass_defaults(),
})

View File

@ -252,8 +252,9 @@ for i in ipairs(sides) do
on_construct = function(pos)
minetest.get_meta(pos):set_int("closed", 1)
end,
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
homedecor.flip_door(pos, node, clicker, doorname, side)
return itemstack
end,
-- both left and right doors may be used for open or closed doors
-- so they have to have both action_on and action_off and just
@ -385,8 +386,9 @@ for i in ipairs(gates_list) do
type = "fixed",
fixed = gate_models_closed[i]
},
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
homedecor.flip_gate(pos, node, clicker, gate, "closed")
return itemstack
end,
mesecons = {
effector = {
@ -413,8 +415,9 @@ for i in ipairs(gates_list) do
tiles[3]
}
def.drop = "homedecor:gate_"..gate.."_closed"
def.on_rightclick = function(pos, node, clicker)
def.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
homedecor.flip_gate(pos, node, clicker, gate, "open")
return itemstack
end
def.mesecons.effector = {
action_off = function(pos,node) homedecor.flip_gate(pos,node,player,gate, "open") end
@ -605,8 +608,9 @@ homedecor.register("door_japanese_closed", {
fixed = {-0.5, -0.5, -0.0625, 0.5, 1.5, 0},
},
expand = { top = "placeholder" },
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
minetest.set_node(pos, {name = "homedecor:door_japanese_open", param2 = node.param2})
return itemstack
end
})
@ -628,8 +632,9 @@ homedecor.register("door_japanese_open", {
fixed = {-1.5, -0.5, -0.0625, -0.5, 1.5, 0},
},
expand = { top = "placeholder" },
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
minetest.set_node(pos, {name = "homedecor:door_japanese_closed", param2 = node.param2})
return itemstack
end,
drop = "homedecor:door_japanese_closed",
})

View File

@ -84,9 +84,10 @@ for i in ipairs(chaircolors) do
collision_box = kc_cbox,
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
pos.y = pos.y+0 -- where do I put my ass ?
homedecor.sit(pos, node, clicker)
return itemstack
end
})

View File

@ -169,7 +169,7 @@ homedecor.register("toaster", {
{-0.0625, -0.5, -0.125, 0.125, -0.3125, 0.125}, -- NodeBox1
},
},
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local fdir = node.param2
minetest.set_node(pos, { name = "homedecor:toaster_loaf", param2 = fdir })
minetest.sound_play("toaster", {
@ -177,6 +177,7 @@ homedecor.register("toaster", {
gain = 1.0,
max_hear_distance = 5
})
return itemstack
end
})
@ -199,9 +200,10 @@ homedecor.register("toaster_loaf", {
{0.0625, -0.3125, -0.0935, 0.0935, -0.25, 0.0935}, -- NodeBox3
},
},
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local fdir = node.param2
minetest.set_node(pos, { name = "homedecor:toaster", param2 = fdir })
return itemstack
end,
drop = "homedecor:toaster"
})

View File

@ -117,7 +117,7 @@ homedecor.register("kitchen_faucet", {
selection_box = kf_cbox,
walkable = false,
on_rotate = screwdriver.disallow,
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local below = minetest.get_node_or_nil({x=pos.x, y=pos.y-1, z=pos.z})
if below and
below.name == "homedecor:sink" or
@ -131,6 +131,7 @@ homedecor.register("kitchen_faucet", {
}
homedecor.start_particle_spawner(pos, node, particledef, "homedecor_faucet")
end
return itemstack
end,
on_destruct = homedecor.stop_particle_spawner
})

View File

@ -179,8 +179,9 @@ homedecor.register("fishtank", {
collision_box = ft_cbox,
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
minetest.set_node(pos, {name = "homedecor:fishtank_lighted", param2 = node.param2})
return itemstack
end
})
@ -195,14 +196,15 @@ homedecor.register("fishtank_lighted", {
"homedecor_fishtank_water_top_lighted.png",
"homedecor_fishtank_sides_lighted.png",
},
light_source = LIGHT_MAX-4,
light_source = default.LIGHT_MAX-4,
use_texture_alpha = true,
selection_box = ft_cbox,
collision_box = ft_cbox,
groups = {cracky=3,oddly_breakable_by_hand=3,not_in_creative_inventory=1},
sounds = default.node_sound_glass_defaults(),
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
minetest.set_node(pos, {name = "homedecor:fishtank", param2 = node.param2})
return itemstack
end,
drop = "homedecor:fishtank",
})

View File

@ -81,10 +81,11 @@ homedecor.register("calendar", {
legacy_wallmounted = true,
sounds = default.node_sound_defaults(),
infotext = "Date (right-click to update):\n" .. os.date("%Y-%m-%d"), -- ISO 8601 format
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local meta = minetest.get_meta(pos)
local date = os.date("%Y-%m-%d")
meta:set_string("infotext", "Date (right-click to update):\n"..date)
return itemstack
end
})

View File

@ -125,12 +125,13 @@ for c in ipairs(curtaincolors) do
paramtype2 = 'wallmounted',
selection_box = { type = "wallmounted" },
-- Open the curtains
on_rightclick = function(pos, node, clicker, itemstack)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local topnode = minetest.get_node({x=pos.x, y=pos.y+1.0, z=pos.z})
if string.find(topnode.name, "homedecor:curtainrod") then
local fdir = node.param2
minetest.set_node(pos, { name = "homedecor:curtain_open_"..color, param2 = fdir })
end
return itemstack
end
})
@ -147,12 +148,13 @@ for c in ipairs(curtaincolors) do
paramtype2 = 'wallmounted',
selection_box = { type = "wallmounted" },
-- Close the curtains
on_rightclick = function(pos, node, clicker, itemstack)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local topnode = minetest.get_node({x=pos.x, y=pos.y+1.0, z=pos.z})
if string.find(topnode.name, "homedecor:curtainrod") then
local fdir = node.param2
minetest.set_node(pos, { name = "homedecor:curtain_"..color, param2 = fdir })
end
return itemstack
end
})

View File

@ -57,12 +57,14 @@ minetest.register_node("inbox:empty", {
"default:chest_locked",
inbox.get_inbox_insert_formspec(pos))
end
return itemstack
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local name = player and player:get_player_name()
local owner = meta:get_string("owner")
local inv = meta:get_inventory()
return player:get_player_name() == owner and inv:is_empty("main")
return player == owner and inv:is_empty("main")
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)

View File

@ -141,9 +141,9 @@ minetest.register_node("itemframes:frame",{
end
end,
can_dig = function(pos,player)
local name = player and player:get_player_name()
local meta = minetest.get_meta(pos)
return player:get_player_name() == meta:get_string("owner")
return name == meta:get_string("owner")
end,
on_destruct = function(pos)
local meta = minetest.get_meta(pos)
@ -198,9 +198,9 @@ minetest.register_node("itemframes:pedestal",{
end
end,
can_dig = function(pos,player)
local name = player and player:get_player_name()
local meta = minetest.get_meta(pos)
return player:get_player_name() == meta:get_string("owner")
return name == meta:get_string("owner")
end,
on_destruct = function(pos)
local meta = minetest.get_meta(pos)

View File

@ -39,9 +39,10 @@ for i in ipairs(lavalamps_list) do
},
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
node.name = "lavalamp:"..colour.."_off"
minetest.set_node(pos, node)
return itemstack
end,
})
@ -64,9 +65,10 @@ for i in ipairs(lavalamps_list) do
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3, not_in_creative_inventory=1},
sounds = default.node_sound_glass_defaults(),
drop = "lavalamp:"..colour,
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
node.name = "lavalamp:"..colour
minetest.set_node(pos, node)
return itemstack
end,
})

View File

@ -24,13 +24,14 @@ for i in ipairs(lrfurn.colors) do
groups = {snappy=3},
sounds = default.node_sound_wood_defaults(),
node_box = armchair_cbox,
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
if not clicker:is_player() then
return
return itemstack
end
pos.y = pos.y-0.5
clicker:setpos(pos)
clicker:set_hp(20)
return itemstack
end
})

View File

@ -46,13 +46,14 @@ for i in ipairs(lrfurn.colors) do
end
return itemstack
end,
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
if not clicker:is_player() then
return
return itemstack
end
pos.y = pos.y-0.5
clicker:setpos(pos)
clicker:set_hp(20)
return itemstack
end
})

View File

@ -48,13 +48,14 @@ for i in ipairs(lrfurn.colors) do
end
return itemstack
end,
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
if not clicker:is_player() then
return
return itemstack
end
pos.y = pos.y-0.5
clicker:setpos(pos)
clicker:set_hp(20)
return itemstack
end
})