update: digtron
This commit is contained in:
parent
0cb4884332
commit
9cb782dca2
@ -271,7 +271,9 @@ local loaded_on_dig = function(pos, player, loaded_node_name)
|
|||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
local stack = inv:add_item("main", stack)
|
local stack = inv:add_item("main", stack)
|
||||||
if stack:get_count() > 0 then
|
if stack:get_count() > 0 then
|
||||||
minetest.add_item(pos, stack)
|
-- prevent crash by not dropping loaded crate (see #44)
|
||||||
|
-- minetest.add_item(pos, stack)
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
-- call on_dignodes callback
|
-- call on_dignodes callback
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
@ -333,6 +335,7 @@ minetest.register_node("digtron:loaded_crate", {
|
|||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||||
loaded_after_place(pos, itemstack)
|
loaded_after_place(pos, itemstack)
|
||||||
end,
|
end,
|
||||||
|
on_drop = function(a, b, c) end -- prevent dropping loaded digtrons, causing server to crash (see #44)
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("digtron:loaded_locked_crate", {
|
minetest.register_node("digtron:loaded_locked_crate", {
|
||||||
@ -349,7 +352,9 @@ minetest.register_node("digtron:loaded_locked_crate", {
|
|||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("owner", "")
|
meta:set_string("owner", "")
|
||||||
end,
|
end,
|
||||||
|
-- can_dig = function(pos,node,player)
|
||||||
|
-- return player and not minetest.is_protected(pos, player:get_player_name()) and player_permitted(pos,player)
|
||||||
|
-- end,
|
||||||
on_dig = function(pos, node, player)
|
on_dig = function(pos, node, player)
|
||||||
if player and not minetest.is_protected(pos, player:get_player_name()) and player_permitted(pos,player) then
|
if player and not minetest.is_protected(pos, player:get_player_name()) and player_permitted(pos,player) then
|
||||||
return loaded_on_dig(pos, player, "digtron:loaded_locked_crate")
|
return loaded_on_dig(pos, player, "digtron:loaded_locked_crate")
|
||||||
@ -373,7 +378,8 @@ minetest.register_node("digtron:loaded_locked_crate", {
|
|||||||
"digtron:loaded_locked_crate"..minetest.pos_to_string(pos),
|
"digtron:loaded_locked_crate"..minetest.pos_to_string(pos),
|
||||||
loaded_formspec_string:gsub("${title}", meta:get_string("title"), 1))
|
loaded_formspec_string:gsub("${title}", meta:get_string("title"), 1))
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
on_drop = function(a, b, c) end -- prevent dropping loaded digtrons, causing server to crash
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
@ -325,6 +325,9 @@ local damage_def = {
|
|||||||
damage_groups = {},
|
damage_groups = {},
|
||||||
}
|
}
|
||||||
digtron.damage_creatures = function(player, source_pos, target_pos, amount, items_dropped)
|
digtron.damage_creatures = function(player, source_pos, target_pos, amount, items_dropped)
|
||||||
|
if type(player) ~= 'userdata' then
|
||||||
|
return
|
||||||
|
end
|
||||||
local objects = minetest.env:get_objects_inside_radius(target_pos, 1.0)
|
local objects = minetest.env:get_objects_inside_radius(target_pos, 1.0)
|
||||||
if objects ~= nil then
|
if objects ~= nil then
|
||||||
damage_def.damage_groups.fleshy = amount
|
damage_def.damage_groups.fleshy = amount
|
||||||
@ -433,4 +436,4 @@ digtron.show_offset_markers = function(pos, offset, period)
|
|||||||
local entity = safe_add_entity({x=buildpos.x, y=buildpos.y, z=z_pos + period}, "digtron:marker")
|
local entity = safe_add_entity({x=buildpos.x, y=buildpos.y, z=z_pos + period}, "digtron:marker")
|
||||||
if entity ~= nil then entity:setyaw(1.5708) end
|
if entity ~= nil then entity:setyaw(1.5708) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user