![]() |
addEventListener
Like in javascript, subscribe to events using code.
PHP Code:
|
Use function prototyping:
PHP Code:
PHP Code:
PHP Code:
|
So ECMAScript standards + gs2 = :(
|
Like Skyld said, it can be replicated easily. However, I guess it would be nice to have.
|
It's just that ECMAScript is a standard definition and It would be easier for new scripters to start if they didn't have to comb the wiki for information :P
|
I've been scripting for quite awhile and I don't know what the *bleep* ECMAScript is. I doubt anyone knew to coding would either.
I even dislike the syntax of the example you provided. I think catchevent() works just fine and should be expanded to work with scripted events with a function throwevent() or so. Script A: PHP Code:
PHP Code:
|
I agree with Inverness, catchevent would work fine, just needs to be "fixed".
|
I dislike how catchevent() requires the "on" part to be specified in the event name. Events already start with "on" by default so such a thing should be assumed I believe.
|
Quote:
|
Quote:
this.catchevent("GraalControl", "onResize", "onGraalControlResize"); instead of: this.catchevent("GraalControl", "Resize", "GraalControlResize"); Things like scheduleevent() and trigger() always prefix the event name with "on" to show that its an event so catchevent() should reflect that Graal event function names always start with "on" I believe that should be fixed by Stefan and he should give people a warning ahead of time so they can fix their scripts. |
Quote:
PHP Code:
|
Blah, all events should start with "on" in all cases. Anything handling event names shouldn't need the "on" in all cases.
It sounds to me like you're being lazy. Standards are something that should be practiced in coding. |
Quote:
Are based on. Are you trying to say you've never come across any of these technologies? That anyone knew to coding has not either? Also @ Skyld: function prototyping doesn't seem to work with gui events, but the rest of your examples do. Strange. |
Quote:
|
Quote:
|
Quote:
If you have a function blowup() that blows up the npc then have an event onBlownUp() that is thrown at the end of the function... what is wrong with that? Its a simple concept to have all events prefixed with "on" to separate them from other normal functions because events are responding to something else and you're not normally supposed to be calling them directly. Is that so difficult to understand? |
Quote:
Quote:
|
wouldn't you rather have:
PHP Code:
|
I usually catchevent my gui catchs with something like guiDoStuff(); (a gui header rather then an on header) as I see them as a little different. That's just my opinion though but I don't want to see that functionality removed.
|
It would probably be possible to add a sort of addEventListener by using classes and mapping every event manually x-x
Would be fun though. Plus if Gscript2 were ECMAScript COMPLIANT then I wouldn't have to port this JSON parser from C x-x |
catchevent() is like addEventListener() except that it also allows to catch events of objects which don't exist yet. You also don't need to specify the "on" in the event name, it's actually stripping that from the event name in case you are providing it.
The only problem with catchevent() is that you cannot catch events for objects which don't have a name. It could be possible to add addEventListener() for compatibility and for closing that hole. The function for invoking/throwing events is trigger(), but it is currently restricted to avoid security problems (e.g. a scripter from a server could open the remote control for you and click on some controls and type text and then ban someone, just as example). |
!!! <3<3<3<3<3<3<3<3
Love. (Translation: Yes, that'd be a remarkably good idea, and it would allow for many other things.) |
Quote:
|
Quote:
Quote:
Quote:
Quote:
Would that suffice? Quote:
Quote:
PHP Code:
|
In the latest internal Graal version all trigger()ed events are also sent to the "event listeners" when an object is triggering itself. I can check if it's possible to support the object as parameter for catchevent().
|
PASSING OBJECTS AND FUNCTIONS AND VARIABLES BY REFERENCE WOULD BE GREATLY APPRECIATED PLEASEEEEEE.
</beg> |
Objects and functions already are refs, and you can pass arrays by ref using link().
PHP Code:
|
Something like this would be greatly appriciated for both Clientside and Serverside:
PHP Code:
|
Quote:
The ECMAScript thing isn't a good enough reason to redo how we catch events either. |
Because you currently can't do that with catch event.
Or can you? Are you able to hook the current onTimeout of a script and simultaneously have both an onTimeout and another event called of your choosing without putting anything in the onTimeout? I've tried it, and it doesn't work, at least not serverside. So you can be negative about this, or you can feel positive that you're getting your own way, albeit via a different function, rather than your seemingly beloved catchevent, which I cannot seem to get working on ANY script event OTHER than GUI events! |
He's saying to fix what we have, not add something totally new.
ECMAScript Standards can wait in line. We already have a way to do this, it just needs to be fixed. No need to reinvent the wheel :) |
Quote:
Quote:
Quote:
|
What you don't seem to understand is that addEventListener IS the wheel Stefan reinvented by making catchEvent.
Just a... slightly square... triangular wheel that doesn't work quite right. |
Quote:
There was no catchevent in GS1, he created catchevent in GS2. Therefore, he reinvented no wheel in Graal's scripting. |
Quote:
You don't seem to realize that we've been using catchevent() for years and nobody wants to have to replace all instances of it with some new function just to adhere to some standard that they probably don't care about. |
Quote:
Quote:
catchevent seems to only work for GUI / HTTPRequest objects and that seems like a very small scope. It should be modified to work with any event, custom events included. The beauty of addEventListener is that it's an already defined function in C-like interperated scripts and you wouldn't lose backwards compatibility by adding a new function. |
Quote:
Quote:
You still don't seem to understand that we do not need addeventlistener() because rather than adding a new way to do the same thing Stefan can simply modify catchevent() On a different subject: I don't think you have the ability to be PWA if you can't understand simple things such as consistency. |
Quote:
Quote:
Quote:
If catchevent worked the way you and myself would like it to, I could make this: PHP Code:
Quote:
You say I do not understand consistency, when I am talking about standards. Standards are about keeping things consistent. As I have also said, if you have a problem, feel free to IM me or to email me. You will not be ignored. |
Quote:
Quote:
Quote:
Quote:
Actually, I will start a crusade to make GS2 compliant with my BASICStandards :rolleyes: This way, everyone coming from BASIC would be able to script GS2 :) |
Quote:
Quote:
PHP Code:
Quote:
Plus, as I have already said, I can add my own "addEventListener" if catchevent was fixed, it does not matter to me what the function is named as long as it works Quote:
Quote:
I was starting no crusade sir, I saw the inklings of GS2 becoming something greater than it already is and decided to try and help, and yet was bashed :) |
| All times are GMT +2. The time now is 06:24 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.