mirror of
https://github.com/HybridDog/builtin_item.git
synced 2024-12-22 17:00:27 +01:00
Improvement of flowing code
This commit is contained in:
parent
a0c49e7677
commit
3968be9270
36
init.lua
36
init.lua
@ -125,32 +125,16 @@ minetest.register_entity(":__builtin:item", {
|
|||||||
end
|
end
|
||||||
|
|
||||||
local vec = get_flowing_dir(self)
|
local vec = get_flowing_dir(self)
|
||||||
if vec and vec.x-p.x > 0 then
|
if vec then
|
||||||
self.object:setvelocity({x=1,y=0,z=0})
|
if vec and vec.x-p.x > 0 then
|
||||||
self.object:setacceleration({x=0, y=-10, z=0})
|
self.object:setvelocity({x=1,y=0,z=0})
|
||||||
self.physical_state = true
|
elseif vec and vec.x-p.x < 0 then
|
||||||
self.object:set_properties({
|
self.object:setvelocity({x=-1,y=0,z=0})
|
||||||
physical = true
|
elseif vec and vec.z-p.z > 0 then
|
||||||
})
|
self.object:setvelocity({x=0,y=0,z=1})
|
||||||
return
|
elseif vec and vec.z-p.z < 0 then
|
||||||
elseif vec and vec.x-p.x < 0 then
|
self.object:setvelocity({x=0,y=0,z=-1})
|
||||||
self.object:setvelocity({x=-1,y=0,z=0})
|
end
|
||||||
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})
|
|
||||||
self.object:setacceleration({x=0, y=-10, z=0})
|
self.object:setacceleration({x=0, y=-10, z=0})
|
||||||
self.physical_state = true
|
self.physical_state = true
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
|
Loading…
Reference in New Issue
Block a user