Aller au contenu

Photo

Do placeables have onclick events?


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

#1
georage

georage
  • Members
  • 247 messages
I am still making my levels/areas, but wanted to make doors send players to night areas if it is night, day if it is day.

Do doors have an event that I can attatch that sort of script to?

And let us not forget the joy of a random door trap!

Thanks for any tips, I am not sure I have a handle on the new event model yet.

#2
Challseus

Challseus
  • Members
  • 1 032 messages

georage wrote...

I am still making my levels/areas, but wanted to make doors send players to night areas if it is night, day if it is day.

Do doors have an event that I can attatch that sort of script to?

And let us not forget the joy of a random door trap!

Thanks for any tips, I am not sure I have a handle on the new event model yet.


All placeables (i.e. Doors) have an event script slot in the properties section. The default one is  placeable_core.nss. In that script, you will find all the events associated with placables that you will need. While all events are caught in said script, they are for the most part handled by the include file, placeable_h.nss.

Anyway, if you wanted to add your own functionality, you would just need to create your own script for the door in question, and catch the relevant events you need. Just make sure your script calls placeable_core.nss (in certain situations) when it is done processing. Here is an example:

#include "placeable_h"
void main()
{
    event ev     = GetCurrentEvent();
    int   nEvent = GetEventType(ev);
    int nEventHandled = FALSE; //keep track of whether the event has been handled
    switch (nEvent)
    {
        //---------------------------------------------------------------------
        //  Sent by engine when creature clicks on the placeable.
        //---------------------------------------------------------------------
        case EVENT_TYPE_USE:
            //your special code goes here
            nEventHandled = TRUE;
            break;
    }
    if (!nEventHandled) //If this event wasn't handled by this script, let the core script try
    {
        HandleEvent(ev, RESOURCE_SCRIPT_PLACEABLE_CORE);
    }
}

Bear in mind that your special code may or may not be the end of the event. In other words, after your special code is processed, you may still need to run the normal functionality for placeables. In that case, you would not set nEventHandled to TRUE.

Let me know if you need anything else.

Modifié par Challseus, 24 novembre 2009 - 04:36 .


#3
Craig Graff

Craig Graff
  • Members
  • 608 messages
To answer the topic title question, there is an EVENT_TYPE_PLACEABLE_ONCLICK that fires on placeables. It doesn't quite sound like what you are looking for, though.

#4
georage

georage
  • Members
  • 247 messages
Thanks, I will give it a go.