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.

Any decent scripters about?

Page: 1 of 1
 Marius Fett
01-29-2011, 6:34 AM
#1
oh hai <3

I've just recently started work on a 'large-ish' mod and i've hit something of a snag. I'm trying to change the Dune Sea onEnter script to make it spawn an NPC if my Globals value is set to 1, then using ExecuteScript, execute the original onEnter.

Trouble is, it's REALLY not working out. Anyone got any ideas? Here's my code:


//k_ptat18aa_enter.nss

int StartingConditional()
{
int iGlobal = GetGlobalNumber("K_MF_TAT");


if (iGlobal ==1)
{
ExecuteScript("mf_m18aaspbrax", OBJECT_SELF);
ExecuteScript("k_ptat18aa_enter_old", OBJECT_SELF);
}

return 0;

ExecuteScript("k_ptat18aa_enter_old", OBJECT_SELF);
}


and the spawn script:


void main()
{
CreateObject(OBJECT_TYPE_CREATURE, "m18aaBrax", Location(Vector((48.09), (368.54), 37.40), 180.0), 0);
}
 TimBob12
01-29-2011, 7:23 AM
#2
First of all you dont need s conditional script. They areusually used for diaalogue. It just needs to bew a void main sacript

Second u dont have enough coordinates set. I would post an example but im on my phone. It should work after that.

If u want an exaample check out my tatooine job office which has all the scrript source available and is commented with what it does. Itss in mqy WIP thread. Also caheck out my new tutorial on conditional scriipts.

Hope this helped. Sorry for the baqda spelling.

TB12
 Canaan Sadow
01-29-2011, 7:24 AM
#3
I've never really dealt with an on enter script... I usually just script characters in via dialogue (though I really shouldn't do that, so I'm going to stop :p ). However it seems to me that the problem might be with the "if (global ==1)" line. I'm not sure that there are supposed to be two "=" symbols. Again... I'm not 100% sure that'll fix it, because I've never dealt with on enter scripts :xp:
 TimBob12
01-29-2011, 7:28 AM
#4
== is correct
 bead-v
01-29-2011, 8:39 AM
#5
First of all you dont need s conditional script. They areusually used for diaalogue. It just needs to bew a void main sacript

Second u dont have enough coordinates set. I would post an example but im on my phone. It should work after that.
Right about 'void main()', but the coords look alright to me. Though a Z of 37 meters, most models aren't that high, are you sure you put in the right value?

Also I had a similar problem with an OnEnter script, I couldn't get a creature to spawn until I set a delay for it. You can try that too.
 TimBob12
01-29-2011, 9:08 AM
#6
sorry. I didn't see it was scrolling.
 Qui-Gon Glenn
01-29-2011, 11:28 AM
#7
//k_ptat18aa_enter.nss

int StartingConditional() Discussed....
{
int iGlobal = GetGlobalNumber("K_MF_TAT");

if (iGlobal ==1)
{
ExecuteScript("mf_m18aaspbrax", OBJECT_SELF);
ExecuteScript("k_ptat18aa_enter_old", OBJECT_SELF) // <-- Is this line necessary twice?
}
return 0; // What's this doing?
ExecuteScript("k_ptat18aa_enter_old", OBJECT_SELF); // one of these should be good :)
}

So, it looks like good code for the most part.... Since you always want the original OnEnter to run, it does not need to be a part of the conditional, and can instead be the default event that occurs when your new OE runs.
//k_ptat18aa_enter.nss

void main()
{
int iGlobal = GetGlobalNumber("K_MF_TAT");

if (iGlobal == 1) //skips unless this specific condition is met
{
ExecuteScript("mf_m18aaspbrax", OBJECT_SELF);
// return 0; only if you need to put a value back into iGlobal? You could also just assign it within the conditional, ie iGlobal=0
}

ExecuteScript("k_ptat18aa_enter_old", OBJECT_SELF); // always runs

}
If you wanted to eliminate the spawn script entirely, you could put the CreateObject code as a result of the conditional, and eliminate the ExecuteScript.

This code really should work fine though, so make sure your globalcat.2da is modded the way you would expect :p
 bead-v
01-29-2011, 12:45 PM
#8
The return 0; is there because the function StartingConditional() returns an integer. I'm not completely sure whether it is necessary to reutrn something or not, but since you're supposed to use main() anyway, just remove it.
 TimBob12
01-29-2011, 1:37 PM
#9
Its not necessary in a void command hence the void part of it :P

http://www.lucasforums.com/showthread.php?t=206600)

that explains it all.
 DarthStoney
01-29-2011, 3:06 PM
#10
Give this a shot and see if this works for you
//k_ptat18aa_enter.nss
void main() {
object oEntering = GetEnteringObject();
if ((oEntering == GetFirstPC())) {
if ((GetGlobalNumber("K_MF_TAT") == 1)) {
ExecuteScript("mf_m18aaspbrax", OBJECT_SELF);
ExecuteScript("k_ptat18aa_enter_old", OBJECT_SELF);
}
else {
ExecuteScript("k_ptat18aa_enter_old", OBJECT_SELF);
}
}
}
Page: 1 of 1