Aller au contenu

Photo

Need help adding a function to a script.


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

#1
JackFuzz

JackFuzz
  • Members
  • 408 messages
Where am I going wrong?  I know I've made some kind of syntax error.   

I'm calling a function from two places.   I just need to know what i'm doing wrong exactly. I'm crossing over to C++ from VB.NET

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

    //watch for events
    switch ( nEventType )
    {
        // This event happenes every time the module load. Loading save or new game.
        case EVENT_TYPE_MODULE_LOAD:
        {
            HandleAction_GiveCompanionItems();
            break;
        }                                                                                                                    
        case EVENT_TYPE_CHAR_RECORD_OPENED:
        {
            HandleAction_GiveCompanionItems();
            break;
        }
        default:
        break;
    }
   
void HandleAction_GiveCompanionItems()
    {
   
    }   
   
}

   

#2
Lady Olivia

Lady Olivia
  • Members
  • 374 messages
So, does it compile without errors? If not, what's the error message?



At first glance it looks ok. The only thing that comes to mind is that maybe you should move your function definition up (before main()), so it's defined before the event handlers call it.

#3
JackFuzz

JackFuzz
  • Members
  • 408 messages

Lady Olivia wrote...

So, does it compile without errors? If not, what's the error message?

At first glance it looks ok. The only thing that comes to mind is that maybe you should move your function definition up (before main()), so it's defined before the event handlers call it.


*smacks forehead*... really?   

.... Man I can't believe that worked....  Thanks ;)

Uggh that is so ugly now.  I have to always scroll down to see my starting point.. Oh wel.

Modifié par JackFuzz, 16 janvier 2010 - 04:03 .


#4
Lady Olivia

Lady Olivia
  • Members
  • 374 messages
It doesn't have to be ugly. Look for examples in, say, utility.h. You can declare the functions in the beginning of the script, and then define them wherever you like.

#5
JackFuzz

JackFuzz
  • Members
  • 408 messages
oh wait it's not working when I add code.

#include "utility_h"
#include "wrappers_h"
#include "events_h"

#include "plt_my_plot"
#include "plt_gen00pt_party"

   
void HandleAction_GiveCompanionItems()
    {

        //=========================================
        //Give PC, Leliana, Morrigans Undergarments
        //=========================================

        //if we haven't given player brapanty
        if (WR_GetPlotFlag(PLT_MY_PLOT, GIVE_PLAYER_SWORD) == FALSE)

.....

I get an error on that line... Not sure why? As soon as I put the void Handle over the void Main it caused a problem..

Modifié par JackFuzz, 16 janvier 2010 - 07:06 .


#6
Lady Olivia

Lady Olivia
  • Members
  • 374 messages
What's the error?