Hello, I’m looking for a way to turn this script from a random waypoint jump to an ordered sequence for each use. A simple 1, 2, 3 and then back to 1 order. I’m only an amateur scripter, so I find myself a bit lost. Thanks.
Thank you for the response. Testing seemed to give me a compiling error.
6/3/2020 8:14:16 AM: Error. ‘su_spireenter’ did not compile.
su_spireenter.nss(44): ERROR: PARSING VARIABLE LIST
I’m not sure why. Correct me if I’m wrong, but wouldn’t there also need to be a section that tracks each use to change the variable between 1-3 to teleport in a sequence?
You probably need to fix the double quotes if you copy/pasted. Just retype them with real double quotes on the GetWayointByTag lines. And the “NextSpireTargets” ones…
I don’t think that will do what you described in the OP.
if (GetLocalInt(OBJECT_SELF, "NextSpireTarget")!= 1)
return;
This part makes the script only work at all when NextSpireTarget == 1. But you wanted it to cycle on each use, this will prevent that.
SetLocalInt(OBJECT_SELF, "NextSpireTarget", 2);
if (GetLocalInt(OBJECT_SELF, "NextSpireTarget")== 2)
This part will always be true. It looks like you will jump to target 1 then jump to target 2 then
since you’ve set it to 3 it’ll never do anything again since NextSpireTarget is not 1.
Here is a shorter version that should do what you described. Take a look and see if it makes sense to you. In this one you don’t need to remember to set the variable initially.
void main() {
object oPC = GetLastUsedBy();
if (!GetIsPC(oPC)) return;
int nTarget = GetLocalInt(OBJECT_SELF, "NextSpireTarget");
if (nTarget <= 0 || nTarget > 3)
nTarget = 1;
object oTarget = GetWaypointByTag("0SpireEnter" + IntToString(nTarget));
location lTarget = GetLocation(oTarget);
// Probably worth a sendmessage here for debugging
if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;
oTarget=GetFirstFactionMember(oPC, FALSE);
while (GetIsObjectValid(oTarget)) {
AssignCommand(oTarget, ClearAllActions());
AssignCommand(oTarget, ActionJumpToLocation(lTarget));
oTarget=GetNextFactionMember(oPC, FALSE);
}
SetLocalInt(OBJECT_SELF, "NextSpireTarget", nTarget + 1);
}
You’re right, it didn’t end up working the way I thought. I ended up making three separate scripts to save myself some headache, and that seems to be working. I may end up using yours for something else down the road. Thanks again.