All scripts

Iron Miner Varrock East

by SolemnVanguard ·Mining

Mines in Varock East with banking

0

Installed

1.0

Version

21 Aug 2026

Updated

About this script

Mines in Varock East with banking, build in sleep, bank from chest and mod protection

Builds

VersionKindPublishedSizeWhat changed
1.0 current text script 21 Aug 2026 8 KB First upload.

Source of 1.0

Published by the author. This is the current build, exactly as it will be delivered.

script "Iron Miner Varrock East"
author "SolemnVanguard"
version "1.0"
every 600

# Mines Iron rock (id 102) at tile(75, 542) and tile(76, 543), ignoring
# the rock at tile(76, 542). When the inventory is full, walks the path
# to Bank Chest (id 942) near tile(98, 509), deposits all Iron ore
# (id 151), then walks back and resumes mining. Uses Sleeping Bag
# (id 1263) at 100% fatigue.
#
# Teleport protection: if the character's tile jumps more than 20 tiles
# between passes, the script halts (shows a red warning) rather than
# continuing from an unknown location.
#
# Fatigue failsafe: if fatigue jumps more than 25 points in a single
# pass, that is treated as suspicious (e.g. a mod forcing it up to test
# you) and the script halts (shows an orange warning) instead of using
# the Sleeping Bag as if it were normal.

var stuckCount = 0

var lastTile = tile(0, 0)
var haveLastTile = false
var pendingJump = false
var haltedTeleport = false

var prevFatigueVal = -1
var haltedFatigueJump = false
var FatigueJumpLimit = 25

fun halted() -> bool {
    return haltedTeleport or haltedFatigueJump
}

# Flags the script if the position jumped further than a normal pass of
# walking or mining could explain. A single stray reading is not enough -
# the jump must still be there on the NEXT check too before it counts.
fun teleportCheck() {
    let now = myTile()
    if haveLastTile {
        let jumped = distance(lastTile, now)
        if jumped > 20 {
            if pendingJump {
                print("Jumped", jumped, "tiles, confirmed on second check - halting")
                haltedTeleport = true
                lastTile = now
            } else {
                print("Jumped", jumped, "tiles - unconfirmed, checking again next pass")
                pendingJump = true
            }
        } else {
            pendingJump = false
            lastTile = now
        }
    } else {
        lastTile = now
        haveLastTile = true
    }
}

# Flags the script if fatigue rose by more than FatigueJumpLimit points
# since the last check - a real person's fatigue does not spike like
# that, so this usually means it was forced up (e.g. a mod testing you).
fun fatigueSuspiciousCheck() {
    let curFatigue = fatigue()
    if prevFatigueVal >= 0 {
        let jump = curFatigue - prevFatigueVal
        if jump > FatigueJumpLimit {
            print("Fatigue spike detected:", prevFatigueVal, "->", curFatigue, "- halting")
            haltedFatigueJump = true
        }
    }
    prevFatigueVal = curFatigue
}

on start {
    if not bankAvailable() {
        print("Bank not available")
    }
    if not minimapAvailable() {
        print("Warning: minimap hooks not ready yet - walkPath may misbehave")
    }

    pathStart("route", "mine", tile(75, 543))
    pathTile("route", tile(74, 543))
    pathTile("route", tile(75, 536))
    pathTile("route", tile(75, 530))
    pathTile("route", tile(79, 522))
    pathTile("route", tile(83, 514))
    pathTile("route", tile(90, 511))
    pathFinish("route", "bank", tile(99, 512))
}

state mining {
    teleportCheck()
    fatigueSuspiciousCheck()
    if halted() { return 999999 }

    if isSleeping() {
        print("Sleeping, fatigue left to sleep off:", sleepFatigue())
        return 2000
    }
    if fatigue() >= 100 {
        print("Fatigue is 100 - using Sleeping Bag")
        let bag = invItem(1263)
        if bag != none {
            interact(bag, "Sleep")
        }
        return random(600, 900)
    }

    if invIsFull() { become goingToBank }

    if batchActive() { return 100 }

    for rock in objectsByDistance(within: 5) {
        if rock.id == 102 and rock.tile != tile(76, 542) {
            if reach(rock) == "DRAWN" {
                interact(rock, "Mine")
            }
            return random(900, 1400)
        }
    }

    print("No iron rock found - waiting")
    return 1000
}

