heyas guys;
i'm looking for how i can select one of my characters to go into a new module, rather than generating a new one on startup. sorta like awakenings, where it asks if you want to load a character from one of your save games. that would be perfect. (the awakenings module doesnt seem to be in my module list to look at :/ )
i haven't worked with the da scripting (though i've done nwn scripting years ago), so... actually, a full start-module event would be nice. i dont know, is there a new command to load a character from a save game? :/
Module Start: Load a Character
Débuté par
BloodsongVengeance
, août 15 2010 01:20
#1
Posté 15 août 2010 - 01:20
#2
Posté 15 août 2010 - 09:36
Create a new script in the palette on the right. Paste the following in. When you're done, save it, go to file -> manage modules -> properties -> module script and select the script you just made. Then right click on the file in the palette and select 'export without dependent resources.'
It's a little messy here, but I've put some comments in. You should look into scripting on the wiki as well, there's some good tutorials and sample scripts. Basically what we're doing here is adding this code in front of the normal module script. When the game fires an event that would go to this module script, it instead comes here first. If it's the start of the game, we fire up the Awakening style import GUI. Then, we pass that or any other event on to the normal module script to take care of it.
#include "global_objects_h"
//this lets us see a core script, which has the definition for
//RESOURCE_SCRIPT_MODULE_CORE which we use below. You can see this if
//you right click on RESOURCE_..._CORE below and select 'go to definition'.
void main()
{
event ev = GetCurrentEvent();
int nEvent = GetEventType(ev);
int bHandled = FALSE;
//all this sets up some variables to tell how to handle this event
object hero = GetHero();
//this is just a handy variable to refer to the player
switch (nEvent)
//here we have different cases for handling different events
{
case EVENT_TYPE_MODULE_START:
{
//this is our case for the event when the game starts
PreloadCharGen();
StartCharGen(hero,0,TRUE);
//this code starts up character generation.
//The TRUE in StartCharGen enables character import.
//You can see this if you right click on StartChargen and
//select "Go to definition".
break;
}
}
if (!bHandled)
{
//if there is an event we haven't taken care of here
//i.e. everything but the start, we pass it on to the
//core script for modules.
HandleEvent(ev,RESOURCE_SCRIPT_MODULE_CORE);
}
}
It's a little messy here, but I've put some comments in. You should look into scripting on the wiki as well, there's some good tutorials and sample scripts. Basically what we're doing here is adding this code in front of the normal module script. When the game fires an event that would go to this module script, it instead comes here first. If it's the start of the game, we fire up the Awakening style import GUI. Then, we pass that or any other event on to the normal module script to take care of it.
#include "global_objects_h"
//this lets us see a core script, which has the definition for
//RESOURCE_SCRIPT_MODULE_CORE which we use below. You can see this if
//you right click on RESOURCE_..._CORE below and select 'go to definition'.
void main()
{
event ev = GetCurrentEvent();
int nEvent = GetEventType(ev);
int bHandled = FALSE;
//all this sets up some variables to tell how to handle this event
object hero = GetHero();
//this is just a handy variable to refer to the player
switch (nEvent)
//here we have different cases for handling different events
{
case EVENT_TYPE_MODULE_START:
{
//this is our case for the event when the game starts
PreloadCharGen();
StartCharGen(hero,0,TRUE);
//this code starts up character generation.
//The TRUE in StartCharGen enables character import.
//You can see this if you right click on StartChargen and
//select "Go to definition".
break;
}
}
if (!bHandled)
{
//if there is an event we haven't taken care of here
//i.e. everything but the start, we pass it on to the
//core script for modules.
HandleEvent(ev,RESOURCE_SCRIPT_MODULE_CORE);
}
}
#3
Posté 16 août 2010 - 12:43
oh, just add true to that chargen function? killer!
thanks again, fergus!
thanks again, fergus!





Retour en haut







