Aller au contenu

Photo

Listener event data?


  • Veuillez vous connecter pour répondre
5 réponses à ce sujet

#1
Magic

Magic
  • Members
  • 187 messages
Hey, does anyone know how to get information from the listener event? I used
RegisterEventListener(OBJECT_SELF,OBJECT_SELF,EVENT_TYPE_COMMAND_COMPLETE);
to listen to the command complete event, which works, but all the listener event fields are empty for me. That makes it difficult to react to the right commands only.

I intended to use the listener to avoid modifying any core scripts. Fortunately, there were other solutions for my task. I'm still curious though.

#2
anakin5

anakin5
  • Members
  • 258 messages
assume you listen EVENT_TYPE_COMMAND_COMPLETE, is this what you tried ?



void main()
{
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);

    switch(nEventType)
    {
        case EVENT_TYPE_LISTENER:
        {
            int nLastCommandType = GetEventInteger(ev, 0);
            int nCommandStatus   = GetEventInteger(ev, 1);
            int nLastSubCommand  = GetEventInteger(ev, 2);
            object oLastTarget   = OBJECT_INVALID;
            object oBlockingObject = GetEventObject(ev, 2);

            ...
        }
    }
}



#3
Magic

Magic
  • Members
  • 187 messages
Oops sorry, I missed your answer somehow.



Yes, that's basically what I did. The commands after case EVENT_TYPE_LISTENER will be executed but as said, all the event data fields are empty (0 or "" or OBJECT_INVALID etc.) when retrieved by the GetEvent*() functions. So I wondered if you or anyone had success using it.

#4
anakin5

anakin5
  • Members
  • 258 messages
I tried it for 5 minutes and stopped when I saw it was not working :)

#5
Magic

Magic
  • Members
  • 187 messages
Hehe ok thanks. Hm I needed some more minutes but I'm just that naïve when I assume something should work. ^^

#6
anakin5

anakin5
  • Members
  • 258 messages
Does anyone have a final answer about EVENT_TYPE_LISTENER ?

The process of RegisterEventListener works fine but the event is "empty", contains no data about the listened event.
In the toolset description of RegisterEventListener we can read :

Registers an object to listen to the specified event type on the target object. When an object is registered as a listener for an event type, whenever the target object receives an event of that type a listener event will be fired to the listening object with the event data that the listening object can then process.


but no event data.
I tried to read value for -100 to 100 with GetEventInteger, Float, String, Object, Resource and got nothing.
Without these informations, there is nothing to do with EVENT_TYPE_LISTENER. It is a shame because I could improve mods compatibility a lot.

Modifié par anakin5, 03 février 2010 - 04:13 .