The Wiki for Tale 4 is in read-only mode and is available for archival and reference purposes only. Please visit the current Tale 11 Wiki in the meantime.

If you have any issues with this Wiki, please post in #wiki-editing on Discord or contact Brad in-game.

User:Obol/Macros/CCOven

From A Tale in the Desert
Jump to navigationJump to search

CCOven (requires ObolObjects in .../ACTool/marcors)

//Charcoal Oven - modified Ver 2.3
//
// Setup:  This handles from 1 to 8 charcoal ovens at a time.  Pin the windows
//         in 2 rows of 4 starting in top left corner.  But them up together but
//         Don't overlap them at all.  I suggest at least 300
//         wood per oven and a normally hold about 150 water jugs (for 8 ovens).
//         All ovens are slightly different but I suggest that you put your
//         fastest burning oven first in line.  You can tweak the settings
//         to your liking in the new GUI window.  Your settings will be saved.
//				 SETUP ADDENUM BELOW
//
//  If you see anything odd, /chat me.
//
//  ENJOY! :)
//  Anka
//
//  This version has been modified by rwindmtg
//
// 	Follow setup as writen by anka and adust the check bars interval acording to
//  the number of ovens used (more ovens less time)
//
// 	Settings provided are those for 4 ovens and have done 3 whole runs without probs for me
//
//  ineterval increace on the menu will increce the wait between checks delay
//  when an oven finishes. hopefully this will keep the chk interval for each
//  oven the same.
//  if win setup is checked place all the windows in the top left corner on top of eachother
//
//	The modifications are to allow the macro to moniter each oven indervidually
//
//
// This version has been modified by Obol
// I only use 4 ovens, I do not expect it to work well with more
//
// 1.) Added a routine to pause macro if user ALT Tabs away from game window.
// 2.) Added a routine to detect if an oven explodes or is snuffed out
//     or it is completed, it will stop monitoring that oven

// Must have ObolObjects.mac in macos folder

Include ObolObjects.mac
Constants
  //User Definable variables
  Ovens = 2       //Number of Ovens you are running. 1-8
  HeatMinX = 129
  HeatX = 162      //Threshold for Heat bar, increase or decrease as needed.
  HeatMaxX = 178
  Oxy1X = 95
  Oxy2X = 134
  WoodX = 104      //Wood threshold, adds wood/round up to this point.
  WaterX = 77      //Alowable water level, not much play here.. dont lower more than 2
  DangerX = 160    //Threshold for Danger bar, increase or decrease as needed.
  DangerMaxX = 170 // maximum danger lvl
  RGBBlue = 220    //Threshold for detecting the color blue.
  RGBGreen = 250   //Threshold for detecting the color green.  Some video cards
  //                 are having problems with this.  If you are having problems, run
  //                 just 1 oven and try lowering this number by 10 at a time.  It's
  //                 hard for me to see what is going on without using your pc :(
  //                 This method is used for RGBBlue and RGBGreen.
  CheckDelay = 500
  Guild = 1       // 1 for Guilded or public ovens, 0 for Personal ovens
  //End User variables
  AddX = 215      // 215-Personal   212-Guilded
  Add2X = 15
  Add1Y = 65
  Add2Y = 17
  Add3Y = 233
  HeatMin = 116
  HeatMax = 174
  maxwoodx = 160
  maxwood = 0
  DangerMax = 0
  BeginX = 103
  BeginY = 229
  NewX = 0
  New2X = 0
  New3X = 0
  New2Y = 0
  NewY = 0
  Heat = 0
  Oxy = 0
  Wood = 0
  Water = 0
  Danger = 0
  Status = 0
  HeatY = 140
  OxyY = 152
  WoodY = 164
  WaterY = 176
  DangerY = 188
  StatusX = 172
  StatusY = 200
  WoodBX = 35
  WoodBY = 234
  WaterBX = 85
  Vent0 = 130
  Vent1 = 155
  Vent2 = 180
  VentBX = 0
  Num = 0
  Jump = 5 // should be 5
  JumpM = 0
  Jumped = 0
  Used = 0
  MDelay = 250
  SDelay = 180 // 200
  S1Delay = 85 // 100
  Count = 0
  CountM = 0
  MouseX = 0
  MouseY = 0
  // oven stas chks
  oven1 = 0
  oven2 = 0
  oven3 = 0
  oven4 = 0
  oven5 = 0
  oven6 = 0
  oven7 = 0
  oven8 = 0
  curentoven = 1
  looped = 1
  sHeatMinX = 0
  sHeatX = 0
  sHeatMaxX = 0
  sHeatY = 0
  sOxy1X = 0
  sOxy2X = 0
  sOxyY = 0
  sWoodX = 0
  sWoodY = 0
  sWaterX = 0
  sWaterY = 0
  sDangerY = 0
  sStatusX = 0
  sStatusY = 0
  sDangerX = 0
  sDangermaxX = 0
  smaxwoodx = 0
  amaxwood = 0
  ovenfinidhed = 0
  OldVent1 = 1
  OldVent2 = 1
  OldVent3 = 1
  OldVent4 = 1
  OldVent5 = 1
  OldVent6 = 1
  OldVent7 = 1
  OldVent8 = 1
  WoodNum1 = 0
  WoodNum2 = 0
  WoodNum3 = 0
  WoodNum4 = 0
  WoodNum5 = 0
  WoodNum6 = 0
  WoodNum7 = 0
  WoodNum8 = 0
  interval = 0
  ovendone = 0
  setup = 0
  WinX = 3
  WinY = 29
  dragX = 3
  dragY = 115
  m = 1
  
  pausing = 0
  
  CloseStartX = 1003
  CloseStartY = 43
  
  Iron = 0
  Copper = 1
  
  
  CloseX = 0
  CloseY = 0
  
  beginButtonX = 0
  beginButtonY = 0
  
  ovenPoofed = 0
