lesi123 Posted November 8, 2016 Share Posted November 8, 2016 (edited) Hello all, I'm combing back though an old mod that I made when I first tried my hand at some more complex scripting and I'm wanting to make some changes. I want to be as efficient with them as possible but I've not found any answers regarding how the scripts are actually read. OnBlahEvent if ConditionA if ConditionB ;do a thing elseif ConditionC ;do another thing endif endifEndEvent When the script is executed, does it jump to the 'EndEvent' if the 'if ConditionA' is not met? Or does it read everything below ConditonA regardless? I have a similar question with groupings: if (ConditionA && ConditionB && ConditionC) || (ConditionD && ConditionE && ConditionF);do a thingendif Does the script 'do a thing' once it reads that the group (ConditionA && ConditionB && ConditionC) meets the conditions, or does it continue to read the other groupings anyway? Edited November 8, 2016 by lesi123 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 8, 2016 Share Posted November 8, 2016 As I understand it, if the IF statement fails the check, the entire block is skipped. It doesn't make sense for it to read the contents of a failed block. Furthermore, if you put notification strings within the various IF statement blocks, only those whose IF statements were true would display. That right there indicates that papyrus does not read what it does not need. Regarding the more complex grouping: In an OR statement, if the first group is true, it processes. If the first group is false, it checks the second group. If the second group is true, it processes. Even if both groups were true, it will still process. Take all that with a grain of salt as I have no programming knowledge/training to back me up. Merely how things seem to work in-game. Link to comment Share on other sites More sharing options...
lesi123 Posted November 8, 2016 Author Share Posted November 8, 2016 Now that I think about it, I do recall the notifications I set up during testing displaying when conditions in one block were met and the notifications for other blocks didn't. My new question is should I tier my condition checks in the order most needed so it can skip blocks it doesn't need to read? It would make the script longer as a whole, but if it's skipping massive chunks that don't meet the more general conditions, I assume it would still be more efficient than having large grouping checks? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 8, 2016 Share Posted November 8, 2016 It depends upon what you need to happen. Can't answer that without knowing what you want to do. All I can really say is, do it so that it works. Then if you are concerned about performance, thread safety and other such things, then post your script with the specific concerns you have about it. Hopefully then someone who understands those ins and outs will respond. Link to comment Share on other sites More sharing options...
lesi123 Posted November 8, 2016 Author Share Posted November 8, 2016 It's an OnHit script applied to NPCs with the CK wiki dynamic script attachment method. It applies a debuff spell on them when hit with certain weapons. The current script works, but it feels very clunky and I made it before I knew how powerful global variables could be. It's nice knowing it can be done, but I wanted to improve on it to be more flexible with it's options. I'm still writing the new one, which brought up the question on writing best practices.Thanks for your insight though! Link to comment Share on other sites More sharing options...
Recommended Posts