diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index 3bf027952b..f33514e899 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -1337,11 +1337,21 @@ public interface Client extends GameEngine * * 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 * @see ScriptID */ 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. * diff --git a/runelite-api/src/main/java/net/runelite/api/ScriptEvent.java b/runelite-api/src/main/java/net/runelite/api/ScriptEvent.java index e97061f1f9..2436c9ac3b 100644 --- a/runelite-api/src/main/java/net/runelite/api/ScriptEvent.java +++ b/runelite-api/src/main/java/net/runelite/api/ScriptEvent.java @@ -40,13 +40,19 @@ public interface ScriptEvent String NAME = "event_opbase"; /** - * Gets the widget of the event. - * - * @return the widget - * @see net.runelite.api.widgets.Widget + * Gets the widget the {@link #WIDGET_ID} and {@link #WIDGET_INDEX} args + * are substituted with */ 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 * @@ -80,4 +86,11 @@ public interface ScriptEvent * @return */ 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(); }