End

Form ccOven, Settings // settings listed here are for 4 ovens
  ed1=Combobox:Ovens:1, 2, 3, 4, 5, 6, 7, 8
  ed2=CheckBox:Guilded?:True
  ed16=checkbox:Window Setup :True
  ed3=Editbox:Heat                  (75-188):162
  ed10=Editbox:HeatMin            (75-188):116
  ed11=Editbox:HeatMax           (75-188):174
  ed4=Editbox:Low Oxy            (75-188):95
  ed5=Editbox:High Oxy           (75-188):134
  ed6=Editbox:Wood                (75-188):104
  ed7=Editbox:Water                (75-188):77
  ed13=Editbox:Danger              (75-188):160 // now used
  ed15=Editbox:Max Danger					(75-188):170	// companion value
  ed8=Editbox:RGBGreen:240
  ed9=Editbox:RGBBlue:220
  ed12=Editbox:Check Bars Interval  (miliseconds):500
  ed14=Editbox:Interval Increace    (miliseconds):0
end

FormLoad ccOven, ccOvenall.frm

if ShowForm ccOven
  SetConst Ovens = ccOven[ed1]
  If ccOven[ed2] = True
    SetConst Guild = 1
  Else
    SetConst Guild = 0
  End
  If ccOven[ed16] = True
    Setconst setup = 1
  Else
    Setconst setup = 0
  End
  SetConst HeatX = ccOven[ed3]
  SetConst Oxy1X = ccOven[ed4]
  SetConst Oxy2X = ccOven[ed5]
  SetConst WoodX = ccOven[ed6]
  SetConst WaterX = ccOven[ed7]
  Setconst DangerX = ccOven[ed13]
  setconst DangerMaxX = ccOven[ed15]
  SetConst RGBGreen = ccOven[ed8]
  SetConst RGBBlue = ccOven[ed9]
  SetConst HeatMin = ccOven[ed10]
  SetConst HeatMax = ccOven[ed11]
  SetConst CheckDelay = ccOven[ed12]
  Setconst interval = ccOven[ed14]
else
  Stop
end

FormSave ccOven, ccOvenall.frm

MousePos 45, 42
//MousePos 100, 20  //Activates eGenesis window.. Don't run ACTool maximized.
Delay $MDelay
LeftClick
Delay 200

If $Guild = 1
  Call Guild
End

If $setup = 1
  call WindowSetup
end

