clone functions
This commit is contained in:
parent
2b36bf19f9
commit
2eb4f33864
2 changed files with 27 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue