aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorWeblate <42@minetest.ru>2013-03-30 19:49:52 +0100
committerWeblate <42@minetest.ru>2013-03-30 19:49:52 +0100
commita0566270d9fa075afa36a7e3e68c690b1b23ba90 (patch)
tree6bc88127ee67b7bf4d6a2d6f9d0a9e5f997d1dd1 /builtin
parent0d83bdc3aa9f1077836aacb833ac4ad9bbb9a4f4 (diff)
parent1aa50b13622c1e264044839ecdf0152670dae6ce (diff)
downloadminetest-a0566270d9fa075afa36a7e3e68c690b1b23ba90.tar.gz
minetest-a0566270d9fa075afa36a7e3e68c690b1b23ba90.tar.bz2
minetest-a0566270d9fa075afa36a7e3e68c690b1b23ba90.zip
Merge remote branch 'origin/master'
Diffstat (limited to 'builtin')
-rw-r--r--builtin/falling.lua8
-rw-r--r--builtin/item.lua13
-rw-r--r--builtin/item_entity.lua1
-rw-r--r--builtin/misc.lua13
4 files changed, 28 insertions, 7 deletions
diff --git a/builtin/falling.lua b/builtin/falling.lua
index d3af36f29..1c09f9856 100644
--- a/builtin/falling.lua
+++ b/builtin/falling.lua
@@ -57,6 +57,10 @@ minetest.register_entity("__builtin:falling_node", {
-- Note: walkable is in the node definition, not in item groups
if minetest.registered_nodes[bcn.name] and
minetest.registered_nodes[bcn.name].walkable then
+ if minetest.registered_nodes[bcn.name].buildable_to then
+ minetest.env:remove_node(bcp)
+ return
+ end
local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
-- Check what's here
local n2 = minetest.env:get_node(np)
@@ -80,6 +84,7 @@ minetest.register_entity("__builtin:falling_node", {
-- Create node and remove entity
minetest.env:add_node(np, {name=self.nodename})
self.object:remove()
+ nodeupdate(np)
else
-- Do nothing
end
@@ -144,7 +149,8 @@ function nodeupdate_single(p)
n_bottom = minetest.env:get_node(p_bottom)
-- Note: walkable is in the node definition, not in item groups
if minetest.registered_nodes[n_bottom.name] and
- not minetest.registered_nodes[n_bottom.name].walkable then
+ (not minetest.registered_nodes[n_bottom.name].walkable or
+ minetest.registered_nodes[n_bottom.name].buildable_to) then
minetest.env:remove_node(p)
spawn_falling_node(p, n.name)
nodeupdate(p)
diff --git a/builtin/item.lua b/builtin/item.lua
index 1349fdf63..8e2f75a1a 100644
--- a/builtin/item.lua
+++ b/builtin/item.lua
@@ -129,11 +129,18 @@ function minetest.item_place_node(itemstack, placer, pointed_thing)
end
local under = pointed_thing.under
- local oldnode_under = minetest.env:get_node(under)
+ local oldnode_under = minetest.env:get_node_or_nil(under)
+ local above = pointed_thing.above
+ local oldnode_above = minetest.env:get_node_or_nil(above)
+
+ if not oldnode_under or not oldnode_above then
+ minetest.log("info", placer:get_player_name() .. " tried to place"
+ .. " node in unloaded position " .. minetest.pos_to_string(above))
+ return itemstack
+ end
+
local olddef_under = ItemStack({name=oldnode_under.name}):get_definition()
olddef_under = olddef_under or minetest.nodedef_default
- local above = pointed_thing.above
- local oldnode_above = minetest.env:get_node(above)
local olddef_above = ItemStack({name=oldnode_above.name}):get_definition()
olddef_above = olddef_above or minetest.nodedef_default
diff --git a/builtin/item_entity.lua b/builtin/item_entity.lua
index 1699cb03c..50ce7eafe 100644
--- a/builtin/item_entity.lua
+++ b/builtin/item_entity.lua
@@ -111,6 +111,7 @@ minetest.register_entity("__builtin:item", {
if self.itemstring ~= '' then
local left = hitter:get_inventory():add_item("main", self.itemstring)
if not left:is_empty() then
+ self.itemstring = left:to_string()
return
end
end
diff --git a/builtin/misc.lua b/builtin/misc.lua
index e018aff85..8308b3d6b 100644
--- a/builtin/misc.lua
+++ b/builtin/misc.lua
@@ -14,14 +14,14 @@ minetest.register_globalstep(function(dtime)
for index, timer in ipairs(minetest.timers) do
timer.time = timer.time - dtime
if timer.time <= 0 then
- timer.func(timer.param)
+ timer.func(unpack(timer.args or {}))
table.remove(minetest.timers,index)
end
end
end)
-function minetest.after(time, func, param)
- table.insert(minetest.timers_to_add, {time=time, func=func, param=param})
+function minetest.after(time, func, ...)
+ table.insert(minetest.timers_to_add, {time=time, func=func, args={...}})
end
function minetest.check_player_privs(name, privs)
@@ -99,3 +99,10 @@ function minetest.setting_get_pos(name)
return minetest.string_to_pos(value)
end
+function minetest.formspec_escape(str)
+ str = string.gsub(str, "\\", "\\\\")
+ str = string.gsub(str, "%[", "\\[")
+ str = string.gsub(str, "%]", "\\]")
+ return str
+end
+