Skip to content

Scripting Revelation

wolpakwolpak Member Posts: 390
I am not sure if this has been discussed before, and I am sure the more hard core modders would scoff that I didn't utilize/know this, but here is a scripting technique I just discovered (rediscovered).

If you have been looking through my BGO mod you'll see that I am making skills use modifiers (in the 3e vein). The problem with that is the limited functionality of how scripting works.

We have a basic
IF
THEN
block and everything has to fit neatly into it. The problem is that it is a misnomer. This isn't an IF THEN block, but a While loop. While the "IF" remains true, keep on doing the "THEN" until the IF is no longer true. This is much more potent than a simple IF THEN. What makes this even better are self incrementing globals.

IncrementGlobal(S:Name*,S:Area*,I:Value*)
AddGlobals(S:Name*,S:Name2*)

And global comparisons:

GlobalsEqual(S:Name1*,S:Name2*)

What these can allow is the script block to run continuously until the conditions are met. How does this affect you? I'll tell you how it effects my mod.

First, I have a checkstat on each of the main statistics and then have a variable that gets incremented every even number (to simulate the +1 for each modifier).

Of course, this would require going through 25/2 = 13 iterations up (to increase my variable) and then 25/2 = 13 iterations down to decrease my variable (if you put on dex gauntlets the modifier has to increase, but if you remove them, it has to decrease). Then I have to recreate this for 5 other party members. Not a big deal with find and replace, but obviously taxing when added to a script. The problem is the need to recreate this over and over for different situations. Inquisitor needs this, Bard needs that. Each one requires a ton of scripts to check and run.

With the ability to increment globals, you can run the script until the global you need equals the one set earlier in the script. Now one or two scripts can do the work of 20+.

So, if you knew this, you can laugh. If not, I hope this helps in not on;y making scripts much more lean and efficient, but easier and intuitive.
Sign In or Register to comment.