Class Vars

java.lang.Object
privbot.hooks.Vars

public final class Vars extends Object
Player variables: ctx.vars.

getVarbit(int)/getVarp(int) answer 0 for a read they cannot make, which is also the value of most variables. Decisions that must not act on an unread value use observedVarbit(int)/observedVarp(int), or byName(java.lang.String) for this server's evidence-backed names. Ids are the server's own (Elorin varbits are not RuneLite constants).

  • Constructor Details

    • Vars

      public Vars(net.runelite.api.Client client)
      Parameters:
      client - the client
  • Method Details

    • getVarbit

      public int getVarbit(int id)
      Parameters:
      id - the varbit id in this server's numbering
      Returns:
      the value, or 0 when it cannot be read (see observedVarbit(int))
    • getVarp

      public int getVarp(int id)
      Parameters:
      id - the varp id
      Returns:
      the value, or 0 when it cannot be read (see observedVarp(int))
    • observedVarp

      public Observed<Integer> observedVarp(int id)
      A varp's value, or UNREADABLE when it cannot be read. getVarp(int) answers 0 for that, which is also the value of most varps.

      On Impact, Elorin and SpawnPK it is UNREADABLE where this client's varps cannot be read, or for an id beyond them; RuneLite-API servers read client.getVarpValue.

      Parameters:
      id - the varp id in this server's numbering
      Returns:
      the value
    • observedVarbit

      public Observed<Integer> observedVarbit(int id)
      A varbit's value, or UNREADABLE when it cannot be read: this client's varbits cannot be read, the id has no definition on this client, or its varp is out of range. getVarbit(int) answers 0 for all of those.

      Ids are the CLIENT's. On Elorin a RuneLite Varbits constant is not translated (OSRS ids are raw + 22000 there), so pass an id from a definition, a catalog or ctx.ids, never a RuneLite constant.

      Parameters:
      id - the varbit id in this server's numbering
      Returns:
      the value
    • byName

      public Observed<Integer> byName(String name)
      The value of a variable by name, from this server's evidence-backed names (VarRegistry). An unknown name is UNREADABLE with a reason naming the server, never 0. The value is raw: it is not scaled or mapped to true/false here.
      
       Observed<Integer> run = ctx.vars.byName("RUN_ENABLED");
       
      Parameters:
      name - the variable's name in any spelling ("RUN_ENABLED", "run enabled")
      Returns:
      the value
    • lookup

      public Observed<VarRegistry.Entry> lookup(String name)
      What a name resolves to on this server, without reading it.
      Parameters:
      name - the variable's name in any spelling
      Returns:
      the entry, or UNREADABLE when the name is unknown here
    • names

      public Set<String> names()
      Returns:
      every name byName(java.lang.String) knows on this server, sorted
    • useRegistry

      public void useRegistry(VarRegistry custom)
      Replaces the name registry (a plugin's own captured names, or tests). Pass null to go back to the server's.
      Parameters:
      custom - the registry to use