Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

First script please be gentle lol

Featured Replies

Thanks for your time,

My first script, doesn't run. It builds, using IntelliJ. It doesn't log anything... Any and all help is appreciated. It is suppose to reanimate ensouled giant heads. 

Quote

import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.ui.MagicSpell;
import org.osbot.rs07.api.ui.Spells;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
public class HeadKiller
{
    @ScriptManifest(author = "freedom", name = "EnsouledHeadKiller", info = "Kills Ensouled Heads", version = 0.04, logo = "")
    public final class killer extends Script
    {
        @Override
        public final void onStart()
        {
            log("Script started...");
        }
        public boolean Combat;
        public boolean Head;
        public boolean Spell;
        public int Current;
        @Override
        public final int onLoop() throws InterruptedException
        {
            log("Setting up....");
            Combat = getCombat().isFighting();
            Head = getInventory().contains("Ensouled giant head");
            Spell = getMagic().canCast(Spells.ArceuusSpells.REANIMATE_GIANT);
            Current = 0;
            while ((Head == true) && (Spell == true));
            {
                if (Combat == false)
                {
                    getMagic().castSpell(Spells.ArceuusSpells.REANIMATE_GIANT);
                    getInventory().interact("Cast", "Ensouled giant head");
                    Current = Current + 1;
                    log("Currently killing number " + Current + ".");
                    sleep(random(200, 1200));
                    return 0;
                }
            }
            stop(true);
        return 0;
        }
        @Override
        public final void onExit() {
            log("Script exiting... We completed " + (Current - 1) + ".");
        }
    }


}

 

onLoop is a loop by itself, so using a while-loop inside is bad programming practice. You should use if-statements there.

Nice script considering it's your first one :) Gl with your future scripts.

Just noticed that you say it doesn't run. Why do you have a class within another class? You can just use one class and have that extend Script

  • Author

Thank you, no idea where I got that from. I will change it.

Lets be honest, I have like 4 hours making this. Mostly, looking at what others have done and trying to adapt it to my script. 

EDIT: It started, but insta logged out.

Edited by freedom1
WOOT ITS ALIVE!

17 minutes ago, freedom1 said:

Thank you, no idea where I got that from. I will change it.

Lets be honest, I have like 4 hours making this. Mostly, looking at what others have done and trying to adapt it to my script. 

EDIT: It started, but insta logged out.

Gratz mate 😛

Post the new code & I'll take a look at that :) What does the logger say when it logs out?

  • Author

Ok I changed stop() to log("logout") so I can see when it wants to log out.

I have an error though,

"Inventory widget is null, trying to guess position."

The counters for how many killed and completed work!

