Aller au contenu

Photo

modue script


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

#1
bowlie1

bowlie1
  • Members
  • 51 messages
 hi guys. im making a standalone module. im  not sure what to do with module scripts. so far i only have 3 scripts. the charigter generation one, and two different ones to do with making followers. should these all be as one file or as seperate ones? and what to i do with them after i have made them i.e. telling the module to use them? thanks

#2
jsd313

jsd313
  • Members
  • 184 messages
At least the character generation needs to be part of your module script.

#3
bowlie1

bowlie1
  • Members
  • 51 messages
At the moment the module script is only the char gen one. I think I might have almost sorted it though. I can now talk to the guy and bring up the part picker. Problem is he isn't there. I think this may be caused by the m2da's. When I used the excel processor it came up with the error message

error: worksheet sheet 2 has zero collumns (0) or rows (0) (is cell a1 'id'?)

the spreadsheet clearly has collumns and rows though. Any ideas ? Also when they are created they are just called sheet 1. Should I leave them like that or rename them so they are partypicker or party_picker respectivly? Thanks. And sorry for the clumsy question

#4
jsd313

jsd313
  • Members
  • 184 messages
If you started a new excel file and are only using one Worksheet you need to delete the other 2 Worksheet in that Spreadsheet. You can right click on the tab and choose delete.

Modifié par jsd313, 15 avril 2010 - 11:56 .


#5
bowlie1

bowlie1
  • Members
  • 51 messages
ok thanks, think that sorted that problem. hes not appearing though. i will have another look at the scriipts. how dose the modue script work? do i need to make a script called something like my_module_script and add in all of these scripts? i tried that and it made the charicter generation one not work

Modifié par bowlie1, 16 avril 2010 - 10:45 .


#6
bowlie1

bowlie1
  • Members
  • 51 messages
could someone explain what the module script is? i know its the one that i select in properties in module manager but im not sure what the actural script should contain. is it just one huge script that has all the necessary scripts in?

#7
Sunjammer

Sunjammer
  • Members
  • 925 messages
No. The module script is just the script that handles module events generated by the game engine (or events sent to the module through scripting).

Module events are generated when you start the module, at various points during character generation, when you save your game, when you load your save, when you level up, and so on.  There are lots of module events but you don't have to write code for all of them. Many of them you can ignore or you can allow them to fall through to module_core.nss as the default behaviour is adequate.

Other objects such as ares, creatures, placeables, etc., also have scripts for handling events generated for them.

Modifié par Sunjammer, 16 avril 2010 - 04:48 .


#8
Proleric

Proleric
  • Members
  • 2 346 messages
If the three cases mentioned in the OP are all module events (which sounds likely), then they all need to be in the same module script. It should include case statements determine which part of the script is executed for a particular event.

#9
bowlie1

bowlie1
  • Members
  • 51 messages
humm, still cant get it to work. is module event script different than module script?

#10
bowlie1

bowlie1
  • Members
  • 51 messages
heres what i have so far in my module script. this includes the two follower scripts from the wiki tutorial and the charicter generation one.



case EVENT_TYPE_MODULE_GETCHARSTAGE:

{

// Overlay the existing stage with my stage

// "my_char_stage" is the resource name of the overlay area

// "partypicker" is the name of the default GDA

SetPartyPickerStage("my_char_stage", "partypicker");

break;

}

#include "utility_h"

void main()

{

event ev = GetCurrentEvent();

int nEventType = GetEventType(ev);

switch(nEventType)

{

case EVENT_TYPE_PARTYMEMBER_ADDED:

{

object oFollower = GetEventObject(ev, 0);

SetLocalInt(oFollower, CREATURE_REWARD_FLAGS, 0); //Allows the follower to gain XP

AddCommand(oFollower, CommandJumpToLocation(GetLocation(GetHero()))); //Ensures follower appears at PC's location.

SetFollowerState(oFollower, FOLLOWER_STATE_ACTIVE); //Adds follower to the active party

break;

}



}

}

#include "events_h"

#include "global_objects_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:

{

// preloads resources needed for character generation

PreloadCharGen();



// initiates character generation

StartCharGen(GetHero(),0);



break;

}

}



// if this event wasn't handled by this script fall through to the core script

if(!nEventHandled)

{

HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);

}

}

#11
Proleric

Proleric
  • Members
  • 2 346 messages
You'll need to put all the #includes at the beginning, and move all the cases inside one switch, something like this:


#include "events_h"
#include "utility_h"
#include "global_objects_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:

{

// preloads resources needed for character generation

PreloadCharGen();



// initiates character generation

StartCharGen(GetHero(),0);



break;

}

case EVENT_TYPE_MODULE_GETCHARSTAGE:

{

// Overlay the existing stage with my stage

// "my_char_stage" is the resource name of the overlay area

// "partypicker" is the name of the default GDA

SetPartyPickerStage("my_char_stage", "partypicker");

break;

}

case EVENT_TYPE_PARTYMEMBER_ADDED:

{

object oFollower = GetEventObject(ev, 0);

SetLocalInt(oFollower, CREATURE_REWARD_FLAGS, 0); //Allows the follower to gain XP

AddCommand(oFollower, CommandJumpToLocation(GetLocation(GetHero()))); //Ensures follower appears at PC's location.

SetFollowerState(oFollower, FOLLOWER_STATE_ACTIVE); //Adds follower to the active party

break;

}

} // end switch

// if this event wasn't handled by this script fall through to the core script

if(!nEventHandled)

{

HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);

}

}


#12
bowlie1

bowlie1
  • Members
  • 51 messages
ok thanks. ive put that script in and the charicter gen works but lodd (the npc) still wont apear on the charicter stage. what else could i have done wrong?

also this is the hire script i put into the conversation.

  #include "utility_h"
void main() {
        object oFollower = GetObjectByTag("lodd"); //Use CreateObject() if the creature isn't present in the module yet
        UT_HireFollower(oFollower);   //Hires the follower
        SetPartyPickerGUIStatus(2);
        ShowPartyPickerGUI();  //Shows the Party Picker; necessary for the follower to gain XP
}

should it work? do i need to add this to the module core as well or just put it in the conversation as an action? thanks

Modifié par bowlie1, 18 avril 2010 - 11:26 .


#13
PavelNovotny

PavelNovotny
  • Members
  • 344 messages
Did you add a waypoint to the character stage for your npc?

The hire script should not go in the module script. Check out the Follower tutorial in the wiki. It is pretty clear and works fine.

Modifié par PavelNovotny, 18 avril 2010 - 02:05 .


#14
bowlie1

bowlie1
  • Members
  • 51 messages
ok then. i do have a waypoint and it isnt the module script. i was just checking it shouldnt be. i am using the follower wiki but have got to the end and it isnt working. do i need to change anything like the 0's in the script to the id number?

#15
bowlie1

bowlie1
  • Members
  • 51 messages
ok ive fixed it now. ive even added a second charicter. problem is i cant see her. she is definatly there because her portrait is in one of the 4 circles. but i cant see her in the screen.
edit:that is fixed now. i deleted the origional my_char_stage and when i made the new one and named it the same name the script still thought it was looking for the first one. i renamed the stage new_char_stage and changed the name in the script.

Modifié par bowlie1, 18 avril 2010 - 04:23 .