Quote:
Originally Posted by cbkbud
Agreed, also if the "on" was removed, then it would break a ton of scripts.
|
Quote:
Originally Posted by Stefan
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.
|
Quote:
Originally Posted by Stefan
The only problem with catchevent() is that you cannot catch events for objects which don't have a name.
|
In my throwevent() example the first parameter was the object name which could be this.name or anything else. If such a thing is abusable it could be made so if you use throwevent() then the object name has to be the name of the object calling it or a string thats not an object name already.
Quote:
Originally Posted by Stefan
The function for invoking/throwing events is trigger(), but it is currently restricted to avoid security problems
|
You should make the object and function that triggered/scheduled the event the first entry in the new callstack, just so you know what started the thread. Then the RC could just check to make sure itself or Graal started the thread and not another script.
Would that suffice?
Quote:
Originally Posted by Stefan
cannot catch events for objects which don't have a name.
|
Make it so catchevent can take either a string object name or an object variable. Then you can do your internal stuff to keep track of the object by its pointer instead of by its name.
Quote:
Originally Posted by Robin
wouldn't you rather have:
PHP Code:
function onCreated() { someGui.addEventListener(GuiEvent.CLOSE, function() { event = new createEvent("nsDOMMyEvent"); event.initEvent("nsDOMMyEvent"); thiso.dispatchEvent(event); }); this.addEventListener("nsDOMMyEvent", function() { player.chat = ":P"; }); }
I would.
|
That looks ugly and confusing because you're defining functions on the fly. Lets try to keep things consistent here in GScript?
PHP Code:
//ScriptA
function onCreated() {
this.catchevent(someGui, "CloseQuery", "SomeGuiCloseQuery");
}
function onSomeGuiCloseQuery() {
// fancy fade-out effect
this.throwevent(this.name, "DidGuiClose", params...);
// throwevent() only does something if the event its throwing
// is being caught. Does not trigger()
}
//ScriptB
function onCreated() {
this.catchevent(ScriptA, "DidGuiClose", "ScriptADidGuiClose");
// should use same name if you don't give a new one
}
function onScriptADidGuiClose(params...) {
//stuff
}
Now that is much more like how its done already.