46 lines
1.9 KiB
Lua
46 lines
1.9 KiB
Lua
local port1 = Port:new( GridPoint:new(-1, 0), PortRotation.left, { 0.8, 0.8, 0, 1 } )
|
|
local port2 = Port:new( GridPoint:new(0, -1), PortRotation.up, { 0.8, 0, 0.8, 1 } )
|
|
local port3 = Port:new( GridPoint:new(3, 2), PortRotation.right, { 0.8, 0, 0, 1 } )
|
|
local port4 = Port:new( GridPoint:new(2, 3), PortRotation.down, { 0, 0, 0.8, 1 } )
|
|
local port5 = Port:new( GridPoint:new(2, 0), PortRotation.right, {0.8, 0.8, 0, 1} )
|
|
local port6 = Port:new( GridPoint:new(0, 2), PortRotation.down, { 0.8, 0.4, 0.4, 1 } )
|
|
|
|
local mecha1 = Mechanism:new( GridPoint:new(5, 5), GridPoint:new(3, 3), { port1:clone(), port2:clone(), port3:clone(), port4:clone() }, {0.5, 0.5, 0.5, 1} )
|
|
|
|
local mecha2 = Mechanism:new( GridPoint:new(10, 5), GridPoint:new(2, 2), { port1:clone(), port2:clone(), port5:clone(), port6:clone() }, {0.5, 1, 0.5, 1} )
|
|
|
|
local mecha3 = Mechanism:new( GridPoint:new(13, 5), GridPoint:new(2, 1), { port1:clone(), port2:clone(), port5:clone() }, {1, 0.5, 0.5, 1} )
|
|
|
|
local conveyorPortI1 = Port:new( GridPoint:new(-1, 0), PortRotation.left, Color.input )
|
|
local conveyorPortI2 = Port:new( GridPoint:new(0, -1), PortRotation.up, Color.input )
|
|
local conveyorPortI3 = Port:new( GridPoint:new(0, 1), PortRotation.down, Color.input )
|
|
local conveyorPortO = Port:new( GridPoint:new(1, 0), PortRotation.right, Color.output )
|
|
local conveyorMecha = Mechanism:new( GridPoint:new(0, 0), GridPoint:new(1, 1), {
|
|
conveyorPortI1:clone(),
|
|
conveyorPortI2:clone(),
|
|
conveyorPortI3:clone(),
|
|
conveyorPortO:clone()
|
|
}, Color.mechanism )
|
|
|
|
local mechs = { conveyorMecha, mecha2, mecha3 }
|
|
local actions = { 'none', 'first', 'second', 'third' }
|
|
|
|
local selected = 0
|
|
|
|
function selectorUpdate()
|
|
for index, action in ipairs(actions) do
|
|
if Input:actionReleased(action) then
|
|
selected = index - 1
|
|
break
|
|
end
|
|
end
|
|
end
|
|
|
|
---@return Mechanism|nil
|
|
function getSelected()
|
|
if selected > 0 then
|
|
return mechs[selected]
|
|
else
|
|
return nil
|
|
end
|
|
end
|