parent
da0cad8af7
commit
55189a57f8
@ -449,8 +449,9 @@ minetest.register_craftitem("carts:cart", {
|
|||||||
minetest.sound_play({name = "default_place_node_metal", gain = 0.5},
|
minetest.sound_play({name = "default_place_node_metal", gain = 0.5},
|
||||||
{pos = pointed_thing.above}, true)
|
{pos = pointed_thing.above}, true)
|
||||||
|
|
||||||
|
local player_name = placer and placer:get_player_name() or ""
|
||||||
if not (creative and creative.is_enabled_for
|
if not (creative and creative.is_enabled_for
|
||||||
and creative.is_enabled_for(placer:get_player_name())) then
|
and creative.is_enabled_for(player_name)) then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
|
@ -1832,6 +1832,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
if not player then return end
|
||||||
local pn = player:get_player_name()
|
local pn = player:get_player_name()
|
||||||
if open_chests[pn] then
|
if open_chests[pn] then
|
||||||
chest_lid_close(pn)
|
chest_lid_close(pn)
|
||||||
@ -1857,40 +1858,40 @@ function default.register_chest(name, d)
|
|||||||
end
|
end
|
||||||
def.after_place_node = function(pos, placer)
|
def.after_place_node = function(pos, placer)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("owner", placer:get_player_name() or "")
|
meta:set_string("owner", placer and placer:get_player_name() or "")
|
||||||
meta:set_string("infotext", "Locked Chest (owned by " ..
|
meta:set_string("infotext", "Locked Chest (owned by " ..
|
||||||
meta:get_string("owner") .. ")")
|
meta:get_string("owner") .. ")")
|
||||||
end
|
end
|
||||||
def.can_dig = function(pos,player)
|
def.can_dig = function(pos,player)
|
||||||
local meta = minetest.get_meta(pos);
|
local meta = minetest.get_meta(pos);
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
return inv:is_empty("main") and
|
if inv then return inv:is_empty("main") and default.can_interact_with_node(player, pos) end
|
||||||
default.can_interact_with_node(player, pos)
|
return
|
||||||
end
|
end
|
||||||
def.allow_metadata_inventory_move = function(pos, from_list, from_index,
|
def.allow_metadata_inventory_move = function(pos, from_list, from_index,
|
||||||
to_list, to_index, count, player)
|
to_list, to_index, count, player)
|
||||||
if not default.can_interact_with_node(player, pos) then
|
if player then
|
||||||
return 0
|
if not default.can_interact_with_node(player, pos) then return 0 end
|
||||||
end
|
end
|
||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
def.allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
def.allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
if not default.can_interact_with_node(player, pos) then
|
if player then
|
||||||
return 0
|
if not default.can_interact_with_node(player, pos) then return 0 end
|
||||||
end
|
end
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
def.allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
def.allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
if not default.can_interact_with_node(player, pos) then
|
if player then
|
||||||
return 0
|
if not default.can_interact_with_node(player, pos) then return 0 end
|
||||||
end
|
end
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
def.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
def.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
if not default.can_interact_with_node(clicker, pos) then
|
if clicker then
|
||||||
return itemstack
|
if not default.can_interact_with_node(clicker, pos) then return itemstack end
|
||||||
end
|
end
|
||||||
|
if not clicker return end
|
||||||
minetest.sound_play(def.sound_open, {gain = 0.3,
|
minetest.sound_play(def.sound_open, {gain = 0.3,
|
||||||
pos = pos, max_hear_distance = 10})
|
pos = pos, max_hear_distance = 10})
|
||||||
if not chest_lid_obstructed(pos) then
|
if not chest_lid_obstructed(pos) then
|
||||||
@ -1907,6 +1908,7 @@ function default.register_chest(name, d)
|
|||||||
def.on_blast = function() end
|
def.on_blast = function() end
|
||||||
def.on_key_use = function(pos, player)
|
def.on_key_use = function(pos, player)
|
||||||
local secret = minetest.get_meta(pos):get_string("key_lock_secret")
|
local secret = minetest.get_meta(pos):get_string("key_lock_secret")
|
||||||
|
if not player then return end
|
||||||
local itemstack = player:get_wielded_item()
|
local itemstack = player:get_wielded_item()
|
||||||
local key_meta = itemstack:get_meta()
|
local key_meta = itemstack:get_meta()
|
||||||
|
|
||||||
@ -1927,6 +1929,7 @@ function default.register_chest(name, d)
|
|||||||
end
|
end
|
||||||
def.on_skeleton_key_use = function(pos, player, newsecret)
|
def.on_skeleton_key_use = function(pos, player, newsecret)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
if not player then return end
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
local pn = player:get_player_name()
|
local pn = player:get_player_name()
|
||||||
|
|
||||||
@ -1958,6 +1961,7 @@ function default.register_chest(name, d)
|
|||||||
return inv:is_empty("main")
|
return inv:is_empty("main")
|
||||||
end
|
end
|
||||||
def.on_rightclick = function(pos, node, clicker)
|
def.on_rightclick = function(pos, node, clicker)
|
||||||
|
if not clicker then return end
|
||||||
minetest.sound_play(def.sound_open, {gain = 0.3, pos = pos,
|
minetest.sound_play(def.sound_open, {gain = 0.3, pos = pos,
|
||||||
max_hear_distance = 10})
|
max_hear_distance = 10})
|
||||||
if not chest_lid_obstructed(pos) then
|
if not chest_lid_obstructed(pos) then
|
||||||
@ -1982,15 +1986,18 @@ function default.register_chest(name, d)
|
|||||||
|
|
||||||
def.on_metadata_inventory_move = function(pos, from_list, from_index,
|
def.on_metadata_inventory_move = function(pos, from_list, from_index,
|
||||||
to_list, to_index, count, player)
|
to_list, to_index, count, player)
|
||||||
|
if not player then return end
|
||||||
minetest.log("action", player:get_player_name() ..
|
minetest.log("action", player:get_player_name() ..
|
||||||
" moves stuff in chest at " .. minetest.pos_to_string(pos))
|
" moves stuff in chest at " .. minetest.pos_to_string(pos))
|
||||||
end
|
end
|
||||||
def.on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
def.on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
if not player then return end
|
||||||
minetest.log("action", player:get_player_name() ..
|
minetest.log("action", player:get_player_name() ..
|
||||||
" moves " .. stack:get_name() ..
|
" moves " .. stack:get_name() ..
|
||||||
" to chest at " .. minetest.pos_to_string(pos))
|
" to chest at " .. minetest.pos_to_string(pos))
|
||||||
end
|
end
|
||||||
def.on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
def.on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
if not player then return end
|
||||||
minetest.log("action", player:get_player_name() ..
|
minetest.log("action", player:get_player_name() ..
|
||||||
" takes " .. stack:get_name() ..
|
" takes " .. stack:get_name() ..
|
||||||
" from chest at " .. minetest.pos_to_string(pos))
|
" from chest at " .. minetest.pos_to_string(pos))
|
||||||
@ -2137,18 +2144,21 @@ minetest.register_node("default:bookshelf", {
|
|||||||
return 0
|
return 0
|
||||||
end,
|
end,
|
||||||
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
if not player then return end
|
||||||
minetest.log("action", player:get_player_name() ..
|
minetest.log("action", player:get_player_name() ..
|
||||||
" moves stuff in bookshelf at " .. minetest.pos_to_string(pos))
|
" moves stuff in bookshelf at " .. minetest.pos_to_string(pos))
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec", get_bookshelf_formspec(meta:get_inventory()))
|
meta:set_string("formspec", get_bookshelf_formspec(meta:get_inventory()))
|
||||||
end,
|
end,
|
||||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
if not player then return end
|
||||||
minetest.log("action", player:get_player_name() ..
|
minetest.log("action", player:get_player_name() ..
|
||||||
" moves stuff to bookshelf at " .. minetest.pos_to_string(pos))
|
" moves stuff to bookshelf at " .. minetest.pos_to_string(pos))
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec", get_bookshelf_formspec(meta:get_inventory()))
|
meta:set_string("formspec", get_bookshelf_formspec(meta:get_inventory()))
|
||||||
end,
|
end,
|
||||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
if not player then return end
|
||||||
minetest.log("action", player:get_player_name() ..
|
minetest.log("action", player:get_player_name() ..
|
||||||
" takes stuff from bookshelf at " .. minetest.pos_to_string(pos))
|
" takes stuff from bookshelf at " .. minetest.pos_to_string(pos))
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
@ -2192,7 +2202,7 @@ local function register_sign(material, desc, def)
|
|||||||
end,
|
end,
|
||||||
on_receive_fields = function(pos, formname, fields, sender)
|
on_receive_fields = function(pos, formname, fields, sender)
|
||||||
--print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
|
--print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
|
||||||
local player_name = sender:get_player_name()
|
local player_name = sender and sender:get_player_name() or ""
|
||||||
if minetest.is_protected(pos, player_name) then
|
if minetest.is_protected(pos, player_name) then
|
||||||
minetest.record_protection_violation(pos, player_name)
|
minetest.record_protection_violation(pos, player_name)
|
||||||
return
|
return
|
||||||
|
@ -626,7 +626,7 @@ function tnt.register_tnt(def)
|
|||||||
groups = {dig_immediate = 2, mesecon = 2, tnt = 1, flammable = 5},
|
groups = {dig_immediate = 2, mesecon = 2, tnt = 1, flammable = 5},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
if placer:is_player() then
|
if placer and placer:is_player() then
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("owner", placer:get_player_name())
|
meta:set_string("owner", placer:get_player_name())
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user