Package rsb.script

Class Script

All Implemented Interfaces:
Runnable, EventListener
Direct Known Subclasses:
Test

public abstract class Script extends Methods implements EventListener, Runnable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    deactivate(int id)
    For internal use only.
    final void
    Initializes the provided script with this script's method context and adds the delegate as a listener to the event manager, allowing it to receive client events.
     
    final void
    Initializes this script with a given context.
    final void
    init(Script script)
    Initializes this script with another script's context.
    final boolean
    Returns whether the loop of this script is able to receive control (i.e.
    final boolean
    Returns whether this script is paused.
    final boolean
    Returns whether this script has started and not stopped.
    abstract int
    The main loop.
    void
    Called when a break is initiated, before the logout.
    boolean
    Called when a break is initiated, before the logout.
    void
    Override to perform any clean up on script stopScript.
    boolean
    Called before loop() is first called, after this script has been initialized with all method providers.
    final boolean
    Deprecated.
    Use onStart() instead.
    final void
    run()
     
    final void
    setID(int id)
    For internal use only.
    final void
    setPaused(boolean paused)
    Pauses/resumes this script.
    void
    Stops the current script without logging out.
    void
    stopScript(boolean logout)
    Stops the current script; player can be logged out before the script is stopped.

    Methods inherited from class rsb.methods.Methods

    getMyPlayer, log, log, random, random, sleep, sleep, verify, verify, verify, verify

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Script

      public Script()
  • Method Details

    • onStart

      @Deprecated public final boolean onStart(Map<String,String> map)
      Deprecated.
      Use onStart() instead.
      Finalized to cause errors intentionally to avoid confusion (yea I know how to deal with these script writers ;)).
      Parameters:
      map - The arguments passed in from the description.
      Returns:
      true if the script can start.
    • onStart

      public boolean onStart()
      Called before loop() is first called, after this script has been initialized with all method providers. Override to perform any initialization or prevent script start.
      Returns:
      true if the script can start.
    • onBreakStart

      public boolean onBreakStart()
      Called when a break is initiated, before the logout. Override it to implement in your script.
      Returns:
      true if a break can be initiated.
    • onBreakFinish

      public void onBreakFinish()
      Called when a break is initiated, before the logout. Override it to implement in your script.
    • loop

      public abstract int loop()
      The main loop. Called if you return true from onStart, then continuously until a negative integer is returned or the script stopped externally. When this script is paused this method will not be called until the script is resumed. Avoid causing execution to pause using sleep() within this method in favor of returning the number of milliseconds to sleep. This ensures that pausing and anti-randoms perform normally.
      Returns:
      The number of milliseconds that the manager should sleep before calling it again. Returning a negative number will deactivate the script.
    • onFinish

      public void onFinish()
      Override to perform any clean up on script stopScript.
    • init

      public final void init(Script script)
      Initializes this script with another script's context.
      Parameters:
      script - The context providing Script.
      See Also:
    • init

      public final void init(MethodContext ctx)
      Initializes this script with a given context.
      Overrides:
      init in class Methods
      Parameters:
      ctx - The MethodContext.
    • delegateTo

      public final void delegateTo(Script script)
      Initializes the provided script with this script's method context and adds the delegate as a listener to the event manager, allowing it to receive client events. The script will be stored as a delegate of this script and removed from the event manager when this script is stopped. The onStart(), loop() and onFinish() methods are not automatically called on the delegate.
      Parameters:
      script - The script to delegate to.
    • deactivate

      public final void deactivate(int id)
      For internal use only. Deactivates this script if the appropriate id is provided.
      Parameters:
      id - The id from ScriptHandler.
    • setID

      public final void setID(int id)
      For internal use only. Sets the pool id of this script.
      Parameters:
      id - The id from ScriptHandler.
    • setPaused

      public final void setPaused(boolean paused)
      Pauses/resumes this script.
      Parameters:
      paused - true to pause; false to resume.
    • isPaused

      public final boolean isPaused()
      Returns whether this script is paused.
      Returns:
      true if paused; otherwise false.
    • isRunning

      public final boolean isRunning()
      Returns whether this script has started and not stopped.
      Returns:
      true if running; otherwise false.
    • isActive

      public final boolean isActive()
      Returns whether the loop of this script is able to receive control (i.e. not paused, stopped or in random).
      Returns:
      true if active; otherwise false.
    • stopScript

      public void stopScript()
      Stops the current script without logging out.
    • stopScript

      public void stopScript(boolean logout)
      Stops the current script; player can be logged out before the script is stopped.
      Parameters:
      logout - true if the player should be logged out before the script is stopped.
    • run

      public final void run()
      Specified by:
      run in interface Runnable
    • getBot

      public RuneLite getBot()