set %oak 0
set %Yew 0
set %Blood 0
set %Ash 0
set %Heart 0
set %Frost 0
set %scnt 0
set %logs zlk
set %all tlk_yws_xws_bwr_nws_fxs
set %saw agg_egg
set %bacpackid #backpackid
set %delay 15


gosub open
loop:
gosub cut
gosub dump
goto loop


sub open
display ok Target the chest your boards are in.
set #targcurs 1
hangout:
wait 5
if #targcurs = 1
goto hangout
wait 20
set %boxid #LTARGETID
set #LOBJECTID %boxid
      set #findmod 0_0
      set #NEXTCPOSX 65
      set #NEXTCPOSY 270
      event macro 17 0
return

sub cut
  retry:
gosub grab
    finditem %saw C_ , #backpackid
      wait 15
       if #findkind = -1
 	{
	goto bottomm
        }             
openagain:
          set #lobjectid #findid
            event macro 17 0
   set %scnt #scnt + 10
gump:
finditem %logs  C_ , #backpackid
wait %delay
if #findid = x
{
set %mody 411 + #contposy
set %modx 19 + #contposx
 CLICK  %modx %mody R
goto finish
}
event property #findid
 if #scnt > %scnt
    goto retry
if #contname <> generic_gump || #CONTSIZE <> 530_437
    goto retry
      wait %delay
if ash notin #property && oak notin #property && yew notin #property && heartwood notin #property && frostwood notin #property && bloodwood notin #property && #findcol <> 0
{
ignoreitem #findid
goto gump
}
set %modx 27 + #contposx
set %mody 90 + #contposy
       click %modx %mody x1
         wait %delay
if oak in #property
{
set %pixx 495 + #contposx
set %pixy 91 + #contposy
savepix %pixx %pixy 1
set %mody 372 + #contposy
set %modx 27 + #contposx
11:
if #scnt > %scnt
    goto click1
click %modx %mody x1
wait %delay
cmpPix 1 t 1
goto 11
click1:
set %mody 90 + #contposy
set %modx 234 + #contposx
click %modx %mody x1
wait %delay2
set %again 1
}
if ash in #property
{
set %pixx 495 + #contposx
set %pixy 91 + #contposy
savepix %pixx %pixy 1
set %mody 372 + #contposy
set %modx 27 + #contposx
12:
if #scnt > %scnt
    goto click2
click %modx %mody x1
wait %delay
cmpPix 1 t 1
goto 12
click2:
set %mody 110 + #contposy
set %modx 234 + #contposx
click %modx %mody x1
wait %delay2
set %again 1
}
if yew in #property
{
set %pixx 495 + #contposx
set %pixy 91 + #contposy
savepix %pixx %pixy 1
set %mody 372 + #contposy
set %modx 27 + #contposx
13:
if #scnt > %scnt
    goto click3
click %modx %mody x1
wait %delay
cmpPix 1 t 1
goto 13
click3:
set %mody 130 + #contposy
set %modx 234 + #contposx
click %modx %mody x1
wait %delay2
set %again 1
}
if heartwood in #property
{
set %pixx 495 + #contposx
set %pixy 91 + #contposy
savepix %pixx %pixy 1
set %mody 372 + #contposy
set %modx 27 + #contposx
14:
if #scnt > %scnt
    goto click4
click %modx %mody x1
wait %delay
cmpPix 1 t 1
goto 14
click4:
set %mody 150 + #contposy
set %modx 234 + #contposx
click %modx %mody x1
wait %delay2
set %again 1
}
if bloodwood in #property
{
set %pixx 495 + #contposx
set %pixy 91 + #contposy
savepix %pixx %pixy 1
set %mody 372 + #contposy
set %modx 27 + #contposx
15:
if #scnt > %scnt
    goto click5
click %modx %mody x1
wait %delay
cmpPix 1 t 1
goto 15
click5:
set %mody 170 + #contposy
set %modx 234 + #contposx
click %modx %mody x1
wait %delay2
set %again 1
}
if frostwood in #property
{
set %pixx 495 + #contposx
set %pixy 91 + #contposy
savepix %pixx %pixy 1
set %mody 372 + #contposy
set %modx 27 + #contposx
16:
if #scnt > %scnt
    goto click6
click %modx %mody x1
wait %delay
cmpPix 1 t 1
goto 16
click6:
set %mody 190 + #contposy
set %modx 234 + #contposx
click %modx %mody x1
wait %delay2
set %again 1
}

