Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   onCall Event (https://forums.graalonline.com/forums/showthread.php?t=81488)

Inverness 08-26-2008 08:33 PM

onCall Event
 
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

Quote:

Originally Posted by Inverness (Post 1418022)
I haven't yet decided what I could use it for

Not practical enough!

Inverness 08-26-2008 08:39 PM

Quote:

Originally Posted by Skyld (Post 1418023)
Not practical enough!

Perhaps you should ask people what they use __call__() in Python for.

Skyld 08-26-2008 08:42 PM

Quote:

Originally Posted by Inverness (Post 1418025)
Perhaps you should ask people what they use __call__() in Python for.

Quote:

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

Quote:

Originally Posted by Skyld (Post 1418026)
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

Quote:

Originally Posted by Inverness (Post 1418030)
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

Quote:

Originally Posted by Skyld (Post 1418032)
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

Quote:

Originally Posted by Stefan (Post 1418096)
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.


All times are GMT +2. The time now is 02:19 AM.

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