diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index e1783e4..bfc88fb 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -926,32 +926,15 @@ end ------------------------------------------------------------------------------------------------------------- -- funzione che controlla validità delle combinazioni proposte local function IsCombinationAvailable( sCombination, nUnloadPos) + -- TODO scelta combinazione forzato DA RIMUOVERE!! Serve modifica al BEAM. + BEAM.BeamWall = true + BEAM.Rotation = {} + BEAM.Rotation.bStandard = true + -- BASIC : posizione di scarico come posizionamento iniziale - if not BEAM.BeamWall or BEAM.Rotation.Basic then - nUnloadPos = 1 + if not BEAM.BeamWall or BEAM.Rotation.bBasic then local ExtraRotation = nUnloadPos + 3 - if string.sub( sCombination, nUnloadPos, nUnloadPos) == '1' and string.sub( sCombination, ExtraRotation, ExtraRotation) == '0' then - if not BeamData.ROT90 and string.sub( sCombination, nUnloadPos+1, nUnloadPos+1) == '1' then - return false - elseif not BeamData.ROT180 and string.sub( sCombination, nUnloadPos+2, nUnloadPos+2) == '1' then - return false - else - return true - end - else - return false - end - -- NO ROTATION : solo posizione di partenza - elseif BEAM.Rotation.bNoRotation then - if sCombination == '1000' then - return true - else - return false - end - -- STANDARD : come BASIC ma ammesse anche le prerotazioni (posizione di scarico può essere diversa da posizione iniziale) - elseif BEAM.Rotation.Standard then - local ExtraRotation = EgtIf( nUnloadPos + 3 > 4, nUnloadPos + 3 - 4, nUnloadPos + 3) - if nUnloadPos == 2 or nUnloadPos == 4 then + if nUnloadPos ~= 1 then return false elseif string.sub( sCombination, nUnloadPos, nUnloadPos) == '1' and string.sub( sCombination, ExtraRotation, ExtraRotation) == '0' then if not BeamData.ROT90 and string.sub( sCombination, nUnloadPos+1, nUnloadPos+1) == '1' then @@ -964,15 +947,43 @@ local function IsCombinationAvailable( sCombination, nUnloadPos) else return false end - -- FULL COMBI : ammesso anche rotazione finale diversa da quella di partenza - elseif BEAM.Rotation.FullCombi then + -- NO ROTATION : solo posizione di partenza + elseif BEAM.Rotation.bNoRotation then + if sCombination == '1000' and nUnloadPos == 1 then + return true + else + return false + end + -- STANDARD : come BASIC ma ammesse anche le prerotazioni (posizione di scarico può essere diversa da posizione iniziale) + -- TODO : In caso di sezione quadrata, la tipologia STANDARD può diventare FULL COMBI. + elseif BEAM.Rotation.bStandard then local ExtraRotation = EgtIf( nUnloadPos + 3 > 4, nUnloadPos + 3 - 4, nUnloadPos + 3) + local Rotation90 = EgtIf( nUnloadPos + 1 > 4, nUnloadPos + 1 - 4, nUnloadPos + 1) + local Rotation180 = EgtIf( nUnloadPos + 2 > 4, nUnloadPos + 2 - 4, nUnloadPos + 2) + if nUnloadPos == 2 or nUnloadPos == 4 then + return false + elseif string.sub( sCombination, nUnloadPos, nUnloadPos) == '1' and string.sub( sCombination, ExtraRotation, ExtraRotation) == '0' then + if not BeamData.ROT90 and string.sub( sCombination, Rotation90, Rotation90) == '1' then + return false + elseif not BeamData.ROT180 and string.sub( sCombination, Rotation180, Rotation180) == '1' then + return false + else + return true + end + else + return false + end + -- FULL COMBI : ammesso anche rotazione finale diversa da quella di partenza + elseif BEAM.Rotation.bFullCombi then + local ExtraRotation = EgtIf( nUnloadPos + 3 > 4, nUnloadPos + 3 - 4, nUnloadPos + 3) + local Rotation90 = EgtIf( nUnloadPos + 1 > 4, nUnloadPos + 1 - 4, nUnloadPos + 1) + local Rotation180 = EgtIf( nUnloadPos + 2 > 4, nUnloadPos + 2 - 4, nUnloadPos + 2) if string.sub( sCombination, nUnloadPos, nUnloadPos) ~= '1' or string.sub( sCombination, ExtraRotation, ExtraRotation) == '1' then return false else - if not BeamData.ROT90 and string.sub( sCombination, nUnloadPos+1, nUnloadPos+1) == '1' then + if not BeamData.ROT90 and string.sub( sCombination, Rotation90, Rotation90) == '1' then return false - elseif not BeamData.ROT180 and string.sub( sCombination, nUnloadPos+2, nUnloadPos+2) == '1' then + elseif not BeamData.ROT180 and string.sub( sCombination, Rotation180, Rotation180) == '1' then return false else return true @@ -980,6 +991,9 @@ local function IsCombinationAvailable( sCombination, nUnloadPos) end else -- forzo comportamento BASIC + if not BEAM.Rotation then + BEAM.Rotation = {} + end BEAM.Rotation.Basic = true return IsCombinationAvailable( sCombination, nUnloadPos) end