if ash notin #property && oak notin #property && yew notin #property && heartwood notin #property && bloodwood notin #property && frostwood notin #property
{
ignoreitem #findid 1
set %pixx 495 + #contposx
set %pixy 91 + #contposy
savepix %pixx %pixy 1
set %mody 372 + #contposy
set %modx 27 + #contposx
17:
if #scnt > %scnt
    goto click7
click %modx %mody x1
wait %delay
cmpPix 1 t 1
goto 17
click7:
set %mody 70 + #contposy
set %modx 234 + #contposx
click %modx %mody x1
wait %delay2
set %again 1
}
set %mody 71 + #contposy
set %modx 233 + #contposx
click %modx %mody x1
            WAIT %delay2
             set %scnt #scnt + 10
hang:
  if #scnt > %scnt
    return
if #CONTSIZE <> 530_437
      goto hang
gosub finish
bottomm:
ignoreitem reset
return

sub finish
finish:
if #CONTSIZE <> 530_437
goto bottom
set %mody 414 + #contposy
set %modx 24 + #contposx
click %modx %mody x1
if #CONTSIZE = 530_437
goto finish
bottom:
return

sub grab
finditem %logs c_ , %boxid
if #findid = x
goto grabout
event drag #findid
set %before_weight #weight
wait_it_out:
wait 5
msg 100 $
wait 10
if #lliftedkind = 0 || #weight = %before_weight
goto wait_it_out
wait 10
event macro 8 1
set %xXx #contposx + 140
set %yYy #contposy + 220
click %xXx %yYy p 
grabout:
if #findid = x
gosub menuu
return

sub dump
finditem %all c_ , #backpackid
     if #findkind = -1 && #lLiftedKind  <> 1
       {
           goto endit
             }

            if #findkind = 0
          {
IF #lLiftedKind  <> 1
     event drag #findid
wait 15
msg $
wait 5
       finditem %boxid C_
 if #findid = x
         goto opensecure
          set #findmod 20_10
set %scnt #scnt + 10
oredrop:
if %scnt < #scnt
      goto ore
              click #findx #findy p
                 wait 10
if #lliftedkind = 1
goto oredrop
                    goto ore
	            }
endit:
set %cutting 1
return

sub menuu
menu clear
menu window size 100 140
      menu window color BLACK
      menu font bgcolor BLACK
menu window title Bod counter
menu font align center
      menu font style
	menu font color red
	menu font size 11
menu text stat 18 0 Total Boards
      menu font align center
      menu font style
	menu font color green
	menu font size 11
menu text stat 5 25 %CHANGE
menu text stat 5 40 Oak
menu text stat 5 55 Ash
menu text stat 5 70 yew
menu text stat 5 85 Heart
menu text stat 5 100 Blood
menu text stat 5 115 Frost
	menu font align center
count:
      menu font style B
	menu font color RED
	menu font size 11
menu Delete stat1
menu text stat1 70 25 %b
menu text stat1 70 40 %oak
menu text stat1 70 55 %Ash
menu text stat1 70 70 %Yew
menu text stat1 70 85 %Heart
menu text stat1 70 100 %Blood
menu text stat1 70 115 %Frost
	menu font size 11
	menu font style B
	menu font color RED
set #menubutton N/A
	menu show 0 400
if %b > %stop
pause
return


