Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #16  
Old 05-03-2008, 03:32 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by cbkbud View Post
That's just personal preference. I think it's silly to have something like onBlowUpCar()
Its irritating me to have to explain a simple concept to you.

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?
__________________
Reply With Quote
  #17  
Old 05-03-2008, 03:45 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Inverness View Post
Its irritating me to have to explain a simple concept to you.
It irritates me when people have this perspective. I didn't ask for you to explain it, you chose to.
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?
Okay, I see what you mean.
__________________
Reply With Quote
  #18  
Old 05-03-2008, 03:53 AM
Robin Robin is offline
The secret of NIMH
Robin's Avatar
Join Date: Apr 2005
Location: Wales, UK
Posts: 515
Robin will become famous soon enough
Send a message via AIM to 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.
Reply With Quote
  #19  
Old 05-03-2008, 08:25 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
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.
__________________
Do it with a DON!
Reply With Quote
  #20  
Old 05-03-2008, 01:23 PM
Robin Robin is offline
The secret of NIMH
Robin's Avatar
Join Date: Apr 2005
Location: Wales, UK
Posts: 515
Robin will become famous soon enough
Send a message via AIM to Robin
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
__________________

Reply With Quote
  #21  
Old 05-03-2008, 01:41 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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).
Reply With Quote
  #22  
Old 05-03-2008, 01:43 PM
Robin Robin is offline
The secret of NIMH
Robin's Avatar
Join Date: Apr 2005
Location: Wales, UK
Posts: 515
Robin will become famous soon enough
Send a message via AIM to Robin
!!! <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.)
__________________

Reply With Quote
  #23  
Old 05-03-2008, 02:58 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by zokemon View Post
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.
Agreed, also if the "on" was removed, then it would break a ton of scripts.
__________________
Reply With Quote
  #24  
Old 05-03-2008, 10:29 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by cbkbud View Post
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 View Post
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.
__________________

Last edited by Inverness; 05-03-2008 at 10:53 PM..
Reply With Quote
  #25  
Old 05-03-2008, 11:20 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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().
Reply With Quote
  #26  
Old 05-03-2008, 11:36 PM
Robin Robin is offline
The secret of NIMH
Robin's Avatar
Join Date: Apr 2005
Location: Wales, UK
Posts: 515
Robin will become famous soon enough
Send a message via AIM to Robin
PASSING OBJECTS AND FUNCTIONS AND VARIABLES BY REFERENCE WOULD BE GREATLY APPRECIATED PLEASEEEEEE.
</beg>
__________________

Reply With Quote
  #27  
Old 05-03-2008, 11:58 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Objects and functions already are refs, and you can pass arrays by ref using link().
PHP Code:
function onCreated() {
  
temp.array = {"lol""pancake"};
  
thefunc(temp.array.link());
}
function 
thefunc(array) {
  array[
1] @= "lol";

Though I think its silly that it only works for arrays and not strings or numbers.
__________________
Reply With Quote
  #28  
Old 05-08-2008, 02:10 PM
Robin Robin is offline
The secret of NIMH
Robin's Avatar
Join Date: Apr 2005
Location: Wales, UK
Posts: 515
Robin will become famous soon enough
Send a message via AIM to Robin
Something like this would be greatly appriciated for both Clientside and Serverside:

PHP Code:
function onCreated() {
  
this.addEventListener("Timeout",function() {
    
sendtonc("2");
  });
  
setTimer(1);
}
function 
onTimeout() {
  
sendtonc("1");
}

// Would recieve:
// 1
// 2
// Simultaneously 
__________________

Reply With Quote
  #29  
Old 05-08-2008, 09:01 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Robin View Post
Something like this would be greatly appriciated for both Clientside and Serverside:

PHP Code:
function onCreated() {
  
this.addEventListener("Timeout",function() {
    
sendtonc("2");
  });
  
setTimer(1);
}
function 
onTimeout() {
  
sendtonc("1");
}

// Would recieve:
// 1
// 2
// Simultaneously 
So do you have a good reason why we need to add another way to do catchevent()? Cause it seems like my consistency argument is going right over your head.

The ECMAScript thing isn't a good enough reason to redo how we catch events either.
__________________
Reply With Quote
  #30  
Old 05-08-2008, 09:21 PM
Robin Robin is offline
The secret of NIMH
Robin's Avatar
Join Date: Apr 2005
Location: Wales, UK
Posts: 515
Robin will become famous soon enough
Send a message via AIM to Robin
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!
__________________

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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