Fix 2 flycontroller bugs
This commit is contained in:
parent
14f7c8718c
commit
baea3f137f
@ -542,6 +542,7 @@ minetest.register_entity("techage:move_item", {
|
|||||||
obj:move_to(self.dest_pos, true)
|
obj:move_to(self.dest_pos, true)
|
||||||
obj:set_acceleration({x=0, y=0, z=0})
|
obj:set_acceleration({x=0, y=0, z=0})
|
||||||
obj:set_velocity({x=0, y=0, z=0})
|
obj:set_velocity({x=0, y=0, z=0})
|
||||||
|
self.item.dest_pos = dest_pos
|
||||||
self.dest_pos = nil
|
self.dest_pos = nil
|
||||||
self.old_dist = nil
|
self.old_dist = nil
|
||||||
return dest_pos
|
return dest_pos
|
||||||
@ -554,9 +555,9 @@ minetest.register_entity("techage:move_item", {
|
|||||||
local speed = calc_speed(obj:get_velocity())
|
local speed = calc_speed(obj:get_velocity())
|
||||||
self.old_dist = self.old_dist or dist
|
self.old_dist = self.old_dist or dist
|
||||||
|
|
||||||
-- Landing
|
|
||||||
if self.lpath and self.lpath[self.path_idx] then
|
if self.lpath and self.lpath[self.path_idx] then
|
||||||
if dist < 1 or dist > self.old_dist then
|
if dist < 1 or dist > self.old_dist then
|
||||||
|
-- change of direction
|
||||||
local dest_pos = stop_obj(obj, self)
|
local dest_pos = stop_obj(obj, self)
|
||||||
if not moveon_entity(obj, self, dest_pos) then
|
if not moveon_entity(obj, self, dest_pos) then
|
||||||
minetest.after(0.5, entity_to_node, dest_pos, obj)
|
minetest.after(0.5, entity_to_node, dest_pos, obj)
|
||||||
@ -571,6 +572,7 @@ minetest.register_entity("techage:move_item", {
|
|||||||
return
|
return
|
||||||
else
|
else
|
||||||
if dist < 0.05 or dist > self.old_dist then
|
if dist < 0.05 or dist > self.old_dist then
|
||||||
|
-- Landing
|
||||||
local dest_pos = stop_obj(obj, self)
|
local dest_pos = stop_obj(obj, self)
|
||||||
minetest.after(0.5, entity_to_node, dest_pos, obj)
|
minetest.after(0.5, entity_to_node, dest_pos, obj)
|
||||||
return
|
return
|
||||||
|
@ -165,8 +165,6 @@ minetest.register_node("techage:ta5_flycontroller", {
|
|||||||
elseif fields.moveAB then
|
elseif fields.moveAB then
|
||||||
meta:set_string("status", "")
|
meta:set_string("status", "")
|
||||||
if fly.move_to_other_pos(pos, false) then
|
if fly.move_to_other_pos(pos, false) then
|
||||||
nvm.moveBA = true
|
|
||||||
nvm.running = true
|
|
||||||
meta:set_string("formspec", formspec(nvm, meta))
|
meta:set_string("formspec", formspec(nvm, meta))
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
mark.stop(name)
|
mark.stop(name)
|
||||||
@ -175,8 +173,6 @@ minetest.register_node("techage:ta5_flycontroller", {
|
|||||||
elseif fields.moveBA then
|
elseif fields.moveBA then
|
||||||
meta:set_string("status", "")
|
meta:set_string("status", "")
|
||||||
if fly.move_to_other_pos(pos, true) then
|
if fly.move_to_other_pos(pos, true) then
|
||||||
nvm.moveBA = false
|
|
||||||
nvm.running = true
|
|
||||||
meta:set_string("formspec", formspec(nvm, meta))
|
meta:set_string("formspec", formspec(nvm, meta))
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
mark.stop(name)
|
mark.stop(name)
|
||||||
@ -185,8 +181,6 @@ minetest.register_node("techage:ta5_flycontroller", {
|
|||||||
elseif fields.move then
|
elseif fields.move then
|
||||||
meta:set_string("status", "")
|
meta:set_string("status", "")
|
||||||
if fly.move_to_other_pos(pos, nvm.moveBA) then
|
if fly.move_to_other_pos(pos, nvm.moveBA) then
|
||||||
nvm.moveBA = nvm.moveBA == false
|
|
||||||
nvm.running = true
|
|
||||||
meta:set_string("formspec", formspec(nvm, meta))
|
meta:set_string("formspec", formspec(nvm, meta))
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
mark.stop(name)
|
mark.stop(name)
|
||||||
@ -219,17 +213,11 @@ techage.register_node({"techage:ta5_flycontroller"}, {
|
|||||||
elseif topic == "state" then
|
elseif topic == "state" then
|
||||||
return nvm.running and "running" or "stopped"
|
return nvm.running and "running" or "stopped"
|
||||||
elseif topic == "a2b" then
|
elseif topic == "a2b" then
|
||||||
nvm.moveBA = true
|
|
||||||
nvm.running = true
|
|
||||||
return fly.move_to_other_pos(pos, false)
|
return fly.move_to_other_pos(pos, false)
|
||||||
elseif topic == "b2a" then
|
elseif topic == "b2a" then
|
||||||
nvm.moveBA = false
|
|
||||||
nvm.running = true
|
|
||||||
return fly.move_to_other_pos(pos, true)
|
return fly.move_to_other_pos(pos, true)
|
||||||
elseif topic == "move" then
|
elseif topic == "move" then
|
||||||
nvm.moveBA = nvm.moveBA == false
|
return fly.move_to_other_pos(pos, nvm.moveBA)
|
||||||
nvm.running = true
|
|
||||||
return fly.move_to_other_pos(pos, nvm.moveBA == false)
|
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end,
|
end,
|
||||||
@ -237,17 +225,11 @@ techage.register_node({"techage:ta5_flycontroller"}, {
|
|||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
if topic == 11 then
|
if topic == 11 then
|
||||||
if payload[1] == 1 then
|
if payload[1] == 1 then
|
||||||
nvm.moveBA = true
|
|
||||||
nvm.running = true
|
|
||||||
return fly.move_to_other_pos(pos, false) and 0 or 3
|
return fly.move_to_other_pos(pos, false) and 0 or 3
|
||||||
elseif payload[1] == 2 then
|
elseif payload[1] == 2 then
|
||||||
nvm.moveBA = false
|
|
||||||
nvm.running = true
|
|
||||||
return fly.move_to_other_pos(pos, true) and 0 or 3
|
return fly.move_to_other_pos(pos, true) and 0 or 3
|
||||||
elseif payload[1] == 3 then
|
elseif payload[1] == 3 then
|
||||||
nvm.moveBA = nvm.moveBA == false
|
return fly.move_to_other_pos(pos, nvm.moveBA) and 0 or 3
|
||||||
nvm.running = true
|
|
||||||
return fly.move_to_other_pos(pos, nvm.moveBA == false) and 0 or 3
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return 2
|
return 2
|
||||||
|
Loading…
Reference in New Issue
Block a user