runelite-api: allow running scripts with a widget source

This commit is contained in:
Max Weber
2020-12-06 19:20:05 -07:00
parent 6056b92faf
commit 54f953dc42
2 changed files with 27 additions and 4 deletions

View File

@@ -1337,11 +1337,21 @@ public interface Client extends GameEngine
* *
* This method must be ran on the client thread and is not reentrant * This method must be ran on the client thread and is not reentrant
* *
* This method is shorthand for {@code client.createScriptEvent(args).run()}
*
* @param args the script id, then any additional arguments to execute the script with * @param args the script id, then any additional arguments to execute the script with
* @see ScriptID * @see ScriptID
*/ */
void runScript(Object... args); void runScript(Object... args);
/**
* Creates a blank ScriptEvent for executing a ClientScript2 script
*
* @param args the script id, then any additional arguments to execute the script with
* @see ScriptID
*/
ScriptEvent createScriptEvent(Object ...args);
/** /**
* Checks whether or not there is any active hint arrow. * Checks whether or not there is any active hint arrow.
* *

View File

@@ -40,13 +40,19 @@ public interface ScriptEvent
String NAME = "event_opbase"; String NAME = "event_opbase";
/** /**
* Gets the widget of the event. * Gets the widget the {@link #WIDGET_ID} and {@link #WIDGET_INDEX} args
* * are substituted with
* @return the widget
* @see net.runelite.api.widgets.Widget
*/ */
Widget getSource(); Widget getSource();
/**
* Sets the widget the {@link #WIDGET_ID} and {@link #WIDGET_INDEX} args
* are substituted with. This is useful for running widget listeners
*
* @see Widget#getOnLoadListener()
*/
ScriptEvent setSource(Widget widget);
/** /**
* Gets the menu index of the event * Gets the menu index of the event
* *
@@ -80,4 +86,11 @@ public interface ScriptEvent
* @return * @return
*/ */
int getTypedKeyChar(); int getTypedKeyChar();
/**
* Executes a cs2 script specified by this event
*
* This method must be ran on the client thread and is not reentrant
*/
void run();
} }