SetConst NewX = $BeginX
SetConst NewY = $BeginY
SetConst Count = 1
Loop $Ovens
  if $CheckforLostFocus = 0
    If $Count = $Jump
      SetConst NewX = $BeginX
      Compute NewY = $BeginY + $Add3Y
    End
    MousePos $NewX, $NewY
    Delay $MDelay
    Rightclick
    Delay $MDelay
    Compute NewX = $NewX + $AddX
    Compute Count = $Count + 1
  End
End
SetConst NewX = $BeginX  //Dont remember why this is here :)
Call Main

Procedure WindowSetup
  SetConst DragX = $winx
  setconst Dragy = $winy
  setconst count = 1
  Loop $ovens
    if $CheckforLostFocus = 0
      if $count = $jump
        Compute DragX = $DragX - (($count - 1) * $AddX)
        Compute DragY = $DragY + $Add3Y
      End
      MousePos $WinX, $WinY
      Delay $MDelay
      Dragto $DragX, $DragY
      Compute DragX = $DragX + $AddX
      compute count = $count + 1
    End
  End
End

Procedure Main
  SetConst CountM = 1
  SetConst Status = 0
  Compute JumpM = $Jump - 1
  
  // rwinds ver
  //stores some vars
  setconst sHeatMinX = $HeatMinX
  setconst sHeatX = $HeatX
  setconst sHeatMaxX = $HeatMaxX
  setconst sHeatY = $HeatY
  setconst sOxy1X = $Oxy1X
  setconst sOxy2X = $Oxy2X
  setconst sOxyY = $OxyY
  setconst sWoodX = $WoodX
  setconst sWoodY = $WoodY
  setconst sWaterX = $WaterX
  setconst sWaterY = $WaterY
  setconst sDangerY = $DangerY
  setconst sStatusX = $StatusX
  setconst sStatusY = $StatusY
  setconst sDangerX = $DangerX
  setconst sDangermaxX = $DangermaxX
  setconst smaxwoodx = $maxwoodx
  
  While $Status < $Ovens
    if $CheckforLostFocus = 0
      Loop $Ovens
        if $CheckforLostFocus = 0
          setconst curentoven = {loopno}
          If $CountM = $Jump
            SetConst NewX = $StatusX
            Compute NewY = $StatusY + $Add3Y
            SetConst New2X = $WaterBX
            Compute New2Y = $WoodBY + $Add3Y
          End
          // next 8 ifs determine if current oven has finished
          If $curentoven = 1 and $oven1 = 1
            setconst ovenfinidhed = 1
          End
          If $curentoven = 2 and $oven2 = 1
            setconst ovenfinidhed = 1
          End
          If $curentoven = 3 and $oven3 = 1
            setconst ovenfinidhed = 1
          End
          If $curentoven = 4 and $oven4 = 1
            setconst ovenfinidhed = 1
          End
          If $curentoven = 5 and $oven5 = 1
            setconst ovenfinidhed = 1
          End
          If $curentoven = 6 and $oven6 = 1
            setconst ovenfinidhed = 1
          End
          If $curentoven = 7 and $oven7 = 1
            setconst ovenfinidhed = 1
          End
          If $curentoven = 8 and $oven8 = 1
            setconst ovenfinidhed = 1
          End
          
          If $ovenfinidhed = 0 //skips if set to 1
            Call CheckBars
            
            if $curentoven = 1
              Case
              When $HeatMin = 1
                Call Wood
                Set WoodNum1 = 1
              Else
                If $Heat = 0 and $Danger = 0
                  If $WoodNum1 = 0  and $Wood = 0
                    Call Wood
                    Set WoodNum1 = 1
                  else
                    Set WoodNum1 = 0
                  End
                Else
                  If $Heat = 1 or $Danger = 1
                    If $Water = 0 or $HeatMax = 1 or $DangerMax = 1
                      Call Water
                    End
                  End
                End
              End
            End
            if $curentoven = 2
              Case
              When $HeatMin = 1
                Call Wood
                Set WoodNum2 = 1
              Else
                If $Heat = 0 and $Danger = 0
                  If $WoodNum2 = 0  and $Wood = 0
                    Call Wood
                    Set WoodNum2 = 1
                  else
                    Set WoodNum2 = 0
                  End
                Else
                  If $Heat = 1 or $Danger = 1
                    If $Water = 0 or $HeatMax = 1 or $DangerMax = 1
                      Call Water
                    End
                  End
                End
              End
            End
            if $curentoven = 3
              Case
              When $HeatMin = 1
                Call Wood
                Set WoodNum3 = 1
              Else
                If $Heat = 0 and $Danger = 0
                  If $WoodNum3 = 0  and $Wood = 0
                    Call Wood
                    Set WoodNum3 = 1
                  else
                    Set WoodNum3 = 0
                  End
                Else
                  If $Heat = 1 or $Danger = 1
                    If $Water = 0 or $HeatMax = 1 or $DangerMax = 1
                      Call Water
                    End
                  End
                End
              End
            End
            if $curentoven = 4
              Case
              When $HeatMin = 1
                Call Wood
                Set WoodNum4 = 1
              Else
                If $Heat = 0 and $Danger = 0
                  If $WoodNum4 = 0  and $Wood = 0
                    Call Wood
                    Set WoodNum4 = 1
                  else
                    Set WoodNum4 = 0
                  End
                Else
                  If $Heat = 1 or $Danger = 1
                    If $Water = 0 or $HeatMax = 1 or $DangerMax = 1
                      Call Water
                    End
                  End
                End
              End
            End
            if $curentoven = 5
              Case
              When $HeatMin = 1
                Call Wood
                Set WoodNum5 = 1
              Else
                If $Heat = 0 and $Danger = 0
                  If $WoodNum5 = 0  and $Wood = 0
                    Call Wood
                    Set WoodNum5 = 1
                  else
                    Set WoodNum5 = 0
                  End
                Else
                  If $Heat = 1 or $Danger = 1
                    If $Water = 0 or $HeatMax = 1 or $DangerMax = 1
                      Call Water
                    End
                  End
                End
              End
            End
            if $curentoven = 6
              Case
              When $HeatMin = 1
                Call Wood
                Set WoodNum6 = 1
              Else
                If $Heat = 0 and $Danger = 0
                  If $WoodNum6 = 0  and $Wood = 0
                    Call Wood
                    Set WoodNum6 = 1
                  else
                    Set WoodNum6 = 0
                  End
                Else
                  If $Heat = 1 or $Danger = 1
                    If $Water = 0 or $HeatMax = 1 or $DangerMax = 1
                      Call Water
                    End
                  End
                End
              End
            End
            if $curentoven = 7
              Case
              When $HeatMin = 1
                Call Wood
                Set WoodNum7 = 1
              Else
                If $Heat = 0 and $Danger = 0
                  If $WoodNum7 = 0  and $Wood = 0
                    Call Wood
                    Set WoodNum7 = 1
                  else
                    Set WoodNum7 = 0
                  End
                Else
                  If $Heat = 1 or $Danger = 1
                    If $Water = 0 or $HeatMax = 1 or $DangerMax = 1
                      Call Water
                    End
                  End
                End
              End
            End
            if $curentoven = 8
              Case
              When $HeatMin = 1
                Call Wood
                Set WoodNum8 = 1
              Else
                If $Heat = 0 and $Danger = 0
                  If $WoodNum8 = 0  and $Wood = 0
                    Call Wood
                    Set WoodNum8 = 1
                  else
                    Set WoodNum8 = 0
                  End
                Else
                  If $Heat = 1 or $Danger = 1
                    If $Water = 0 or $HeatMax = 1 or $DangerMax = 1
                      Call Water
                    End
                  End
                End
              End
            End
            
            If $looped > 3
              
              if $curentoven = 1/// Work in progress .......................... isolate ovens vents
                Case
                When $Oxy = 0
                  // Open vent full
                  If $OldVent1 <> $Oxy
                    SetConst VentBX = $Vent2
                    Call Vent
                    SetConst OldVent1 = 0
                    Delay 100
                  End
                When $Oxy = 1
                  // Oxy set normal
                  If $OldVent1 <> $Oxy
                    SetConst VentBX = $Vent1
                    Call Vent
                    SetConst OldVent1 = 1
                    Delay 100
                  End
                When $Oxy = 2
                  // Close vent
                  If $OldVent1 <> $Oxy
                    SetConst VentBX = $Vent0
                    Call Vent
                    SetConst OldVent1 = 2
                    Delay 100
                  End
                End
              End ///// Work in progresss ...............
              if $curentoven = 2/// Work in progress .......................... isolate ovens vents
                Case
                When $Oxy = 0
                  // Open vent full
                  If $OldVent2 <> $Oxy
                    SetConst VentBX = $Vent2
                    Call Vent
                    SetConst OldVent2 = 0
                    Delay 100
                  End
                When $Oxy = 1
                  // Oxy set normal
                  If $OldVent2 <> $Oxy
                    SetConst VentBX = $Vent1
                    Call Vent
                    SetConst OldVent2 = 1
                    Delay 100
                  End
                When $Oxy = 2
                  // Close vent
                  If $OldVent2 <> $Oxy
                    SetConst VentBX = $Vent0
                    Call Vent
                    SetConst OldVent2 = 2
                    Delay 100
                  End
                End
              End ///// Work in progresss ...............
              if $curentoven = 3/// Work in progress .......................... isolate ovens vents
                Case
                When $Oxy = 0
                  // Open vent full
                  If $OldVent3 <> $Oxy
                    SetConst VentBX = $Vent2
                    Call Vent
                    SetConst OldVent3 = 0
                    Delay 100
                  End
                When $Oxy = 1
                  // Oxy set normal
                  If $OldVent3 <> $Oxy
                    SetConst VentBX = $Vent1
                    Call Vent
                    SetConst OldVent3 = 1
                    Delay 100
                  End
                When $Oxy = 2
                  // Close vent
                  If $OldVent3 <> $Oxy
                    SetConst VentBX = $Vent0
                    Call Vent
                    SetConst OldVent3 = 2
                    Delay 100
                  End
                End
              End ///// Work in progresss ...............
              if $curentoven = 4/// Work in progress .......................... isolate ovens vents
                Case
                When $Oxy = 0
                  // Open vent full
                  If $OldVent4 <> $Oxy
                    SetConst VentBX = $Vent2
                    Call Vent
                    SetConst OldVent4 = 0
                    Delay 100
                  End
                When $Oxy = 1
                  // Oxy set normal
                  If $OldVent4 <> $Oxy
                    SetConst VentBX = $Vent1
                    Call Vent
                    SetConst OldVent4 = 1
                    Delay 100
                  End
                When $Oxy = 2
                  // Close vent
                  If $OldVent4 <> $Oxy
                    SetConst VentBX = $Vent0
                    Call Vent
                    SetConst OldVent4 = 2
                    Delay 100
                  End
                End
              End ///// Work in progresss ...............
              if $curentoven = 5/// Work in progress .......................... isolate ovens vents
                Case
                When $Oxy = 0
                  // Open vent full
                  If $OldVent5 <> $Oxy
                    SetConst VentBX = $Vent2
                    Call Vent
                    SetConst OldVent5 = 0
                    Delay 100
                  End
                When $Oxy = 1
                  // Oxy set normal
                  If $OldVent5 <> $Oxy
                    SetConst VentBX = $Vent1
                    Call Vent
                    SetConst OldVent5 = 1
                    Delay 100
                  End
                When $Oxy = 2
                  // Close vent
                  If $OldVent5 <> $Oxy
                    SetConst VentBX = $Vent0
                    Call Vent
                    SetConst OldVent5 = 2
                    Delay 100
                  End
                End
              End ///// Work in progresss ...............
              if $curentoven = 6/// Work in progress .......................... isolate ovens vents
                Case
                When $Oxy = 0
                  // Open vent full
                  If $OldVent6 <> $Oxy
                    SetConst VentBX = $Vent2
                    Call Vent
                    SetConst OldVent6 = 0
                    Delay 100
                  End
                When $Oxy = 1
                  // Oxy set normal
                  If $OldVent6 <> $Oxy
                    SetConst VentBX = $Vent1
                    Call Vent
                    SetConst OldVent6 = 1
                    Delay 100
                  End
                When $Oxy = 2
                  // Close vent
                  If $OldVent6 <> $Oxy
                    SetConst VentBX = $Vent0
                    Call Vent
                    SetConst OldVent6 = 2
                    Delay 100
                  End
                End
              End ///// Work in progresss ...............
              if $curentoven = 7/// Work in progress .......................... isolate ovens vents
                Case
                When $Oxy = 0
                  // Open vent full
                  If $OldVent7 <> $Oxy
                    SetConst VentBX = $Vent2
                    Call Vent
                    SetConst OldVent7 = 0
                    Delay 100
                  End
                When $Oxy = 1
                  // Oxy set normal
                  If $OldVent7 <> $Oxy
                    SetConst VentBX = $Vent1
                    Call Vent
                    SetConst OldVent7 = 1
                    Delay 100
                  End
                When $Oxy = 2
                  // Close vent
                  If $OldVent7 <> $Oxy
                    SetConst VentBX = $Vent0
                    Call Vent
                    SetConst OldVent7 = 2
                    Delay 100
                  End
                End
              End ///// Work in progresss ...............
              if $curentoven = 8/// Work in progress .......................... isolate ovens vents
                Case
                When $Oxy = 0
                  // Open vent full
                  If $OldVent8 <> $Oxy
                    SetConst VentBX = $Vent2
                    Call Vent
                    SetConst OldVent8 = 0
                    Delay 100
                  End
                When $Oxy = 1
                  // Oxy set normal
                  If $OldVent8 <> $Oxy
                    SetConst VentBX = $Vent1
                    Call Vent
                    SetConst OldVent8 = 1
                    Delay 100
                  End
                When $Oxy = 2
                  // Close vent
                  If $OldVent8 <> $Oxy
                    SetConst VentBX = $Vent0
                    Call Vent
                    SetConst OldVent8 = 2
                    Delay 100
                  End
                End
              End ///// Work in progresss ...............
              
            End
          End
          if $ovendone = 1
            setconst ovendone = 0
            call snuff
          End
          // nxt oven
          setconst ovenfinidhed = 0
          Compute Used = $Used + 1
          If $Used = $JumpM
            Compute HeatMinX = $HeatMinX - (($Used - 1) * $AddX)
            Compute HeatX = $HeatX - (($Used - 1) * $AddX)
            Compute HeatMaxX = $HeatMaxX - (($Used - 1) * $AddX)
            Compute HeatY = $HeatY + $Add3Y
            Compute Oxy1X = $Oxy1X - (($Used - 1) * $AddX)
            Compute Oxy2X = $Oxy2X - (($Used - 1) * $AddX)
            Compute OxyY = $OxyY + $Add3Y
            Compute WoodX = $WoodX - (($Used - 1) * $AddX)
            Compute maxwoodx = $maxwoodx - (($Used - 1) * $AddX)
            Compute WoodY = $WoodY + $Add3Y
            Compute WaterX = $WaterX - (($Used - 1) * $AddX)
            Compute WaterY = $WaterY + $Add3Y
            Compute DangerX = $DangerX - (($Used - 1) * $AddX)
            Compute DangermaxX = $DangermaxX - (($Used - 1) * $AddX)
            Compute DangerY = $DangerY + $Add3Y
            Compute StatusX = $StatusX - (($Used - 1) * $AddX)
            Compute StatusY = $StatusY + $Add3Y
            //Compute WaterBX = $WaterBX - (($Used -1) * $AddX)
            //Compute WoodBX = $WoodBX - (($Used - 1 ) * $AddX)
            //Compute WoodBY = $WoodBY + $Add3Y
            SetConst Jumped = 1
            Continue
          Else
            Compute HeatMinX = $HeatMinX + $AddX
            Compute HeatX = $HeatX + $AddX
            Compute HeatMaxX = $HeatMaxX + $AddX
            Compute Oxy1X = $Oxy1X + $AddX
            Compute Oxy2X = $Oxy2X + $AddX
            Compute WoodX = $WoodX + $AddX
            Compute maxwoodx = $maxwoodx + $AddX
            Compute WaterX = $WaterX + $AddX
            Compute DangerX = $DangerX + $AddX
            Compute DangermaxX = $DangermaxX + $AddX
            Compute StatusX = $StatusX + $AddX
            //Compute WaterBX = $WaterBX + $AddX
            //Compute WoodBX = $WoodBX + $AddX
          End
          Continue
        End
      End
      // resets positions
      Compute Used = 0
      Compute HeatMinX = $sHeatMinX
      Compute HeatX = $sHeatX
      Compute HeatMaxX = $sHeatMaxX
      Compute HeatY = $sHeatY
      Compute Oxy1X = $sOxy1X
      Compute Oxy2X = $sOxy2X
      Compute OxyY = $sOxyY
      Compute WoodX = $sWoodX
      Compute WoodY = $sWoodY
      Compute WaterX = $sWaterX
      Compute WaterY = $sWaterY
      Compute DangerY = $sDangerY
      Compute StatusX = $sStatusX
      Compute StatusY = $sStatusY
      compute DangerX = $sDangerX
      compute DangermaxX = $sDangermaxX
      compute maxwoodx = $smaxwoodx
      Delay $CheckDelay
      compute looped = $looped +1 // incremts loop for vent enable
    End
  End
