NOTE: still fixing it up, feel free test it out

Also, feel free to share any ideas about what should be added.
Moar notes:
- Doesnt work inside mines yet, go to a mountain side
- use 800x600 resolution on your gameplay window
New in 1.02:
- Minimize button (the yellow one in the corner)
- Adds granite to stone keys if you have them
- Colors veins so you can see where old one ends and new begins
How to get started
1) You need a shovel, portable forge and metal keys in your backpack
2) start script, move the script window over the game window so that the red circle
aims at your feet
3) press setup button, it'll look for the shovel, forge etc.
4) press scan button, a series of smaller buttons will appear on the HUD
5) clicking one of the small buttons will do something depending on their color:
blue - spawns small green/[other color] buttons
green - moves there
[other color] - mines there if it's close enough
On the side, there are more buttons:
Scan - If screen is empty, it'll scan the area and spawn blue buttons
Wipe - Will empty the screen
Smelt - smelts ore
Keys - Adds ingots and granite (if you have stone keys) to keys
Setup - This is the button you need to press first, otherwise nothing will happen
The editable number - defines the "rate of mining", 20 is good, a bit more if laggy, 15 is pretty much minimum.
I hope I didn't forget anything...
Code: Select all
; version - 1.02
tile init
set %delta 23
set %halfdelta 11
set %veinEmptyMsg no_metal_here
set %miningFailMsg You_loosen_some_rocks
set %miningSuccessMsg ore_in_your_backpack
set %cantMineMsg mine_there
set %cantseeMsg Target_cannot_be_seen
set %tooFarMsg too_far_away
set %backpackfullMsg your_backpack_is_full
set #lpc 1000
menu font bgcolor green
menu window size 900 600
menu window transparent 70
menu shape targetCircle 385 285 30 30 1 2 1 red 2 red
menu button rawScan 820 50 80 30 Scan
menu button wipeGrid 820 90 80 30 Wipe
menu button smelt 820 130 80 30 Smelt
menu button keys 820 170 80 30 Keys
menu font bgcolor red
menu button setup 820 210 80 30 Setup
menu font bgcolor yellow
menu text miningWaitText 820 250 Mining speed
menu edit miningWait 835 270 50 20
menu button minimize 0 0 20 20
set %minimized #false
menu show
set #menubutton none
while #true
{
if #menubutton = setup
{
set #menubutton none
gosub setup
while #true
{
if #menubutton = minimize
{
set #menubutton none
gosub minimize
}
if #menubutton = Smelt
{
set #menubutton none
gosub smelt
}
if #menubutton = keys
{
set #menubutton none
gosub keys
}
if #menubutton = rawScan
{
set #menubutton none
gosub rawScan #menures
}
if #menubutton = wipeGrid
{
set #menubutton none
gosub wiperawGrid
gosub wipesmallGrid
}
if rawGrid in #menubutton
{
str mid #menubutton 8 6
set #menubutton none
gosub wipesmallGrid
gosub smallGrid #strres
}
if smallGrid in #menubutton
{
str mid #menubutton 10 6
set #menubutton none
gosub wipesmallgrid
gosub wipeRawgrid
gosub handleSpot #strres
gosub rawScan
}
}
}
}
halt
sub minimize
{
if %minimized
{
menu window size 900 600
set %minimized #false
}
else
{
menu window size 20 20
set %minimized #true
}
return
}
sub handleSpot
{
set %string %1
str pos %string y
set %ypos #strres + 1
set %len %ypos - 3
str mid %string 2 %len
set %smallx #strres
str mid %string %ypos 2
set %smally #strres
set %x %rawx * 5 + %smallx
set %y %rawy * 5 + %smally
if ( abs %x <= 1 && abs %y <= 1 )
{
gosub handleClose %x %y
}
else
{
set %x #charposx + %x
set %y #charposy + %y
tile get %x %y 1
set %flag #tileflags
tile get %x %y 2
set %name #tilename
if ( impassable notin %flag ) && ( tree notin %name )
{
event pathfind %x %y #tilez
set #lpc 10
while ! ( #charposx = %x && #charposy = %y )
wait 1
set #lpc 1000
}
}
return
}
sub handleClose
{
set %spotX #charposx + %1
set %spotY #charposy + %2
tile get %spotX %spotY 1
if impassable notin #tileflags
{
event pathfind %spotX %spotY
set #lpc 10
while ! ( #charposx = %spotX && #charposy = %spotY )
wait 1
set #lpc 1000
return
}
else
{
set #lpc 10
set %spotZ #tileZ
set #lobjectid %shovelid
set #ltargetx %spotX
set #ltargety %spotY
set #ltargetz %spotZ
set #ltargetkind 2
set %stillMining #true
while %stillMining
{
event macro 17
target
event macro 22
menu get miningWait
wait #menures
gosub lookForStop
}
gosub smelt
}
set #lpc 1000
return
}
sub lookForStop
{
set %jInd #jindex + 2
for %i #jindex %jind
{
scanjournal %i
if ( ( %veinEmptyMsg in #journal ) || ( %cantMineMsg in #journal ) || ( %cantseeMsg in #journal ) || ( %toofarMsg in #journal ) || ( %backpackfullMsg in #journal ) )
{
set %stillMining #false
return
}
}
return
}
sub smelt
{
smelt_start:
set #lpc 10
finditem DWJ C_ , #backpackid
if #findcnt > 0
{
for %i 1 #findcnt
{
set #findindex %i
set #lobjectid #findid
event macro 17
target
set #ltargetid %forgeID
set #ltargetkind 1
event macro 22
wait 5
}
}
finditem DWJ C_ , #backpackid
if #findcnt > 0
goto smelt_start
set #lpc 1000
return
}
sub keys
{
set #lpc 10
finditem ENK C_ , #backpackid
if #findcnt > 0
{
set #lobjectid %keyID
event macro 17
while #contsize <> 505_270
wait 3
set %x #contposx + 294
set %y #contposy + 233
click %x %y
target
for %i 1 #findcnt
{
set #findindex %i
set #ltargetid #findid
set #ltargetkind 1
event macro 22
target
}
set %x #contposx + 294
set %y #contposy + 233
click %x %y r
key esc
}
finditem BVI C_ , #backpackid
if #findcnt > 0 && %stoneKeyID <> none
{
set #lobjectid %stonekeyID
event macro 17
while #contsize <> 505_270
wait 3
set %x #contposx + 294
set %y #contposy + 233
click %x %y
target
for %i 1 #findcnt
{
set #findindex %i
set #ltargetid #findid
set #ltargetkind 1
event macro 22
target
}
set %x #contposx + 294
set %y #contposy + 233
click %x %y r
key esc
}
set #lpc 1000
return
}
sub setup
{
;find shovel
finditem TWF C_ , #backpackid
if #findcnt > 0
{
set %shovelID #findid
}
else
{
event exmsg #charid 3 33 No shovel found! stopping!
halt
}
;find forge
finditem SMF C_ , #backpackid
if #findcnt > 0
{
set %forgeID #findid
}
else
{
event exmsg #charid 3 33 No forge found! stopping!
halt
}
;findkeys
set %keyID none
set %stoneKeyID none
finditem NUI C_ , #backpackid
if #findcnt > 0
{
for %i 1 #findcnt
{
set #findindex %i
event property #findid
if metal in #property
{
set %keyID #findid
}
if stone in #property
{
set %stonekeyID #findid
}
}
}
if %keyID = none
{
event exmsg #charid 3 33 No keys found! stopping!
halt
}
menu font bgcolor green
menu button setup 820 210 80 30 Setup
return
}
sub smallGrid
{
set %string %1
str pos %string y
set %ypos #strres + 1
set %len %ypos - 3
str mid %string 2 %len
set %rawx #strres
str mid %string %ypos 2
set %rawy #strres
for %i -2 2
{
for %j -2 2
{
set %x %i + %rawx * 5
set %y %j + %rawy * 5
gosub XYtoM %x %y
if ( ( %mx <= 790 && %mX >= 0 ) && ( %mY <= 590 && %mY >= 0 ) )
{
set %tilex #charposx + %x
set %tiley #charposy + %y
tile get %tilex %tiley 1
if impassable in #tileflags
{
set %colorX ( %tileX / 6 ) % 2
set %colorY ( %tileY / 6 ) % 2
if %colorX = 1 && %colorY = 1
set %bgColor $FF00FF
if %colorX = 0 && %colorY = 1
set %bgColor $00FFFF
if %colorX = 1 && %colorY = 0
set %bgColor $FFFF00
if %colorX = 0 && %colorY = 0
set %bgColor $0000FF
menu font bgcolor %bgColor
}
else
{
menu font bgcolor green
}
set %menubutton smallgridx , %i , y , %j
menu button %menubutton %mX %mY 10 10
}
}
}
return
}
sub wipeSmallGrid
{
for %i -2 2
{
for %j -2 2
{
set %menubutton smallgridx , %i , y , %j
menu delete %menubutton
}
}
return
}
sub rawScan
{
set %type %1
gosub wipeRawGrid
menu font bgcolor blue
for %i -3 3
{
for %j -3 3
{
set %x %i * 5
set %y %j * 5
gosub XYtoM %x %y
if ( ( %mx <= 790 && %mX >= 0 ) && ( %mY <= 590 && %mY >= 0 ) )
{
set %buttonname rawGridx , %i , y , %j
menu button %buttonname %mX %mY 10 10
}
}
}
gosub smallgrid x0y0
return
}
sub XYtoM
{
set %mX 400 + %1 * %delta - %2 * %delta - 5
set %mY 300 + %1 * %delta + %2 * %delta - 5
return
}
sub wipeRawGrid
{
for %i -3 3
{
for %j -3 3
{
set %buttonname rawgridx , %i , y , %j
menu delete %buttonname
}
}
return
}