state goingToBank {
    teleportCheck()
    fatigueSuspiciousCheck()
    if halted() { return 999999 }

    if isSleeping() {
        print("Sleeping, fatigue left to sleep off:", sleepFatigue())
        return 2000
    }
    if fatigue() >= 100 {
        print("Fatigue is 100 - using Sleeping Bag")
        let bag = invItem(1263)
        if bag != none {
            interact(bag, "Sleep")
        }
        return random(600, 900)
    }

    let how = walkPath("route", "bank")

    if how == "ARRIVED" {
        stuckCount = 0
        become banking
    } else if how == "WALKING" {
        stuckCount = 0
        return 900
    } else if how == "CROSSING" {
        stuckCount = 0
        return 1500
    } else if how == "BLOCKED" or how == "STUCK" {
        stuckCount = stuckCount + 1
        print("Blocked/stuck (", stuckCount, ") - waiting for it to clear")
        if stuckCount >= 10 {
            print("Been stuck too long - resetting path")
            pathReset("route")
            stuckCount = 0
        }
        return 1200
    } else {
        print("goingToBank status:", how)
        return 1000
    }
}

state banking {
    teleportCheck()
    fatigueSuspiciousCheck()
    if halted() { return 999999 }

    if isSleeping() {
        print("Sleeping, fatigue left to sleep off:", sleepFatigue())
        return 2000
    }
    if fatigue() >= 100 {
        if bankIsOpen() {
            bankClose()
            return 600
        }
        print("Fatigue is 100 - using Sleeping Bag")
        let bag = invItem(1263)
        if bag != none {
            interact(bag, "Sleep")
        }
        return random(600, 900)
    }

    let chest = nearestObject(id: 942, within: 5)
    if chest == none {
        print("No Bank Chest (942) found - waiting")
        return 1000
    }

    if not bankIsOpen() {
        let howReach = reach(chest)
        print("reach(chest) =", howReach)
        if howReach == "DRAWN" {
            let opened = interact(chest, "open")
            print("interact(chest, 'open') =", opened)
            wait until bankIsOpen() timeout 2000 else { return 300 }
        }
        return 1000
    }

    bankDepositAll(151)
    bankClose()
    become goingToMine
}

state goingToMine {
    teleportCheck()
    fatigueSuspiciousCheck()
    if halted() { return 999999 }

    if isSleeping() {
        print("Sleeping, fatigue left to sleep off:", sleepFatigue())
        return 2000
    }
    if fatigue() >= 100 {
        print("Fatigue is 100 - using Sleeping Bag")
        let bag = invItem(1263)
        if bag != none {
            interact(bag, "Sleep")
        }
        return random(600, 900)
    }

    let how = walkPath("route", "mine")

    if how == "ARRIVED" {
        stuckCount = 0
        become mining
    } else if how == "WALKING" {
        stuckCount = 0
        return 900
    } else if how == "CROSSING" {
        stuckCount = 0
        return 1500
    } else if how == "BLOCKED" or how == "STUCK" {
        stuckCount = stuckCount + 1
        print("Blocked/stuck (", stuckCount, ") - waiting for it to clear")
        if stuckCount >= 10 {
            print("Been stuck too long - resetting path")
            pathReset("route")
            stuckCount = 0
        }
        return 1200
    } else {
        print("goingToMine status:", how)
        return 1000
    }
}

on render {
    if halted() {
        let flashOn = wrap(nowMillis(), 0, 999) < 500
        let bg = "#cc0000ee"
        if haltedTeleport {
            if not flashOn { bg = "#660000ee" }
            paintRoundFill(4, 300, 220, 60, 12, bg)
            paintTextCenteredSized(114, 322, "TELEPORTED", "white", 16)
        } else {
            bg = "#cc6600ee"
            if not flashOn { bg = "#663300ee" }
            paintRoundFill(4, 300, 220, 60, 12, bg)
            paintTextCenteredSized(114, 322, "FATIGUE SPIKE", "white", 16)
        }
        paintTextCenteredSized(114, 344, "SCRIPT STOPPED", "white", 12)
    }
}