Aller au contenu

Photo

Module Load script help


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

#1
indio

indio
  • Members
  • 204 messages
I'm using this auto character generator for testing, which works fine.

I'm trying to initialise Phaenan's crafting system (awesome) in the following way:

#include "sys_chargen_h"
#include "utility_h"

void main()
{
    // keep track of whether the event has been handled
    int nEventHandled = FALSE;

    event ev = GetCurrentEvent();
    switch(GetEventType(ev))
    {
        case EVENT_TYPE_MODULE_START:
        {
            object oHero = GetHero();

            // skip character generation
            Chargen_InitializeCharacter(oHero);
            Chargen_SelectGender(oHero, GENDER_MALE);
            Chargen_SelectRace(oHero, RACE_HUMAN);
            Chargen_SelectCoreclass(oHero, class_WARRIOR);
            Chargen_SelectBackground(oHero, BACKGROUND_NOBLE);

            // give the player some equipment
            EquipItem(oHero, UT_AddItemToInventory(R"gen_im_arm_cht_lgt_rlr.uti"));
            EquipItem(oHero, UT_AddItemToInventory(R"gen_im_arm_bot_lgt_rlr.uti"));
            EquipItem(oHero, UT_AddItemToInventory(R"gen_im_arm_glv_lgt_rlr.uti"));
            EquipItem(oHero, UT_AddItemToInventory(R"gen_im_arm_shd_sml_wdn.uti"));
            EquipItem(oHero, UT_AddItemToInventory(R"gen_im_wep_mel_lsw_lsw.uti"));

            break;
        }
    }

    // if this event wasn't handled by this script fall through to the core script
    if(!nEventHandled)
    {
        HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);
        [b]HandleEvent(resource rScriptName = R "phae_dacrafting_debug"[/b]

    }
}
The emboldened line is the one I'm curious about.
The script compiles, but phae_dacrafting_debug doesn't load, or initialise. I've been initialising the script using the devconsole, but I'd rather automate the process. I'd ask Phaenan about it, but I've probably bugged Phaenen enough.
Any ideas?

Modifié par indio, 20 juin 2010 - 03:27 .


#2
ladydesire

ladydesire
  • Members
  • 1 928 messages
If you're using this in a stand-alone module, couldn't you do the initialization in an area script? Another option would be to use a PRCSCR 2da file to execute the script when you enter the starting area of the module. HandleEvent(), while it seems it should work the way you want, is mainly for scripts like sys_chargen, rather than ExecuteScript() (what I would have used in Neverwinter Nights 2 to do what you're attempting to do), which is a depreciated function in DA.

#3
indio

indio
  • Members
  • 204 messages
Thanks for the reply. I did try area first, but it also failed, so I ended up going for the module instead. I will try the PRCSCR 2da (first I will learn what one is :)) and try that. ExecuteScript was indeed my inspiration, and I've no idea what depreciated means outside of finances. Heh.



Much obliged for the idea.

#4
indio

indio
  • Members
  • 204 messages
Any alternatives to the PRCSCR? They're tricky for n00b scripters.

#5
Phaenan

Phaenan
  • Members
  • 315 messages

indio wrote...
I'm trying to initialise Phaenan's crafting system (awesome) in the following way:

It needs to be initialized ? Why nobody told me ? :whistle:

    // if this event wasn't handled by this script fall through to the core script
    if(!nEventHandled)
    {
        HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);
        [b]HandleEvent(resource rScriptName = R "phae_dacrafting_debug"[/b]
    }
}
The emboldened line is the one I'm curious about.


I'm not sure what this thingy is supposed to do, as there are no events handling involved at the core level in that system. But anyways, that line isn't ok and I would actually say it can't compile.
HandleEvent needs an event as first param :
- http://dalexicon.net...eEvent_function
And you can't declare a variable right when you're using it ; finally resources must include the file extension. So it should be :
resource rScriptName = R"phae_dacrafting_debug.ncs";
HandleEvent(ev, rScriptName);

Modifié par Phaenan, 20 juin 2010 - 08:36 .


#6
indio

indio
  • Members
  • 204 messages
*grumbles*
You were right. It wasn't compiling. Wishful thinking.

Your solution has indeed triggered the script to fire, so thank you.

Modifié par indio, 20 juin 2010 - 09:23 .