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 void
deactivate
(int id) For internal use only.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.getBot()
final void
init
(MethodContext ctx) Initializes this script with a given context.final void
Initializes this script with another script's context.final boolean
isActive()
Returns whether the loop of this script is able to receive control (i.e.final boolean
isPaused()
Returns whether this script is paused.final boolean
Returns whether this script has started and not stopped.abstract int
loop()
The main loop.void
Called when a break is initiated, before the logout.boolean
Called when a break is initiated, before the logout.void
onFinish()
Override to perform any clean up on script stopScript.boolean
onStart()
Called before loop() is first called, after this script has been initialized with all method providers.final boolean
Deprecated.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.
-
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:
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
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
-true
to pause;false
to resume.
-
isPaused
public final boolean isPaused()Returns whether this script is paused.- Returns:
true
if paused; otherwisefalse
.
-
isRunning
public final boolean isRunning()Returns whether this script has started and not stopped.- Returns:
true
if 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:
true
if 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
-true
if the player should be logged out before the script is stopped.
-
run
public final void run() -
getBot
-
onStart()
instead.