End
// end rwinds ver

Procedure CheckBars	//reads the data
  MousePos $HeatMinX, $HeatY	//heat min
  Delay $SDelay
  LoadRGB {MouseX}, {MouseY}
  if {RGBBlue} < $RGBBlue
    SetConst HeatMin = 1
  else
    Set HeatMin = 0
  End
  
  MousePos $HeatX, $HeatY		//heat target
  Delay $SDelay
  LoadRGB {MouseX}, {MouseY}
  if {RGBBlue} > $RGBBlue
    SetConst Heat = 1
  Else
    SetConst Heat = 0
  End
  
  MousePos $HeatMaxX, $HeatY // heat max
  Delay $SDelay
  LoadRGB {MouseX}, {MouseY}
  if {RGBBlue} > $RGBBlue
    SetConst HeatMax = 1
  Else
    SetConst HeatMax = 0
  End
  
  MousePos $Oxy1X, $OxyY	// oxy min
  Delay $SDelay
  LoadRGB {MouseX}, {MouseY}
  if {RGBBlue} > $RGBBlue
    SetConst Oxy = 1
  Else
    SetConst Oxy = 0
  End
  
  MousePos $Oxy2X, $OxyY // oxy max
  Delay $SDelay
  LoadRGB {MouseX}, {MouseY}
  if {RGBBlue} > $RGBBlue
    SetConst Oxy = 2
  End
  
  MousePos $WoodX, $WoodY // wood target
  Delay $S1Delay
  LoadRGB {mousex}, {mousey}
  if {RGBBlue} > $RGBBlue
    SetConst Wood = 1
  Else
    SetConst Wood = 0
  End
  
  MousePos $maxwoodx, $WoodY // maxwood target
  Delay $S1Delay
  LoadRGB {mousex}, {mousey}
  if {RGBBlue} > $RGBBlue
    SetConst maxwood = 1
  Else
    SetConst maxwood = 0
  End
  
  MousePos $WaterX, $WaterY // water max
  Delay $S1Delay
  LoadRGB {mousex}, {mousey}
  if {RGBBlue} > $RGBBlue
    SetConst Water = 1
  Else
    SetConst Water = 0
  End
  
  MousePos $DangerX, $DangerY // danger warn??
  Delay $S1Delay
  LoadRGB {MouseX}, {MouseY}
  if {RGBBlue} > $RGBBlue
    SetConst Danger = 1
  Else
    SetConst Danger = 0
  End
  
  MousePos $DangerMaxX, $DangerY // danger out of controll??
  Delay $S1Delay
  LoadRGB {MouseX}, {MouseY}
  if {RGBBlue} > $RGBBlue
    SetConst DangerMax = 1
  Else
    SetConst DangerMax = 0
  End
  
  //84, 234
  compute beginButtonX = $StatusX - 88
  compute beginButtonY = $StatusY + 18

  // If oven explodes or snuffes out, stop monitoring it
  IsObject BeginButton at $beginButtonX, $beginButtonY
		SetConst ovenPoofed = 1
	end
 
  MousePos $StatusX, $StatusY  // checks to see if it is done
  LoadRGB {MouseX}, {MouseY}
  if {RGBGreen} > $RGBGreen or $ovenPoofed = 1
    //if {RGBRed} = 6 and {RGBGreen} = 254 and {RGBBlue} = 5
		SetConst ovenPoofed = 0
    compute Status = $Status + 1
    // say  yes // debuging code
    setconst ovendone = 1
    compute $CheckDelay = $CheckDelay + $interval
    If $curentoven = 1
      setconst oven1 = 1
    End
    If $curentoven = 2
      setconst oven2 = 1
    End
    If $curentoven = 3
      setconst oven3 = 1
    End
    If $curentoven = 4
      setconst oven4 = 1
    End
    If $curentoven = 5
      setconst oven5 = 1
    End
    If $curentoven = 6
      setconst oven6 = 1
    End
    If $curentoven = 7
      setconst oven7 = 1
    End
    If $curentoven = 8
      setconst oven8 = 1
    End
    
  Else
    // SetConst Status = 0
    compute Status = $Status + 0 // dummy line
    //say  no // debuging code
    //  End
  End
