Marius Fett Posted January 29, 2011 Share Posted January 29, 2011 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); } Link to comment Share on other sites More sharing options...
TimBob12 Posted January 29, 2011 Share Posted January 29, 2011 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 Link to comment Share on other sites More sharing options...
Canaan Sadow Posted January 29, 2011 Share Posted January 29, 2011 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 ). 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 Link to comment Share on other sites More sharing options...
TimBob12 Posted January 29, 2011 Share Posted January 29, 2011 == is correct Link to comment Share on other sites More sharing options...
bead-v Posted January 29, 2011 Share Posted January 29, 2011 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. Link to comment Share on other sites More sharing options...
TimBob12 Posted January 29, 2011 Share Posted January 29, 2011 sorry. I didn't see it was scrolling. Link to comment Share on other sites More sharing options...
Qui-Gon Glenn Posted January 29, 2011 Share Posted January 29, 2011 //k_ptat18aa_enter.nss int StartingConditional() [color=darkorange]Discussed....[/color] { int iGlobal = GetGlobalNumber("K_MF_TAT"); if (iGlobal ==1) { ExecuteScript("mf_m18aaspbrax", OBJECT_SELF); ExecuteScript("k_ptat18aa_enter_old", OBJECT_SELF)[color=darkorange] // <-- Is this line necessary twice?[/color] } return 0; [color=darkorange] // What's this doing?[/color] ExecuteScript("k_ptat18aa_enter_old", OBJECT_SELF); [color=darkorange] // one of these should be good [/color] } 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 Link to comment Share on other sites More sharing options...
bead-v Posted January 29, 2011 Share Posted January 29, 2011 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. Link to comment Share on other sites More sharing options...
TimBob12 Posted January 29, 2011 Share Posted January 29, 2011 Its not necessary in a void command hence the void part of it http://www.lucasforums.com/showthread.php?t=206600 that explains it all. Link to comment Share on other sites More sharing options...
DarthStoney Posted January 29, 2011 Share Posted January 29, 2011 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); } } } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.