clone functions

This commit is contained in:
Alexey 2025-10-30 00:24:49 +03:00
commit 2eb4f33864
2 changed files with 27 additions and 0 deletions

View file

@ -55,6 +55,20 @@ function Mechanism:new( position, size, ports, color )
return mechanism
end
function Mechanism:clone()
local ports = {}
for _, port in ipairs(self.ports) do
local clonedPort = port:clone()
table.insert(ports, clonedPort)
end
local mechanism = {
position = GridPoint:new( self.position.x, self.position.y ),
size = GridPoint:new( self.size.x, self.size.y ),
ports = ports,
color = self.color
}
end
function Mechanism:rotateClockwise()
self.size = GridPoint:new(self.size.y, self.size.x)
self.xcorner = nextxcorner(self.xcorner, self.size)