Tweaked and tidied code
This commit is contained in:
parent
6af2a7b889
commit
c878439d71
24
init.lua
24
init.lua
@ -1,4 +1,7 @@
|
|||||||
-- Minetest: builtin/item_entity.lua (22nd August 2016)
|
|
||||||
|
-- Minetest: builtin/item_entity.lua (11th September 2016)
|
||||||
|
|
||||||
|
local abs = math.abs
|
||||||
|
|
||||||
-- water flow functions by QwertyMine3, edited by TenPlus1
|
-- water flow functions by QwertyMine3, edited by TenPlus1
|
||||||
local function to_unit_vector(dir_vector)
|
local function to_unit_vector(dir_vector)
|
||||||
@ -23,7 +26,7 @@ end
|
|||||||
|
|
||||||
local function is_touching(realpos, nodepos, radius)
|
local function is_touching(realpos, nodepos, radius)
|
||||||
|
|
||||||
return (math.abs(realpos - nodepos) > (0.5 - radius))
|
return (abs(realpos - nodepos) > (0.5 - radius))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function node_ok(pos)
|
local function node_ok(pos)
|
||||||
@ -41,23 +44,12 @@ local function node_ok(pos)
|
|||||||
return minetest.registered_nodes["default:dirt"]
|
return minetest.registered_nodes["default:dirt"]
|
||||||
end
|
end
|
||||||
|
|
||||||
local function is_water(pos)
|
|
||||||
|
|
||||||
return (minetest.registered_nodes[
|
|
||||||
node_ok({x = pos.x, y = pos.y, z = pos.z}).name].groups.water)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function is_liquid(pos)
|
local function is_liquid(pos)
|
||||||
|
|
||||||
return (minetest.registered_nodes[
|
return (minetest.registered_nodes[
|
||||||
node_ok({x = pos.x, y = pos.y, z = pos.z}).name].groups.liquid)
|
node_ok({x = pos.x, y = pos.y, z = pos.z}).name].groups.liquid)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function node_is_liquid(node)
|
|
||||||
|
|
||||||
return (minetest.registered_nodes[node.name].groups.liquid)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function quick_flow_logic(node, pos_testing, direction)
|
local function quick_flow_logic(node, pos_testing, direction)
|
||||||
|
|
||||||
if minetest.registered_nodes[node.name].liquidtype == "source" then
|
if minetest.registered_nodes[node.name].liquidtype == "source" then
|
||||||
@ -107,7 +99,7 @@ local function quick_flow(pos, node)
|
|||||||
|
|
||||||
local x, z = 0, 0
|
local x, z = 0, 0
|
||||||
|
|
||||||
if not node_is_liquid(node) then
|
if not minetest.registered_nodes[node.name].groups.liquid then
|
||||||
return {x = 0, y = 0, z = 0}
|
return {x = 0, y = 0, z = 0}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -209,6 +201,7 @@ local function within_limits(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
core.register_entity(":__builtin:item", {
|
core.register_entity(":__builtin:item", {
|
||||||
|
|
||||||
initial_properties = {
|
initial_properties = {
|
||||||
hp_max = 1,
|
hp_max = 1,
|
||||||
physical = true,
|
physical = true,
|
||||||
@ -253,6 +246,7 @@ core.register_entity(":__builtin:item", {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
update_gravity = function(self)
|
update_gravity = function(self)
|
||||||
|
|
||||||
if not self.physical_state then
|
if not self.physical_state then
|
||||||
self.object:setacceleration({x = 0, y = 0, z = 0})
|
self.object:setacceleration({x = 0, y = 0, z = 0})
|
||||||
return
|
return
|
||||||
@ -413,7 +407,7 @@ core.register_entity(":__builtin:item", {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local objects = core.get_objects_inside_radius(pos, 1.0)--0.8)
|
local objects = core.get_objects_inside_radius(pos, 1.0)
|
||||||
|
|
||||||
for k, object in pairs(objects) do
|
for k, object in pairs(objects) do
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user