Make lua selection line create a new selection

... instead of modifying the one given as a parameter.

Also add some tests for it.
This commit is contained in:
Pasi Kallinen
2020-02-22 14:23:33 +02:00
parent 00a32c6039
commit 44f7d44e94
3 changed files with 34 additions and 12 deletions

View File

@@ -29,26 +29,23 @@ if math.random(0,99) < 75 then
local tidx = math.random(1, #terrains);
local choice = math.random(0, 4);
if choice == 0 then
-- one horizontal line
des.terrain(selection.line(10,8, 65,8), terrains[tidx]);
elseif choice == 1 then
local sel = selection.new();
sel:line(15,4, 15, 13);
sel:line(59,4, 59, 13);
-- two vertical lines
local sel = selection.line(15,4, 15, 13) | selection.line(59,4, 59, 13);
des.terrain(sel, terrains[tidx]);
elseif choice == 2 then
local sel = selection.new();
sel:line(10,8, 38, 8);
sel:line(37,8, 65, 8);
sel:line(37,3, 37, 8);
sel:line(37,8, 37,14);
-- plus sign
local sel = selection.line(10,8, 64, 8) | selection.line(37,3, 37, 14);
des.terrain(sel, terrains[tidx]);
elseif choice == 3 then
-- brackets: [ ]
des.terrain(selection.rect(4,4, 70,13), terrains[tidx]);
local sel = selection.new();
sel:line(25,4, 50,4);
sel:line(25,13, 50,13);
local sel = selection.line(25,4, 50,4) | selection.line(25,13, 50,13);
des.terrain(sel, '.');
else
-- nothing
end
end