Package rsb.script
Class Script
java.lang.Object
rsb.methods.Methods
rsb.script.Script
- All Implemented Interfaces:
Runnable,EventListener
- Direct Known Subclasses:
Test
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voiddeactivate(int id) For internal use only.final voiddelegateTo(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.getBot()final voidinit(MethodContext ctx) Initializes this script with a given context.final voidInitializes this script with another script's context.final booleanisActive()Returns whether the loop of this script is able to receive control (i.e.final booleanisPaused()Returns whether this script is paused.final booleanReturns whether this script has started and not stopped.abstract intloop()The main loop.voidCalled when a break is initiated, before the logout.booleanCalled when a break is initiated, before the logout.voidonFinish()Override to perform any clean up on script stopScript.booleanonStart()Called before loop() is first called, after this script has been initialized with all method providers.final booleanDeprecated.final voidrun()final voidsetID(int id) For internal use only.final voidsetPaused(boolean paused) Pauses/resumes this script.voidStops the current script without logging out.voidstopScript(boolean logout) Stops the current script; player can be logged out before the script is stopped.
-
Field Details
-
ctx
-
-
Constructor Details
-
Script
public Script()
-
-
Method Details
-
onStart
Deprecated.UseonStart()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:
trueif 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:
trueif 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:
trueif 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
Initializes this script with another script's context.- Parameters:
script- The context providing Script.- See Also:
-
init
Initializes this script with a given context. -
delegateTo
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-trueto pause;falseto resume.
-
isPaused
public final boolean isPaused()Returns whether this script is paused.- Returns:
trueif paused; otherwisefalse.
-
isRunning
public final boolean isRunning()Returns whether this script has started and not stopped.- Returns:
trueif running; otherwisefalse.
-
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:
trueif active; otherwisefalse.
-
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-trueif the player should be logged out before the script is stopped.
-
run
public final void run() -
getBot
-
onStart()instead.