Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Trouble with conditional scripts, again :P

Page: 1 of 1
 Exile007
04-12-2008, 3:48 AM
#1
Hey, sorry to pester you guys about scripts again, but I wrote this script and it compiles fine, but it just doesn't work in game.

I'm trying to make a fairly simple one, the script is supposed to spawn a creature and start a conversation once something has happened. This is what I'm using to set the GlobalNumber:


void main()
{
SetGlobalNumber("Sith_attack", 4);
}


And the check to see if the requirement has been fulfilled:


void main()
{
int nThingy=GetGlobalNumber("Sith_attack");

if (nThingy == 4)
{
object oPC=GetFirstPC();

CreateObject(OBJECT_TYPE_CREATURE, "n_zekk", Location(Vector(-0.22019,213.73494,17.49721), 269.35315));
object oZekk=GetObjectByTag("zekk");
AssignCommand(oZekk, ActionStartConversation(oPC, "zekk"));
}

}

Does anyone have any idea what I did wrong?
 stoffe
04-12-2008, 7:31 AM
#2
Hey, sorry to pester you guys about scripts again, but I wrote this script and it compiles fine, but it just doesn't work in game.


Have you added the Sith_attack global number variable to the globalcat.2da file and put that in the override folder? Global variables needs to be listed in this file or the game won't keep track of them.

Is the n_zekk.utc file either in the module this is run from, or in the override folder? Also make sure the coordinates are valid, so it isn't spawned elsewhere.

That's the only things I can think of since I can't spot anything that's technically wrong with your script. :)


Though you can write it a bit shorter by eliminating a few variables that are only used once, and cutting off a few decimals from the coordinates since you won't notice any differences with fractions of a millimeter ingame. :) It's also better to assign the object reference directly to the object you create rather than get it by tag afterwards, since you're sure to get the correct object this way. Like:


void main() {
if (GetGlobalNumber("Sith_attack") == 4) {
object oZekk = CreateObject(OBJECT_TYPE_CREATURE, "n_zekk", Location(Vector(-0.22, 213.73, 17.49), 269.35));
AssignCommand(oZekk, ActionStartConversation(GetFirstPC(), "zekk"));
}
}
 Exile007
04-12-2008, 12:08 PM
#3
Have you added the Sith_attack global number variable to the globalcat.2da file and put that in the override folder? Global variables needs to be listed in this file or the game won't keep track of them.

Is the n_zekk.utc file either in the module this is run from, or in the override folder? Also make sure the coordinates are valid, so it isn't spawned elsewhere.

That's the only things I can think of since I can't spot anything that's technically wrong with your script. :)


Though you can write it a bit shorter by eliminating a few variables that are only used once, and cutting off a few decimals from the coordinates since you won't notice any differences with fractions of a millimeter ingame. :) It's also better to assign the object reference directly to the object you create rather than get it by tag afterwards, since you're sure to get the correct object this way. Like:


void main() {
if (GetGlobalNumber("Sith_attack") == 4) {
object oZekk = CreateObject(OBJECT_TYPE_CREATURE, "n_zekk", Location(Vector(-0.22, 213.73, 17.49), 269.35));
AssignCommand(oZekk, ActionStartConversation(GetFirstPC(), "zekk"));
}
}


That was actually the original script, but I thought there was something wrong with it, so I changed it.

Whoops, didn't know that I needed to add anything to globalcat.2da, thanks stoffe!
Page: 1 of 1