Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Script events (https://forums.graalonline.com/forums/showthread.php?t=85749)

Skyld 05-26-2009 04:52 PM

Script events
 
You might find the following list of clientside script events useful:
HTML Code:

Global:
  onClassLoaded(str) - a class script has been updated: name of the class
  onConnectingToServer(str, str, int) - connecting to: servername, address, port
  onDefaultStyleChanges(str) - the $pref::Video::defaultguistyle has been changed
  onFileChunkReceived(str, int, int) - file download progress: filename, current position, full size
  onFileDownloaded(str, int) - a game file has been downloded: filename, size
  onFilesUploaded() - finished uploading all files to the file browser
  onFirstResponderChanges(obj) - the control that received the keyboard input changed
  onFolderLog(str) - scripted RC file browser message
  onLevelFileUpdated(str) - a game file has been updated: filename
  onLogMessage(str, float, float, float, str) - log message: text, red, green, blue, log type
  onMapClick(obj) - clicked on a player on the map: player object
  onMouseYawPitch(int, int) - the mouse moved in 3D mode: yaw and pitch
  onMusicDataReceived(str, str) - music meta data received: name and value
  onOfflineModeStarted() - the offline mode is started because there is no connection to the server
  onOpenHelpWindow() - the key for opening the help window (F1) has been pressed
  onOpenLogWindow() - the key for opening the log window (F2) has been pressed
  onOpenOptionsWindow() - the key for opening the options window (F3) has been pressed
  onOpenPlayerList() - the key for opening the player list (F7) has been pressed
  onOpenPlayerPositionWindow() - the key for opening the positon window (F5) has been pressed
  onOpenProfileWindow(obj) - right click on a player or call to showProfile() to open the profile window
  onOpenServerList() - the key for opening the serverlist (F8) has been pressed
  onPackagesDownloadComplete() - all update packages (.gupd files) have been downloaded
  onPackagesDownloaded() - some update packages (.gupd files) have been downloaded
  onPlayerChanges(obj, int) - the look of a player changed: player object and id
  onPlayerLanguageChanges(obj, str) - the language of the player has changed: player object, new language
  onPlayerLogin(obj, int) - a player logged in: player object and id
  onPlayerLogout(obj, int) - a player logged out: player object (might be NULL) and id
  onPM(obj) - received a PM from a player: player object
  onRCChat(str) - scripted RC chat: text
  onRemotePlayerChats(obj, str) - another player is saying something: player object, text
  onServerListerConnect() - a connection to the server-lister (central server) established
  onServerLogin() - logged into a server
  onToall(obj, str) - received a toall message: player object and message
  onTranslationUpdated(str) - a translation file (.po) has been updated
  onUpdatePackageDownloaded(obj) - downloaded an update package (.gupd): package object

  GuiControl (TGraalVar):
    onAction() - an action happened (e.g. button pressed)
    onAdd() - the control has been added as child to another control
    onDialogPop() - the control is no longer the dialog control (popDialog())
    onDialogPush() - the control is now the dialog control (pushDialog())
    onDropFiles(int, int, obj) - files dropped from explorer/finder to the control (acceptdropfiles must be true): x, y, filelist
    onHide() - the control is no longer visible on the screen
    onKeyDown(int, str, int) - a key has been pressed: keycode, keytext, scancode
    onKeyUp(int, str, int) - a key has been released: keycode, keytext, scancode
    onMouseDown(int, int, int, int) - mouse click: key modifiers, mouse x and y, click count
    onMouseDragged(int, int, int, int) - mouse moved while holding the mouse button down: key modifiers, mouse x and y, click count
    onMouseEnter(int, int, int, int) - mouse enters the area of the control: key modifiers, mouse x and y, click count
    onMouseLeave(int, int, int, int) - mouse leaves the are of the control: key modifiers, mouse x and y, click count
    onMouseMove(int, int, int, int) - mouse moved: key modifiers, mouse x and y, click count
    onMouseUp(int, int, int, int) - mouse button released: key modifiers, mouse x and y, click count
    onMouseWheelDown(int, int, int, int) - mouse wheel scrolled down: key modifiers, mouse x and y, click count
    onMouseWheelUp(int, int, int, int) - mouse wheel scrolled up: key modifiers, mouse x and y, click count
    onMove(int, int) - the control has been moved to x, y
    onRemove() - the control has been removed from its parent
    onResize(int, int) - the control has been resized to width, height
    onRightMouseDown(int, int, int, int) - right mouse click: key modifiers, mouse x and y, click count
    onRightMouseDragged(int, int, int, int) - mouse moved while holding the right mouse button down: key modifiers, mouse x and y, click count
    onRightMouseUp(int, int, int, int) - right mouse button released: key modifiers, mouse x and y, click count
    onShow() - the control becomes actually visible on the screen
    onSleep() - the control is not part of the screen anymore
    onStartDrag() - the user is moving the control
    onStopDrag(int, int, int, int) - stopped moving a control: key modifiers, mouse x and y, click count
    onStyleChanges() - the GUI style has changed
    onWake() - the control has been added to the screen

    GuiAnimationCtrl (GuiControl):
      onAnimationEnd(int) - finished moving: new entry index
      onAnimationStart(int, int) - started moving: current entry index, destination entry index

    GuiArrayCtrl (GuiControl):
      onOpenMenu(int, int, int, int) - right click on an entry: column, row, mouse x and y
      onSelect(int, int) - an entry has been selected: column and row

      GuiTextListCtrl (GuiArrayCtrl):
        onDblClick(int, str, int) - double click on a list entry: id, text, row
        onDeleteKey(int, str, int) - delete key pressed for an entry: id, text, row
        onIconResized(int, int) - the size of the icons has been changed: new width and height
        onMouseOverCell(int, str, int) - the mouse is hovering over a list entry: id, text, row
        onOpenMenu(int, str, int) - right-click on a list entry: id, text, row
        onSelect(int, str, int) - a list entry has been selected: id, text, row

      GuiTreeViewCtrl (GuiArrayCtrl):
        onDblClick(obj, str, str) - double-click on a node: node object, slash-path, dot-path
        onExpand(obj, str, str) - a node is expanding: node object, slash-path, dot-path
        onFold(obj, str, str) - a node is folded: node object: slash-path, dot-path
        onIconResized(int, int) - the size of the icons has been changed: new width and height
        onMouseOverCell(obj, str, str) - the mouse is hovering over a node: node object, slash-path, dot-path
        onOpenMenu(obj, str, str) - right click on a node: node object, slash-path, dot-path
        onSelect(obj, str, str) - a node is selected: node object, slash-path, dot-path

    GuiContextMenuCtrl (GuiControl):
      onCancel() - the menu has been closed without selecting an entry
      onSelect(int, str, int) - a menu entry has been selected: id, text and row

      GuiStartMenuCtrl (GuiContextMenuCtrl):
        onCancel() - the menu has been closed without selecting an entry
        onSelect(int, str, int) - a menu entry has been selected: id, text and row
        onTextChanged(str) - the menu text has been changed

    GuiMenuCtrl (GuiControl):
      onCancel() - the menu has been closed without selecting a menu entry
      onIconResized(int, int) - the size of the icons has been changed: new width and height
      onSelect(str, int, str, int) - a menu item has been selected: menu name, selection id, text and row

    GuiMLTextCtrl (GuiControl):
      onCursorLineChanged(int) - cursor moved: new line number
      onReflow(int, int) - the displayed content changed: new visible width and height
      onRightSelectTag(str) - right click on: tag id
      onSelectTag(str) - the user clicked on a tag or bitmap: tag id
      onURL(str) - the user clicked on an url

    GuiSliderCtrl (GuiControl):
      onAction(float) - the slider value has been changed (by script or user): new slider value
      onReleaseSlider(float) - the user has finishzed moving the slider: new slider value

    GuiSpriteCtrl (GuiControl):
      onPlayerDies() - the player died
      onUpdateScore(int, int) - new score: new total score, added points

    GuiTabCtrl (GuiControl):
      onDeselect(int, str, int) - a tab is no longer selected: id, text, row
      onIconResized(int, int) - the size of the icons has been changed: new width and height
      onMouseOverCell(int, str, int) - the mouse is hovering over a tab: id, text, row
      onOpenMenu(int, int, int) - the user has clicked with the right mouse button on an entry: row, mouse x and y
      onSelect(int, str, int) - a tab has been selected: id, text, row

    GuiTextCtrl (GuiControl):
      onTextChanged(str) - text has been changed

      GuiPopUpEditCtrl (GuiTextCtrl):
        onCancel() - the menu has been closed without selecting an entry
        onSelect(int, str, int) - a menu entry has been selected: id, text and row

      GuiPopUpMenuCtrl (GuiTextCtrl):
        onCancel() - the menu has been closed without selecting an entry
        onSelect(int, str, int) - a menu entry has been selected: id, text and row

      GuiTextEditCtrl (GuiTextCtrl):
        onAction(str) - a text has been entered (return key pressed)
        onTabComplete(bool) - the tab key has been pressed (with or without shift key)

      GuiWindowCtrl (GuiTextCtrl):
        onCloseQuery() - the player clicked on the close button and closequery=true
        onTextChanged(str) - the window title has been changed

I don't know whether all of the global events will be available to unprivileged (non-login) scripts like onConnectingToServer() but I guess they are not a lot of use to unprivileged scripts anyway.

Crow 05-26-2009 05:41 PM

I have to spread first >_<
Thanks a bunch!

[email protected] 05-26-2009 05:42 PM

You're great- thank you!
Could you compile a list for all script functions (onCreated, onTimeout) etc.

DustyPorViva 05-26-2009 06:33 PM

That's great, a lot of events I didn't know existed :)

