diff --git a/init.lua b/init.lua index e531425..51bd6ee 100644 --- a/init.lua +++ b/init.lua @@ -58,7 +58,7 @@ local chunk = { cartographer.skin = loadfile(modpath .. "/skin_api.lua") (); cartographer.gui = loadfile(modpath .. "/formspec.lua") (); loadfile(modpath .. "/scanner.lua") (map_data, chunk); -loadfile(modpath .. "/map_api.lua") (); +loadfile(modpath .. "/map_api.lua") (chunk); loadfile(modpath .. "/items.lua") (); _cartographer.generate_marker_formspec = loadfile(modpath .. "/marker_formspec.lua") (_cartographer.marker_lookup, cartographer.gui); loadfile(modpath .. "/map_formspec.lua") (map_data); diff --git a/map_api.lua b/map_api.lua index c23ccec..f07cb0e 100644 --- a/map_api.lua +++ b/map_api.lua @@ -1,3 +1,5 @@ +local chunk = ...; + function cartographer.create_map(x, z, w, h, filled, detail, scale) local id = _cartographer.next_map_id; @@ -92,10 +94,10 @@ end -- Returns The converted x and z coordinates function cartographer.to_map_coordinates(map, x, z) if not map or map.scale == 0 then - return tochunk(x), tochunk(z); + return chunk.to(x), chunk.to(z); end - return math.floor(tochunk(x) / map.scale + 0.5), math.floor(tochunk(z) / map.scale + 0.5); + return math.floor(chunk.to(x) / map.scale + 0.5), math.floor(chunk.to(z) / map.scale + 0.5); end -- Periodically-called function to fill in maps and queue chunks for manual @@ -116,9 +118,9 @@ local function fill_loop() for i = -2,2 do for j = -2,2 do local adjusted_pos = { - x = pos.x + fromchunk(i), + x = pos.x + chunk.from(i), y = pos.y, - z = pos.z + fromchunk(j), + z = pos.z + chunk.from(j), } cartographer.queue_region(adjusted_pos); end @@ -208,7 +210,6 @@ function cartographer.is_filled(map, x, z) return false; end - -- minetest.chat_send_all(tostring(x).. ", " .. tostring(z) .. "(" .. tostring(x + (z * map.w)) .."): " .. tostring(map.fill[x + (z * map.w)])); return map.fill[(x - map.x) + ((z - map.z) * map.w)] ~= nil; end @@ -228,7 +229,9 @@ end -- Returns a string with a texture name, or nil if no matching biome entry was found. function cartographer.get_biome_texture(name, height, detail) for _,biome in ipairs(_cartographer.biome_lookup) do - if biome.name == name and (not biome.min_height or height >= biome.min_height) and (not biome.max_height or height <= biome.max_height) then + local matches_height = (not biome.min_height or height >= biome.min_height) + and (not biome.max_height or height <= biome.max_height); + if biome.name == name and matches_height then return cartographer.detail_texture(biome.textures, detail); end end