Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Live Scripting w/ Lua


    GhostData
     Share

    Recommended Posts

    Live Scripting w/ Lua

    Write scripts with lua using LuaJ

    This is my first attempt at writing a script. Wanted to write something where i can see the results immediately. Please post any errors here or on the Github. Thanks!

     

    xFoCkcy.pngBO4jsHl.png

    oPPBoyA.png

    Spoiler

    836309559_Screenshot2022-07-25033015.thumb.png.d5817dd960e5480ca2928114156df1e5.png1174904828_Screenshot2022-07-25033151.png.d012dbf29cbb55862e2a7f5c2a8e92fc.png

     

    Source: https://github.com/GhostDataIsDreaming/LiveScripting/

    Download Link: https://github.com/GhostDataIsDreaming/LiveScripting/releases

    VirusTotal: https://www.virustotal.com/gui/file/e0326c840a23950b4352503e6c8e3e297de8ac9cbc9780c85dc8adee83cfb173

    Edited by GhostData
    fix broken links
    Link to comment
    Share on other sites

    Posted (edited)

    Samples

    WoodcutAnywhere (Click here for most recent)

    Spoiler
    --[[
        Simple Wookcutting Script written in Lua
    
        Notes:
            1. [Important] This entire script is iterated on every onLoop
            2. Adjust frequency of script with Executing Interval to make it faster or slower
            3. Can be ran anywhere. Will chop trees nearby until inventory is full or is in combat
                    and will run to closest bank if either criteria is met
            4. No Antiban present. Figure that shit out yourselves.
    --]]
    local Players = luajava.bindClass("org.dreambot.api.methods.interactive.Players")
    local Walking = luajava.bindClass("org.dreambot.api.methods.walking.impl.Walking")
    local MethodProvider = luajava.bindClass("org.dreambot.api.methods.MethodProvider")
    local NPCs = luajava.bindClass("org.dreambot.api.methods.interactive.NPCs")
    local Inventory = luajava.bindClass("org.dreambot.api.methods.container.impl.Inventory")
    local Bank = luajava.bindClass("org.dreambot.api.methods.container.impl.bank.Bank")
    local GameObjects = luajava.bindClass("org.dreambot.api.methods.interactive.GameObjects")
    local Calculations = luajava.bindClass("org.dreambot.api.methods.Calculations")
    
    --[[
        Lets setup Main Variables to adjust script
    --]]
    local bankers = { "Banker" }
    local maxRadius = 10; -- Max Travel distance around starting tile
    local trees = { "Tree", "Oak Tree", "Willow" } -- Trees to Cut Down
    local logs = { "Logs", "Oak logs", "Willow logs" } -- Logs to deposit in bank
    
    --[[
        Variables for script, Do not modify. Script uses them
    --]]
    local startingArea = nil
    local bankLocation = nil
    local bankArea = nil
    
    --[[
        Define functions script can use
    --]]
    function isAtBank()
        if not bankLocation or not bankArea then
            bankLocation = Bank:getClosestBankLocation()
            bankArea = bankLocation:getArea(2)
        end
    
        if not NPCs:closest(bankers) then return false end
        return true
    end
    
    function isAtStartingArea()
        if not startingArea then
            startingArea = Players:localPlayer():getTile():getArea(maxRadius)
        end
    
        if not startingArea:contains(Players:localPlayer():getTile()) then return false end
        return true
    end
    
    --[[
        Actual Script
    --]]
    script.onStart(function()
        -- Grab Variables onStart
        isAtStartingArea()
        isAtBank()
    end)
    
    script.onLoop(function()
        local min = Calculations:random(100, 1000)
        local max = Calculations:random(1001, 5000)
    
        --MethodProvider:log("Waiting between " .. min .. " and " .. max);
        --MethodProvider:log("Inventory Full: " .. tostring(Inventory:isFull()));
        --MethodProvider:log("Is at Bank (" .. bankLocation:name() .. ")? " .. tostring(isAtBank()));
        --MethodProvider:log("Is at Starting Area? " .. tostring(isAtStartingArea()));
    
        if Inventory:isFull() then
            if (isAtBank()) then
                local banker = NPCs:closest(trees)
    
                if not Bank:isOpen() then
                    Bank:open()
                    MethodProvider:sleep(100, 1000)
                end
    
                for _, item in ipairs(logs) do
                    Bank:depositAll(item)
                    MethodProvider:sleep(25, 500)
                end
    
                Bank:close()
            else
                --MethodProvider:log("Walking to Bank Area");
                Walking:walk(bankArea:getRandomTile())
            end
        else if isAtStartingArea() then
            local me = Players:localPlayer()
    
            --MethodProvider:log("Is Interacted With? " .. tostring(me:isInteractedWith()));
            --MethodProvider:log("Is Animating? " .. tostring(me:isAnimating()));
            --MethodProvider:log("Animating = " .. tostring(me:getAnimation()));
    
            if me:getAnimation() == -1 then
                --MethodProvider:log("Pick Tree");
                local treeObject = GameObjects:closest(trees)
    
                if (treeObject) then
                    treeObject:interact("Chop down")
                end
            end
        else
            --MethodProvider:log("Walking to Starting Area");
            Walking:walk(startingArea:getRandomTile())
        end
        end
    
        return Calculations:random(min, max)
    end)

     

     

    Edited by GhostData
    broken link
    Link to comment
    Share on other sites

    Posted (edited)

    Update to v2.2 - Direct Download

    ChangeLog

    • Revamped the menus. Now includes 3 distinct menues. Loader, Editor, Settings
    • Rewrote the Script Loading, Handling, Executing
      -- Start your Lua Scripts with (script.)
      --Supports onStart, onLoop, onExit, onResume, onPaint
      --Supports onLoop calling even if not present, treats entire script as onLoop
    • Rewrote the sample WoodcutAnywhere. Start that shit anywhere and when your inventory is full it will walk to bank, deposit and then walk back
    • Option to choose samples from the Load Menu. Automatically run them when chose.
    Edited by GhostData
    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.