diff --git a/basis/fly_lib.lua b/basis/fly_lib.lua index c05d36a..451be3b 100644 --- a/basis/fly_lib.lua +++ b/basis/fly_lib.lua @@ -75,14 +75,15 @@ function flylib.distance(v) return math.abs(v.x) + math.abs(v.y) + math.abs(v.z) end -function flylib.to_vector(s) +function flylib.to_vector(s, max_dist) local x,y,z = unpack(string.split(s, ",")) + x = tonumber(x) or 0 + y = tonumber(y) or 0 + z = tonumber(z) or 0 if x and y and z then - return { - x=tonumber(x) or 0, - y=tonumber(y) or 0, - z=tonumber(z) or 0, - } + if not max_dist or (math.abs(x) + math.abs(y) + math.abs(z)) <= max_dist then + return {x = x, y = y, z = z} + end end end diff --git a/move_controller/movecontroller.lua b/move_controller/movecontroller.lua index 9607ea3..db81636 100644 --- a/move_controller/movecontroller.lua +++ b/move_controller/movecontroller.lua @@ -22,7 +22,7 @@ local MP = minetest.get_modpath("techage") local fly = dofile(MP .. "/basis/fly_lib.lua") local mark = dofile(MP .. "/basis/mark_lib.lua") -local MAX_DIST = 100 +local MAX_DIST = 200 local MAX_BLOCKS = 16 local WRENCH_MENU = { @@ -183,7 +183,7 @@ minetest.register_node("techage:ta4_movecontroller", { if fly.to_vector(fields.path or "", MAX_DIST) then meta:set_string("path", fields.path) end - local line = fly.to_vector(meta:get_string("path")) + local line = fly.to_vector(meta:get_string("path"), MAX_DIST) if line then nvm.running = true fly.move_to(pos, line) @@ -240,7 +240,7 @@ techage.register_node({"techage:ta4_movecontroller"}, { nvm.running = true return fly.move_to_other_pos(pos, nvm.moveBA == false) elseif move_xyz and topic == "move2" then - local line = fly.to_vector(payload) + local line = fly.to_vector(payload, MAX_DIST) if line then nvm.running = true nvm.controller_mode = true