PDA

View Full Version : onCall Event


Inverness
08-26-2008, 08:33 PM
I was thinking that an object.onCall() event would allow you to define what happens when you call object() like a function. Obviously this would be a blocking event. I haven't yet decided what I could use it for but I thought it might be nice.

Edit:

And some other things I mentioned before:

A throwevent(objectname, eventname, params...) that throws an event that can be caught with catchevent() like it does with Gui Controls.

onGetVariable() and onSetVariable() events that would allow you to define function behavior for certain variables. Obviously there would need to be some way to specify which variables are included in this.

Skyld
08-26-2008, 08:36 PM
I haven't yet decided what I could use it for
Not practical enough!

Inverness
08-26-2008, 08:39 PM
Not practical enough!Perhaps you should ask people what they use __call__() in Python for.

Skyld
08-26-2008, 08:42 PM
Perhaps you should ask people what they use __call__() in Python for.
Called when the instance is ``called'' as a function; if this method is defined, x(arg1, arg2, ...) is a shorthand for x.__call__(arg1, arg2, ...).
Strikes me that we can probably already achieve something similar with careful use of function prototyping.

Inverness
08-26-2008, 08:46 PM
Strikes me that we can probably already achieve something similar with careful use of function prototyping.Sounds complicated and more difficult than doing x.functionname();

I also thought of something else I wanted to add but reading your post made me forget it. !pissed!

Skyld
08-26-2008, 08:48 PM
I also thought of something else I wanted to add but reading your post made me forget it. !pissed!
Tehe. I do quite like your idea of something along the lines of throwing catchable events, though (or patching trigger() to do it properly - last I checked it didn't).

Inverness
08-26-2008, 09:00 PM
Tehe. I do quite like your idea of something along the lines of throwing catchable events, though (or patching trigger() to do it properly - last I checked it didn't).Yes, patching trigger does sound like the better option. I made a util_catchevent2() but I don't like it too much because I dislike having two functions that do the same thing and its also inherently slower than the built-in function so I'm weary of using it often.

Admins
08-26-2008, 11:23 PM
The events for trigger() and normal GUI/player/catchevents are separate for security reasons. In the next Graal version it's however possible to trigger() events to yourself which act like normal GUI events. That is mainly for scripting new types of GUI controls, e.g. you can trigger("onSelect").

Inverness
08-26-2008, 11:28 PM
The events for trigger() and normal GUI/player/catchevents are separate for security reasons. In the next Graal version it's however possible to trigger() events to yourself which act like normal GUI events. That is mainly for scripting new types of GUI controls, e.g. you can trigger("onSelect").If triggering an event on yourself makes it so an outside object can catch the event then that is exactly what I want.

And I hope this works serverside too?

Admins
08-27-2008, 02:42 PM
Server-side it's already working for a few months.