Aller au contenu

Photo

[Solved]Yet Another DoAreaTransition problem


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

#1
Moonships

Moonships
  • Members
  • 24 messages
Ok so simple problem, at least I'm sure it is anyway.

I'm trying to do an area transition through an interactible object, such as a statue.  I'm assuming all I have to do is specifiy a script in the placable property and put the following code into said script:

void main()
{
   DoAreaTransition("area1", "wp_area1-1");
}

However, it does not work.
The tags are correct, I have verified this several times.  I've exported everything.   I've tried running the script manually and all that happens is the user interface disappears for a second, then comes back.  Same happens if I actually click the statue.

Any ideas on wtf could be wrong? lol

Modifié par Moonships, 15 juillet 2010 - 04:37 .


#2
_L_o_B_o_

_L_o_B_o_
  • Members
  • 117 messages
First of all, your script should look like this. If you just put that line without managing the events, any event signaled to the placeable would execute your code. For example, when the area is loaded and the EVENT_TYPE_SPAWN is sent to this object.

So, since you just want to do the area transition when the placeable is clicked, you just have to treat the EVENT_TYPE_USE event.

#include "placeable_h"

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

    int bEventHandled = FALSE;

    switch (nEvent)    
    {
        case EVENT_TYPE_USE:            
            bEventHandled = TRUE;
            // Your code here.
            break;
    }

    if (!bEventHandled)    
    {        
        HandleEvent(ev, RESOURCE_SCRIPT_PLACEABLE_CORE);    
    }
}


In second place, I don't really know why that DoAreaTransition() function is not working correctly. Do the source and destination area have the same tag? Have you changed something in the area core script of the involved areas? I can only suggest to try the same with different source/destination areas =].

Modifié par _L_o_B_o_, 13 juillet 2010 - 05:50 .


#3
Moonships

Moonships
  • Members
  • 24 messages
Ok I'm a bit confused, does that script you posted have to be a separate script from what I originally did?



Everything is right as far as I can tell. The transitions work with a standard area transition. I also just redirected the transition to WP in the actual area and it still wont work. But it does work if I use a standard door type invisible area transition.

#4
Proleric

Proleric
  • Members
  • 2 355 messages
Your placeable script needs to have the overall structure proposed by _L_o_B_o_, so that the default script handles all events except the one you're trying to manage.

Put your custom code where it says "your code here".

If you look at the default script (placeable_core / placeable_h), you'll see that the EVENT_TYPE_USE script for a standard door is

Placeable_DoAreaTransition(OBJECT_SELF);

so you might try that in your custom code.

Modifié par Proleric1, 14 juillet 2010 - 10:58 .


#5
FergusM

FergusM
  • Members
  • 460 messages
To elaborate, much of the game works around Objects and Events. Objects are things like placeables, creatures, areas, the module, etc. The game (and your scripts) generate events, which get sent to the appropriate object. Each object's script looks at the events it is getting and decides what to do.

Part of the problem with your original code is that it doesn't check what event is going on. By doing as the others suggested, you make sure that your code is only run when an event (specifically, the user clicking on the placeable) happens. There are all kinds of events firing in the background all the time, so its crucial to do this kind of check.

There may be other issues in particular, such as what Proleric has mentioned about a different method.

Modifié par FergusM, 14 juillet 2010 - 10:01 .


#6
Moonships

Moonships
  • Members
  • 24 messages
Alright I got it working. Once I looked at the core script I understood what was going on. I used Prolenic1's method and now it works :)



Thank you all once again =)