Tigairius 05-26-2009 06:35 PM

This is great, thanks :D

fowlplay4 05-26-2009 07:08 PM

onOfflineModeStarted()

Makes me wonder why we can't work and test GS2 scripts offline.

Inverness 05-26-2009 10:10 PM

+rep

cbk1994 05-26-2009 10:11 PM

Awesome, thanks Skyld.

Quote:

Originally Posted by [email protected] (Post 1494285)
You're great- thank you!
Could you compile a list for all script functions (onCreated, onTimeout) etc.

They're called events.

Skyld 05-27-2009 10:00 PM

Quote:

Originally Posted by [email protected] (Post 1494285)
You're great- thank you!
Could you compile a list for all script functions (onCreated, onTimeout) etc.

I guess there is a sorta-partial list at http://wiki.graal.us/CategoryFunctionEvent but it is not complete; people should help to document what they know more.

Pelikano 05-28-2009 11:36 AM

Quote:

Originally Posted by cbk1994 (Post 1494392)
Awesome, thanks Skyld.



They're called events.

ysosmart?

Crow 05-28-2009 01:12 PM

Quote:

Originally Posted by Pelikano (Post 1494838)
ysosmart?

Because "functions" is not the correct term.

Pelikano 05-28-2009 03:18 PM

still using [i] on the word, is very ***gy

Codein 05-28-2009 04:11 PM

Quote:

Originally Posted by Pelikano (Post 1494882)
still using [i] on the word, is very ***gy

How is emphasising a word, especially a key word, '***gy'?

Pelikano 05-28-2009 04:15 PM

Quote:

Originally Posted by Codein (Post 1494890)
How is emphasising a word, especially a key word, '***gy'?

it was an attack, we all know that

Codein 05-28-2009 04:46 PM

Quote:

Originally Posted by Pelikano (Post 1494893)
it was an attack, we all know that

Or, rather, a pretty legitimate correction? This is from a standing point where I've known no previous bitterness between Chris and Andy. I've certainly seen none shown on the forums. Maybe you could correct me on that? :P

Pelikano 05-28-2009 05:03 PM

Quote:

Originally Posted by Codein (Post 1494898)
Or, rather, a pretty legitimate correction? This is from a standing point where I've known no previous bitterness between Chris and Andy. I've certainly seen none shown on the forums. Maybe you could correct me on that? :P

There's a first time for everything :].
And yes I have on the GST Team application of Andy or something

Codein 05-28-2009 05:50 PM

Quote:

Originally Posted by Pelikano (Post 1494909)
There's a first time for everything :].
And yes I have on the GST Team application of Andy or something

Ah, I see, but no cigar. That comment wasn't an attack either, nor did it display any kind of bitterness :P

Pelikano 06-13-2009 10:50 AM

However, can someone really do compile a list of all Events?
That'd be so cool :o

xXziroXx 01-30-2010 05:18 PM

