aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
Diffstat (limited to 'builtin')
-rw-r--r--builtin/builtin.lua1
-rw-r--r--builtin/item.lua25
-rw-r--r--builtin/item_entity.lua5
3 files changed, 21 insertions, 10 deletions
diff --git a/builtin/builtin.lua b/builtin/builtin.lua
index f2811fa9c..bf33cbe6b 100644
--- a/builtin/builtin.lua
+++ b/builtin/builtin.lua
@@ -8,6 +8,7 @@
-- Initialize some very basic things
print = minetest.debug
math.randomseed(os.time())
+os.setlocale("C", "numeric")
-- Load other files
dofile(minetest.get_modpath("__builtin").."/serialize.lua")
diff --git a/builtin/item.lua b/builtin/item.lua
index d36e8a758..1349fdf63 100644
--- a/builtin/item.lua
+++ b/builtin/item.lua
@@ -141,7 +141,7 @@ function minetest.item_place_node(itemstack, placer, pointed_thing)
minetest.log("info", placer:get_player_name() .. " tried to place"
.. " node in invalid position " .. minetest.pos_to_string(above)
.. ", replacing " .. oldnode_above.name)
- return
+ return itemstack
end
-- Place above pointed node
@@ -186,7 +186,7 @@ function minetest.item_place_node(itemstack, placer, pointed_thing)
not check_attached_node(place_to, newnode) then
minetest.log("action", "attached node " .. def.name ..
" can not be placed at " .. minetest.pos_to_string(place_to))
- return
+ return itemstack
end
-- Add node and update
@@ -232,20 +232,19 @@ end
function minetest.item_place(itemstack, placer, pointed_thing)
-- Call on_rightclick if the pointed node defines it
- if pointed_thing.type == "node" then
+ if pointed_thing.type == "node" and placer and
+ not placer:get_player_control().sneak then
local n = minetest.env:get_node(pointed_thing.under)
local nn = n.name
if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then
- minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, n, placer)
- return
+ return minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, n, placer, itemstack)
end
end
if itemstack:get_definition().type == "node" then
return minetest.item_place_node(itemstack, placer, pointed_thing)
- elseif itemstack:get_definition().type ~= "none" then
- return minetest.item_place_object(itemstack, placer, pointed_thing)
end
+ return itemstack
end
function minetest.item_drop(itemstack, dropper, pos)
@@ -262,7 +261,7 @@ function minetest.item_drop(itemstack, dropper, pos)
else
minetest.env:add_item(pos, itemstack)
end
- return ""
+ return ItemStack("")
end
function minetest.item_eat(hp_change, replace_with_item)
@@ -291,7 +290,15 @@ function minetest.handle_node_drops(pos, drops, digger)
if digger:get_inventory() then
local _, dropped_item
for _, dropped_item in ipairs(drops) do
- digger:get_inventory():add_item("main", dropped_item)
+ local left = digger:get_inventory():add_item("main", dropped_item)
+ if not left:is_empty() then
+ local p = {
+ x = pos.x + math.random()/2-0.25,
+ y = pos.y + math.random()/2-0.25,
+ z = pos.z + math.random()/2-0.25,
+ }
+ minetest.env:add_item(p, left)
+ end
end
end
end
diff --git a/builtin/item_entity.lua b/builtin/item_entity.lua
index 46415e538..1699cb03c 100644
--- a/builtin/item_entity.lua
+++ b/builtin/item_entity.lua
@@ -109,7 +109,10 @@ minetest.register_entity("__builtin:item", {
on_punch = function(self, hitter)
if self.itemstring ~= '' then
- hitter:get_inventory():add_item("main", self.itemstring)
+ local left = hitter:get_inventory():add_item("main", self.itemstring)
+ if not left:is_empty() then
+ return
+ end
end
self.object:remove()
end,