Fix 2 flycontroller bugs

This commit is contained in:
Joachim Stolberg 2023-02-02 19:22:37 +01:00
parent 14f7c8718c
commit baea3f137f
2 changed files with 5 additions and 21 deletions

View File

@ -542,6 +542,7 @@ minetest.register_entity("techage:move_item", {
obj:move_to(self.dest_pos, true)
obj:set_acceleration({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.old_dist = nil
return dest_pos
@ -554,9 +555,9 @@ minetest.register_entity("techage:move_item", {
local speed = calc_speed(obj:get_velocity())
self.old_dist = self.old_dist or dist
-- Landing
if self.lpath and self.lpath[self.path_idx] then
if dist < 1 or dist > self.old_dist then
-- change of direction
local dest_pos = stop_obj(obj, self)
if not moveon_entity(obj, self, dest_pos) then
minetest.after(0.5, entity_to_node, dest_pos, obj)
@ -571,6 +572,7 @@ minetest.register_entity("techage:move_item", {
return
else
if dist < 0.05 or dist > self.old_dist then
-- Landing
local dest_pos = stop_obj(obj, self)
minetest.after(0.5, entity_to_node, dest_pos, obj)
return

View File

@ -165,8 +165,6 @@ minetest.register_node("techage:ta5_flycontroller", {
elseif fields.moveAB then
meta:set_string("status", "")
if fly.move_to_other_pos(pos, false) then
nvm.moveBA = true
nvm.running = true
meta:set_string("formspec", formspec(nvm, meta))
local name = player:get_player_name()
mark.stop(name)
@ -175,8 +173,6 @@ minetest.register_node("techage:ta5_flycontroller", {
elseif fields.moveBA then
meta:set_string("status", "")
if fly.move_to_other_pos(pos, true) then
nvm.moveBA = false
nvm.running = true
meta:set_string("formspec", formspec(nvm, meta))
local name = player:get_player_name()
mark.stop(name)
@ -185,8 +181,6 @@ minetest.register_node("techage:ta5_flycontroller", {
elseif fields.move then
meta:set_string("status", "")
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))
local name = player:get_player_name()
mark.stop(name)
@ -219,17 +213,11 @@ techage.register_node({"techage:ta5_flycontroller"}, {
elseif topic == "state" then
return nvm.running and "running" or "stopped"
elseif topic == "a2b" then
nvm.moveBA = true
nvm.running = true
return fly.move_to_other_pos(pos, false)
elseif topic == "b2a" then
nvm.moveBA = false
nvm.running = true
return fly.move_to_other_pos(pos, true)
elseif topic == "move" then
nvm.moveBA = nvm.moveBA == false
nvm.running = true
return fly.move_to_other_pos(pos, nvm.moveBA == false)
return fly.move_to_other_pos(pos, nvm.moveBA)
end
return false
end,
@ -237,17 +225,11 @@ techage.register_node({"techage:ta5_flycontroller"}, {
local nvm = techage.get_nvm(pos)
if topic == 11 then
if payload[1] == 1 then
nvm.moveBA = true
nvm.running = true
return fly.move_to_other_pos(pos, false) and 0 or 3
elseif payload[1] == 2 then
nvm.moveBA = false
nvm.running = true
return fly.move_to_other_pos(pos, true) and 0 or 3
elseif payload[1] == 3 then
nvm.moveBA = nvm.moveBA == false
nvm.running = true
return fly.move_to_other_pos(pos, nvm.moveBA == false) and 0 or 3
return fly.move_to_other_pos(pos, nvm.moveBA) and 0 or 3
end
else
return 2