Expose selection size description to lua

This commit is contained in:
Pasi Kallinen
2026-01-25 15:18:45 +02:00
parent 4bf1fb5c68
commit f73d9ee704
3 changed files with 42 additions and 0 deletions

View File

@@ -540,6 +540,23 @@ function test_sel_gradient()
local selc = selection.gradient({ x = 3, y = 5, x2 = 10, y2 = 12, maxdist = 10});
end
function test_sel_describe_size()
local sela = selection.fillrect(1,1, 3,3);
if (sela:describe_size() ~= "square 3 by 3") then
error("selection.describe_size returned \"" .. sela:describe_size() "\", not \"square 3 by 3\"");
end
local selb = selection.fillrect(1,1, 4,3);
if (selb:describe_size() ~= "rectangular 4 by 3") then
error("selection.describe_size returned \"" .. selb:describe_size() "\", not \"rectangular 4 by 3\"");
end
sela:set(1,1, 0);
if (sela:describe_size() ~= "irregularly shaped 3 by 3") then
error("selection.describe_size returned \"" .. sela:describe_size() "\", not \"irregularly shaped 3 by 3\"");
end
end
nh.debug_flags({mongen = false, hunger = false, overwrite_stairs = true });
test_selection_params();
test_sel_negate();
@@ -563,3 +580,4 @@ test_sel_map();
test_sel_numpoints();
test_sel_room();
test_sel_gradient();
test_sel_describe_size();