GhostData 6 Share Posted July 25, 2022 (edited) Live Scripting w/ Lua Write scripts with lua using LuaJ Wanted to write something where i can see the results immediately. Please post any errors here or on the Github. Thanks! Spoiler Source: https://github.com/GhostDataIsDreaming/GhostIsDreamingScripts/tree/main/LiveScripting Download Link: https://github.com/GhostDataIsDreaming/GhostIsDreamingScripts/releases VirusTotal: https://www.virustotal.com/gui/file/7ef83bd0e0880409ecd78c65a971f9d5f6f7752fe0ab7537f89e74a3964d7d32?nocache=1 Edited September 2, 2022 by GhostData fix broken links holic, yeeter, LostVirt and 1 other 1 3 Link to comment Share on other sites More sharing options...
GhostData 6 Author Share Posted July 26, 2022 (edited) Samples WoodcutAnywhere (Source - 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) MineAnywhere (Source - Most Recent) Spoiler --[[ Simple Mining Script written in Lua identical to the woodcutting one 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 deposits = { 11362, 113611, 11360, 10943, 11161 } -- Low Level ore deposits.. Clay, Tin, Copper ids local items = { "Clay", "Tin ore", "Copper ore" } -- Ores 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(deposits) if not Bank:isOpen() then Bank:open() MethodProvider:sleep(100, 1000) end for _, item in ipairs(items) 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("Mine"); local depsotiObject = GameObjects:closest(deposits) if (depsotiObject) then depsotiObject:interact("Mine") end end else --MethodProvider:log("Walking to Starting Area"); Walking:walk(startingArea:getRandomTile()) end end return Calculations:random(min, max) end) Edited August 19, 2022 by GhostData Added MineAnywhere Link to comment Share on other sites More sharing options...
yeeter 517 Share Posted July 27, 2022 Super neat! Link to comment Share on other sites More sharing options...
GhostData 6 Author Share Posted July 28, 2022 (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 July 28, 2022 by GhostData Link to comment Share on other sites More sharing options...
GhostData 6 Author Share Posted August 19, 2022 (edited) Update to v2.4 - Direct Download ChangeLog Added functions to be able to create guis inside of the lua scripts using wrapped swing components Added function `newInstance` to create new instances of classes Added function `require_local` to import local lua dependencies Updated `import` function Updated way that we load scripts. Works whether we run from SDN or as local. Created `MineAnywhere.lua` -- Based on `WoodcutAnywhere.lua` Fix bug related to New Empty Script Removed unnecessary logging to console Fixed bug for script.kill() & script.stop() Edited August 19, 2022 by GhostData Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now