[INFO][Bot #1][07/04 01:06:31 PM]: Script started...
[INFO][Bot #1][07/04 01:06:31 PM]: Started script : EnsouledHeadKiller
[INFO][Bot #1][07/04 01:06:31 PM]: Setting up....
[INFO][Bot #1][07/04 01:06:32 PM]: logout
[ERROR][Bot #1][07/04 01:06:33 PM]: Inventory widget is null, trying to guess position.
[INFO][Bot #1][07/04 01:06:37 PM]: Currently killing number 1.
[INFO][Bot #1][07/04 01:06:38 PM]: Setting up....
[INFO][Bot #1][07/04 01:06:39 PM]: logout
[ERROR][Bot #1][07/04 01:06:40 PM]: Inventory widget is null, trying to guess position.
[INFO][Bot #1][07/04 01:06:45 PM]: Currently killing number 1.
[INFO][Bot #1][07/04 01:06:45 PM]: Setting up....
[INFO][Bot #1][07/04 01:06:46 PM]: logout
[ERROR][Bot #1][07/04 01:06:47 PM]: Inventory widget is null, trying to guess position.
[INFO][Bot #1][07/04 01:06:51 PM]: Currently killing number 1.
[INFO][Bot #1][07/04 01:06:51 PM]: Script EnsouledHeadKiller has paused!
 

Quote

import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.ui.MagicSpell;
import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.ui.Spells;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
    @ScriptManifest(author = "freedom", name = "EnsouledHeadKiller", info = "Kills Ensouled Heads", version = 0.05, logo = "")
    public final class HeadKiller extends Script
        {
            @Override
            public final void onStart()
                {
                    log("Script started...");
                }
            public boolean Combat;
            public boolean Head;
            public boolean Spell;
            public int Current;
            @Override
            public final int onLoop() throws InterruptedException
                {
                    log("Setting up....");
                    Combat = getCombat().isFighting();
                    Head = getInventory().contains("Ensouled giant head");
                    Spell = getMagic().canCast(Spells.ArceuusSpells.REANIMATE_GIANT);
                    Current = 0;
                    if ((Head == false) && (Spell == false));
                        {
                            log("logout");
                        }
                    if (Combat == false);
                        {
                            getMagic().castSpell(Spells.ArceuusSpells.REANIMATE_GIANT);
                            getInventory().interact("Cast", "Ensouled giant head");
                            Current = Current + 1;
                            log("Currently killing number " + Current + ".");
                            sleep(random(200, 1200));
                            return 0;
                        }
                }
            @Override
            public final void onExit()
                {
                    log("Script exiting... We completed " + (Current - 1) + ".");
                }
        }

 

Edited by freedom1

Not sure if you have to do this, but maybe open the inventory when checking if it contains smth. Same for spells.

  • Author

Will do Thanks,

I thought this was automatic.

I tried starting from the spell and inventory screens, manually. No luck.

Edited by freedom1

if you have ; after a while/if it will run that code no matter what

that would be what is logging you out.

  • Author
I didn't read that anywhere, thanks.

EDIT: that fixed the logout problem

but the inventory widget null error still exists, am I missing the correct import?

Currently it tries to cast the spell, but gets confused on the inventory screen, and then goes back to the spell tab and tries again

I tried a sleep timer but no luck

Quote

getMagic().castSpell(Spells.ArceuusSpells.REANIMATE_GIANT);
sleep(random(100,250));
getInventory().interact("Cast", "Ensouled giant head");
Current = Current + 1;
log("Currently killing number " + Current + ".");
sleep(random(200, 1200));
return 0;

 

Edited by freedom1

1 hour ago, freedom1 said:

I didn't read that anywhere, thanks.

EDIT: that fixed the logout problem

but the inventory widget null error still exists, am I missing the correct import?

Currently it tries to cast the spell, but gets confused on the inventory screen, and then goes back to the spell tab and tries again

I tried a sleep timer but no luck

 

learn to use conditional sleeps. It works great for stuff like that.

2 hours ago, freedom1 said:

I didn't read that anywhere, thanks.

EDIT: that fixed the logout problem

but the inventory widget null error still exists, am I missing the correct import?

Currently it tries to cast the spell, but gets confused on the inventory screen, and then goes back to the spell tab and tries again

I tried a sleep timer but no luck

 

Maybe try to split the interaction part so you can debug it more. First try to find the item in your inventory, and then interact on it

Item head = getInventory().getItem("Ensouled giant head");
log("Item was found");
head.hasAction("Cast");
log("Cast action was found on the item");
head.interact("Cast");

or something like that.

Also as suggested, check out the conditional sleep so you don't have fiddle with finding a good sleep amount. 

 section 9

Im also getting the same error on another script

[ERROR][Bot #1][07/05 01:38:00 AM]: Inventory widget is null, trying to guess position.

  • Author

Thanks to everyone who helped!

I have a working script only took 12hrs, but I did learn a lot.

I have no programing experience.

I could not get the spell to work, so I had to mouse click it =(.

Saturday Ill try to get it banking.

Quote

import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.api.ui.Spells;
import org.osbot.rs07.api.ui.Spells.ArceuusSpells;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
    @ScriptManifest(author = "freedom", name = "EnsouledHeadKiller", info = "Kills Ensouled Heads", version = 0.1, logo = "")
    public final class HeadKiller extends Script {
        @Override
        public final void onStart() {
            log("Script started...");
        }

        private boolean Combat;
        private boolean Head;
        private boolean CCSpell;
        private int Current = 0;
        private ArceuusSpells Spell;
        private int x;
        private int y;
        private boolean rightclick;
        @Override
        public final int onLoop() throws InterruptedException {
            log("Setting up....");
            Combat = getCombat().isFighting();
            log("Currently fighting " + Combat + ".");
            Head = getInventory().contains("Ensouled giant head");
            Spell = Spells.ArceuusSpells.REANIMATE_GIANT;
            CCSpell = getMagic().canCast(Spell);
            x = random(700,720);
            y = random(300,318);
            rightclick = false;
            log("Almost ready...");
            if ((!Head) || (!CCSpell)) {
                stop(false);
            }
            log("Runes and Heads are ready...");
            if (!Combat) {
                log("Not in combat...");
                if (getMagic().isSpellSelected()) {
                    if (getInventory().interact("Reanimate", "Ensouled giant head")) {
                        log("Killing Giant...");
                    }
                }
                else {
                        getMagic().castSpell(Spell);
                        log("Casting Reanimate...");
                        mouse.click(x, y, rightclick);
                        Sleep.sleepUntil(() -> tabs.isOpen(Tab.INVENTORY)|| Combat, 1250);
                        getInventory().interact("Reanimate", "Ensouled giant head");
                        sleep(1000);
                        log("Success...");
                        Current = Current + 1;
                        sleep(1000);
                    }
                }
            if (Combat) {
                log("Currently killing number " + Current + ".");
                Sleep.sleepUntil(() -> !Combat, 1200);
                }
        return 0;
        }
    }

 

Edited by freedom1

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.