End

Procedure Water	// adds water
  SetConst NewX = $WaterBX
  SetConst NewY = $WoodBY
  Loop $Ovens
    IF {loopno} = $Jump
      SetConst NewX = $WaterBX
      Compute NewY = $WoodBY + $Add3Y
    End
    If {loopno} = $curentoven
      MousePos $NewX, $NewY
      Delay $SDelay
      Rightclick
      Delay $SDelay
    End
    Compute NewX = $NewX + $AddX
  End
  SetConst NewX = $WaterBX
End

Procedure Vent	// sets vent
  SetConst NewX = $VentBX
  SetConst NewY = $WoodBY
  Loop $Ovens
    IF {loopno} = $Jump
      SetConst NewX = $VentBX
      Compute NewY = $WoodBY + $Add3Y
    End
    If {loopno} = $curentoven
      MousePos $NewX, $NewY
      Delay $SDelay
      Rightclick
      Delay $SDelay
    End
    Compute NewX = $NewX + $AddX
  End
  SetConst NewX = $VentBX
End

Procedure Snuff // kills the oven
  SetConst New2X = $WaterBX
  SetConst New3X = $Vent2
  SetConst New2Y = $WoodBY
  Compute Num = $Used + 1
  Loop $Ovens
    IF {loopno} = $Jump
      SetConst New2X = $WaterBX
      SetConst New3X = $Vent2
      Compute New2Y = $WoodBY + $Add3Y
    End
    If {loopno} = $Num
      MousePos $New2X, $New2Y
      Loop 6
        Rightclick
      End
      MousePos $New3X, $WoodBY
      Delay 200
      Rightclick
    End
    Compute New2X = $New2X + $AddX
    Compute New3X = $New3X + $AddX
  End
End

Procedure Wood	// adds some wood
  if $ovendone = 0
    if $maxwood = 0
      SetConst NewX = $WoodBX
      SetConst NewY = $WoodBY
      Loop $Ovens
        IF {loopno} = $Jump
          SetConst NewX = $WoodBX
          Compute NewY = $WoodBY + $Add3Y
        End
        If {loopno} = $curentoven
          MousePos $NewX, $NewY
          Delay $SDelay
          Rightclick
          Delay $SDelay
        End
        Compute NewX = $NewX + $AddX
      End
      SetConst NewX = $WoodBX
    End
  end
end

Procedure Guild	// adjusts positions for guilded ovens
  //Compute BeginX = $BeginX - 7
  Compute BeginY = $BeginY + 16
  Compute AddX = $AddX - 3
  Compute Add3Y = $Add3Y + 16
  Compute Add1Y = $Add1Y - 16
  Compute WoodBY = $WoodBY + 16
  //Compute HeatX = $HeatX - 4
  Compute HeatY = $HeatY + 16
  //Compute Oxy1X = $Oxy1X
  //Compute Oxy2X =
  Compute OxyY = $OxyY + 16
  //Compute WoodX = $WoodX - 1
  Compute WoodY = $WoodY + 16
  Compute WaterY = $WaterY + 16
  //Compute DangerX = $DangerX - 4
  Compute DangerY = $DangerY + 16
  //Compute StatusX = $StatusX - 5
  Compute StatusY = $StatusY + 16
End
//Written with ACTool 5.3.0 by Anka
//Modified with ACTool 5.4.0 by rwindmtg
Bell Asterisk

Function CheckforLostFocus
  if {activewindow} contains eGenesis
    Compute Result = 0
    Exit
  Else
    pause
    MousePos 100, 20  //Activates eGenesis window.. Don't run ACTool maximized.
    Delay $MDelay
    LeftClick
    Delay 200
    Compute Result = 0
    Exit
    //Stop
  End
End