summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPilzAdam <adam-k@outlook.com>2012-09-25 16:44:42 +0200
committerPilzAdam <adam-k@outlook.com>2012-09-25 16:44:42 +0200
commit3968be927020ff447f0e4819df589f3d2648298f (patch)
tree3a6f35769a4494a2530d099980a97dc883eb69aa
parenta0c49e7677853ec596ae084212b820b315c70b05 (diff)
Improvement of flowing code
-rw-r--r--init.lua36
1 files changed, 10 insertions, 26 deletions
diff --git a/init.lua b/init.lua
index 6f69cad..506c8df 100644
--- a/init.lua
+++ b/init.lua
@@ -125,32 +125,16 @@ minetest.register_entity(":__builtin:item", {
end
local vec = get_flowing_dir(self)
- if vec and vec.x-p.x > 0 then
- self.object:setvelocity({x=1,y=0,z=0})
- self.object:setacceleration({x=0, y=-10, z=0})
- self.physical_state = true
- self.object:set_properties({
- physical = true
- })
- return
- elseif vec and vec.x-p.x < 0 then
- self.object:setvelocity({x=-1,y=0,z=0})
- self.object:setacceleration({x=0, y=-10, z=0})
- self.physical_state = true
- self.object:set_properties({
- physical = true
- })
- return
- elseif vec and vec.z-p.z > 0 then
- self.object:setvelocity({x=0,y=0,z=1})
- self.object:setacceleration({x=0, y=-10, z=0})
- self.physical_state = true
- self.object:set_properties({
- physical = true
- })
- return
- elseif vec and vec.z-p.z < 0 then
- self.object:setvelocity({x=0,y=0,z=-1})
+ if vec then
+ if vec and vec.x-p.x > 0 then
+ self.object:setvelocity({x=1,y=0,z=0})
+ elseif vec and vec.x-p.x < 0 then
+ self.object:setvelocity({x=-1,y=0,z=0})
+ elseif vec and vec.z-p.z > 0 then
+ self.object:setvelocity({x=0,y=0,z=1})
+ elseif vec and vec.z-p.z < 0 then
+ self.object:setvelocity({x=0,y=0,z=-1})
+ end
self.object:setacceleration({x=0, y=-10, z=0})
self.physical_state = true
self.object:set_properties({