Commit f9713069 authored by Fedja Beader's avatar Fedja Beader
Browse files

only translate coordinates if jump was successful.

parent 129328c3
......@@ -45,6 +45,26 @@ function translate_position_list(jump, list)
end
end
local last_jump = nil
--"Jump executed in 1227 ms"
local match_pattern = "Jump executed in.*ms"
core.register_on_receiving_chat_message(function(message)
local captures = string.match(message, match_pattern)
if captures and last_jump then
l:info("Message captured: \"" .. message .. "\", executing jump watchlist handlers.")
for i=1,#jd_watchlist do
jd_watchlist[i](last_jump)
end
last_jump = nil
return true
end
return false
end)
core.register_on_sending_fields(function(pos, formname, fields)
if formname == "" and fields.jump then
local x = tonumber(fields.x)
......@@ -66,9 +86,8 @@ core.register_on_sending_fields(function(pos, formname, fields)
jump.radius = radius
jump.offset = offset
for i=1,#jd_watchlist do
jd_watchlist[i](jump)
end
l:debug("Waiting for \"Jump executed in.*ms\" message indicating jump success...")
last_jump = jump -- let's see if it was successful or not
end
end
end)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment