function position() local x = get_value("x") local y = get_value("y") local x_id = math.floor(x / 16128) local y_id = math.floor(y / 16128) if x_id > 9 and y_id > 9 then message("Map name: m0" .. x_id .. "_0" .. y_id) elseif x_id > 9 then message("Map name: m0" .. x_id .. "_00" .. y_id) elseif y_id > 9 then message("Map name: m00" .. x_id .. "_0" .. y_id) else message("Map name: m00" .. x_id .. "_00" .. y_id) end local loc_x = x - x_id * 16128 local loc_y = y - y_id * 16128 local segment = math.floor(loc_y / 252) * 64 + math.floor(loc_x / 252) message("Segment ID: " .. segment) local segment_x = loc_x - math.floor(loc_x / 252) * 252 local segment_y = loc_y - math.floor(loc_y / 252) * 252 message("Segment X: " .. segment_x) message("Segment Y: " .. segment_y) end