OSRS Plugin API
    Preparing search index...

    Namespace Events

    This section is for all of the functions, types, and variables related to in-game events. These commands will let you call your own functions whenever a specific in-game event occurs.

    So first lets go over what an in-game event is: An in-game event is an action that occurs while playing on the Old School RuneScape client. When someone playing OSRS clicks on the games window with their mouse, that's a pointer press event (which is expressed as POINTER_PRESS in your Lua script).
    When a new NPC starts loading into the game world, we would call that a NPC load event (expressed as ON_NPC_LOAD). What if a player decided to press a key on their keyboard? That could be three different events. The down press of the key, the release of the key, or the key identity itself, (expressed as KEY_DOWN, KEY_UP, or KEY_TYPE) depending on what you need for your script. There are many different types of events that can all be utilized when creating your own plugin scripts, and all of them are listed under variables. Each of these has explanations about what they do and how they’re used.

    Next we can talk about event callbacks. Each event has a corresponding callback, which can be found under types. These callbacks show you exactly what information you are given for each event, along with code examples on how to use them. Using our example above, where our player pressed a key on their keyboard, let’s decide we used that as a KEY_DOWN event.
    Our KEY_DOWN event becomes attached to the KeyDownCallback, so that when the event happens (when the key is pressed by the player), this callback returns the keycode (a number id) of the key that was pressed. When you use events these callbacks happen automatically, and you can use them to apply the extra information they give you.

    Now that we have a good understanding on what events and event callbacks are, let's talk about how you can use them. Lets say I want my plugin to print “Screen Clicked” every time a player clicks on the game window. Because a mouse click is pressing the mouse key for the pointer, we know that we should use the POINTER_PRESS event, so we have to decide what we will call this event in our plugin. By giving this our own function name, we can instruct the plugin when to connect it to the game event, in this case clicking on the game screen, and when it should stop being connected. This is where the functions subscribe and unsubscribe come into play. The function subscribe allows you to connect your own function to any in-game event, and unsubscribe allows you to disconnect them. While a function is subscribed to an in-game event, every time that event occurs that function will run. So by using subscribe you can connect a function that prints “Screen Clicked” every time a POINTER_PRESS event occurs until you unsubscribe the function from the event.

    When you use events, callbacks, subscribe, and unsubscribe you will be able to connect your plugin to actions that are currently occurring in OSRS, opening up a world of possibilities.

    Enumerations

    GameStateTrigger
    KEY_DOWN
    KEY_TYPE
    KEY_UP
    ON_CHAT_TRANSMIT
    ON_CLAN_CHANNEL_TRANSMIT
    ON_CLAN_RECORD_TRANSMIT
    ON_CLIENTSCRIPT
    ON_COMPONENT_OP
    ON_DIALOG_ABORT
    ON_FRIEND_CHANNEL_TRANSMIT
    ON_FRIEND_TRANSMIT
    ON_GAME_STATE_CHANGED
    ON_GAME_TICK
    ON_IF_CLICK
    ON_IF_CLICK_REPEAT
    ON_IF_COMPONENT_CHANGED
    ON_IF_DRAG
    ON_IF_DRAG_COMPLETE
    ON_IF_HOLD
    ON_IF_LOAD
    ON_IF_MISC_TRANSMIT
    ON_IF_MOUSELEAVE
    ON_IF_MOUSEOVER
    ON_IF_MOUSEREPEAT
    ON_IF_OP
    ON_IF_OPT
    ON_IF_TIMER
    ON_INV_TRANSMIT
    ON_LOC_OP
    ON_MAP_REBUILD_POST
    ON_MAP_REBUILD_PRE
    ON_MINIMENU_CLICK
    ON_MINIMENU_REBUILD
    ON_NPC_LOAD
    ON_NPC_OP
    ON_NPC_UNLOAD
    ON_OBJ_OP
    ON_PLAYER_OP
    ON_RUN_ENERGY_TRANSMIT
    ON_RUN_WEIGHT_TRANSMIT
    ON_SCREEN_RESIZE
    ON_STAT_TRANSMIT
    ON_STOCK_TRANSMIT
    ON_SUB_CHANGE
    ON_TARGET_ENTER
    ON_TARGET_LEAVE
    ON_TILE_OP
    ON_VAR_TRANSMIT
    ON_VARBIT_UPDATE
    POINTER_DRAG
    POINTER_MOVE
    POINTER_PRESS
    POINTER_RELEASE
    WHEEL_SCROLL

    Type Aliases

    EventCallbackPolytype
    KeyDownCallback
    KeyTypeCallback
    KeyUpCallback
    OnChatTransmitCallback
    OnClanChannelTransmitCallback
    OnClanRecordTransmitCallback
    OnClientscriptCallback
    OnComponentChangedCallback
    OnComponentOpCallback
    OnDialogAbortCallback
    OnFriendChannelTransmitCallback
    OnFriendTransmitCallback
    OnGameStateChangeCallback
    OnGameTickCallback
    OnHookCallback
    OnIfLoadCallback
    OnInvTransmitCallback
    OnLocOpCallback
    OnMapRebuildPostCallback
    OnMapRebuildPreCallback
    OnMinimenuClickCallback
    OnMinimenuRebuildCallback
    OnNpcLoadUnloadCallback
    OnNpcOpCallback
    OnObjOpCallback
    OnPlayerOpCallback
    OnRunEnergyTransmitCallback
    OnRunWeightTransmitCallback
    OnScreenResizeCallback
    OnStatTransmitCallback
    OnStockTransmitCallback
    OnSubChangeCallback
    OnTargetEnterCallback
    OnTargetLeaveCallback
    OnTileOpCallback
    OnVarbitUpdateCallback
    OnVarTransmitCallback
    PointerDragCallback
    PointerMoveCallback
    PointerPressCallback
    PointerReleaseCallback
    WheelScrollCallback

    Functions

    subscribe
    unsubscribe