Jump to content

Varbits VarPlayers and Configs


Teamwork

Recommended Posts

I've been wanting to create a questing script recently so I spent some time looking at the Configs class from the api to understand how I can  get access to quest state and such. This led me down a rabbit hole of Varbits and Varplayers and I can't seem to understand how we can access a Varbit from the API. 

If I use configs.get(29) then this should return an int with the state of the quest cook's assistant because 29 is the Varplayer for cook's assistant's current state. But some quests use a Varbit instead of Varplayer, for example if I look at runelite's github or the wiki they both list Varbit 217 as the state of the quest Ghosts Ahoy. So does that mean that using configs.get(217) should return the state of Ghosts Ahoy or it just won't work because the get method only works for Varplayer IDs?(I haven't tested this) If none of the Varplayer and Varbit had the same ID I wouldn't be confused but it turns out Varbit 29 stores the type of rune in the rune pouch and some other IDs overlap as well. 

 

So I guess my question is, how do i access Varbit?

Also I didn't post link to the github or the wiki because I wasn't sure if it was against forum rules. But i can add them if it helps. 

 

Thanks for the help 

 

Edited by Teamwork
Link to comment
Share on other sites

  • Developer

Varbits are just a bitmask over the config in the end, so if you get hold of the config, most- and least significant bit, you can get the varbit value via something like this

EQUIPPED_WEAPON_TYPE(843, 5, 0);

private final int configId;
private final int msb;
private final int lsb;

Varbits(int configId, int msb, int lsb) {
    this.configId = configId;
    this.msb = msb;
    this.lsb = lsb;
}

public int getValue(Configs configs) {
    int mask = (1 << ((msb - lsb) + 1)) - 1;
    return (configs.get(configId) >> lsb) & mask;
}

 

  • Like 3
Link to comment
Share on other sites

15 hours ago, Patrick said:

Varbits are just a bitmask over the config in the end, so if you get hold of the config, most- and least significant bit, you can get the varbit value via something like this

EQUIPPED_WEAPON_TYPE(843, 5, 0)
private final int configId;
private final int msb;
private final int lsb;
Varbitsint , int , int thisconfigId ;
    thismsb ;
    thislsb ;
public int getValueint 1 msb lsb11;
    return configIdlsb;

 

imagine not using the keyword "this" in #getValue.

Demoted to S1

Link to comment
Share on other sites

16 hours ago, Patrick said:

Varbits are just a bitmask over the config in the end, so if you get hold of the config, most- and least significant bit, you can get the varbit value via something like this

 

Wow that's very good stuff thanks for the info, it took me quite a while to understand it all but it makes a whole lot of sense. I didn't know that the Config instance we retrieved with method provider contained both Varplayer and Varbits.

I was looking at this post 

 and the last answer talked about how he got his info from the cache so I'll try to get the lsb, msb and config id from there. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...