Is there an event for when the player updates his settings (or at least closes the F3 menu)?

Admins 02-03-2010 03:58 PM

In the new v6 version you can now do "-listscriptfunctions" which generates scriptfunctions_client.txt and also contains (some) events.

The options are now done by script, there is no event for updating the options but we could add something in the script.

Crow 02-03-2010 08:37 PM

Quote:

Originally Posted by Stefan (Post 1553947)
The options are now done by script, there is no event for updating the options but we could add something in the script.

Yes, add it, please.

fowlplay4 02-03-2010 09:03 PM

This will/should work in v6:

PHP Code:

function F3WindowsName.onHide() {
  
// Options possibly updated.


Not sure of the real window name, but the above should suffice.

DustyPorViva 02-03-2010 10:16 PM

Quote:

Originally Posted by fowlplay4 (Post 1553981)
This will/should work in v6:

PHP Code:

function F3WindowsName.onHide() {
  
// Options possibly updated.


Not sure of the real window name, but the above should suffice.

Wouldn't you just detect when the 'Apply' button was clicked instead?

fowlplay4 02-03-2010 10:29 PM

Quote:

Originally Posted by DustyPorViva (Post 1553997)
Wouldn't you just detect when the 'Apply' button was clicked instead?

You can change things, and click the X on the window and those changes still save. I imagine the OK button just closes it as well.

But really why just check the window, when you can check an exact feature. If your script only cares about light effects:

PHP Code:

// Another case where I don't know the name :P
LightEffectsEnabledCheckBox.onAction() { 
  
// Do stuff.



xAndrewx 06-09-2010 08:23 AM

Isn't there an event which is triggered once the player leaves the level? Any idea's anyone

DustyPorViva 06-09-2010 08:30 AM

Quote:

Originally Posted by xAndrewx (Post 1580983)
Isn't there an event which is triggered once the player leaves the level? Any idea's anyone

onPlayerLeaves() I think, and it's serverside only.

xAndrewx 06-09-2010 08:46 AM

Great job- thanks! :D

xAndrewx 07-16-2010 09:33 PM

Requested ones

HTML Code:

onHPChanges
onMPChanges
onAPChanges


Skyld 07-16-2010 10:14 PM

Quote:

Originally Posted by xAndrewx (Post 1587950)
Requested ones

HTML Code:

onHPChanges
onMPChanges
onAPChanges


onPlayerChanges should do what you want I think, but it will also capture changing heads and stuff.

xAndrewx 07-16-2010 11:03 PM

doesn't detect any of them =o (only detects nicknames... from what I've tested) but thanks!!

xXziroXx 01-11-2011 10:14 PM

Don't suppose there's a serverside event for when the serveroptions are updated by someone on RC?

salesman 01-11-2011 10:25 PM

Quote:

Originally Posted by xXziroXx (Post 1621987)
Don't suppose there's a serverside event for when the serveroptions are updated by someone on RC?

pretty sure it's onServerOptionsUpdated()

xXziroXx 01-11-2011 11:20 PM

Quote:

Originally Posted by salesman (Post 1621990)
pretty sure it's onServerOptionsUpdated()

Does not work.

cbk1994 01-11-2011 11:43 PM

Quote:

Originally Posted by salesman (Post 1621990)
pretty sure it's onServerOptionsUpdated()

I requested that a while back. There isn't one.

salesman 01-11-2011 11:46 PM

Quote:

Originally Posted by cbk1994 (Post 1622004)
I requested that a while back. There isn't one.

That must be what I was thinking of, but for some reason I remember having something like this on Era Dev?

cbk1994 01-12-2011 01:38 AM

Quote:

Originally Posted by salesman (Post 1622005)
That must be what I was thinking of, but for some reason I remember having something like this on Era Dev?

I requested it for use on Era Dev :p

MrDunne 07-01-2011 12:01 AM

Is there not an "onNPCUpdated" or "onScriptUpdated"?

fowlplay4 07-01-2011 12:08 AM

Quote:

Originally Posted by MrDunne (Post 1656869)
Is there not an "onNPCUpdated" or "onScriptUpdated"?

Not globally. onCreated will go off in the script you update though.

MrDunne 07-01-2011 12:14 AM

Hrm, that's a shame.


All times are GMT +2. The time now is 06:10 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.