PDA

View Full Version : Ugh! More questions about scripting!


Exile007
06-19-2008, 01:10 AM
Hello there Holowan,

I have NO idea why the hell this script is not working! It is fine as far as I can tell, yet for some reason it will not work!:firemad:

What I'm trying to do is fairly simple. I'm trying to start a conversation that will only fire off once, as soon as I enter a module. I have attached it to the OnEnter part of the .are file. :firemad:


void main()
{
int i = GetGlobalNumber("833_sith");

if(i==0) {

object oPC=GetFirstPC();
object oSith=GetObjectByTag("g_cradus");

ActionDoCommand(SetCommandable(TRUE, oSith));
AssignCommand(oSith, ActionStartConversation(oPC, "open"));

SetGlobalNumber("833_sith", 1);
}
}

If someone could tell me what I did wrong, I would greatly appreciate it. I probably missed something too.

Please excuse me if I sound too pissed off, you must understand I have been at trying to make this work for three days. :p

Gavroche
06-19-2008, 02:43 AM
What does not work? Does the dialogue fire as many times as you want while it's meant to fire once only, or just not at all?

If it's the latter, just a simple question, are you sure 833_sith is set to 0 by default? I'm not familiar with dialogue firing syntax yet, so the error could also be in the instructions, I can't tell.

deathdisco
06-19-2008, 03:10 AM
I'm no expert in scripting but if you are using an "if" statement, shouldn't there be an "else" statement somewhere in there?

Gavroche
06-19-2008, 03:36 AM
Don't think so. Perhaps it makes the code less conventional, but it should not be less functional. What would we put in the "else" anyway?
else {do(nothing);} '^^

Here if the condition is not met (which happens any time 833_sith is not 0), the script will simply do nothing. And that's what we want.

Darth InSidious
06-19-2008, 07:40 AM
Try using a boolean instead of a number.

stoffe
06-19-2008, 07:56 AM
I have NO idea why the hell this script is not working! It is fine as far as I can tell, yet for some reason it will not work!:firemad:



This problem might be caused by the fact that you don't check who is entering the area before triggering the script. If some NPC is spawned into the area before the player character is, the script will trigger, the global var will be set, but the start conversation function will fail since the player character isn't present in the area yet.

(Also, areas have no action queue IIRC, so the ActionDoCommand() function will not be meaningful to use.)

Try checking that the character entering is the player character before executing the rest of the script. Like:


void main() {
object oPC = GetFirstPC();
if ((GetEnteringObject() == oPC) && (GetGlobalNumber("833_sith") == 0)) {
object oSith = GetObjectByTag("g_cradus");

SetCommandable(TRUE, oSith);
DelayCommand(0.5, AssignCommand(oSith, ActionStartConversation(oPC, "open")));

SetGlobalNumber("833_sith", 1);
}
}

Exile007
06-19-2008, 12:20 PM
My apologies for not saying what wasn't working. How very smart. :p Basically the conversation wasn't starting at all. :P

Thank you very much stoffe, that script worked like a charm. :D