Make Script A start Script B?

Post » Sat Oct 17, 2009 1:02 am

I'm using a modders resource for an ingredient sorter, the script is separated into Morrowind ingredients sorted by one activater and Expansion ingredients sorted by another ... I want one activator to do both ... is there anyway to modify script A to start script B?
User avatar
Hot
 
Posts: 3433
Joined: Sat Dec 01, 2007 6:22 pm

Post » Sat Oct 17, 2009 5:36 am

The http://www.uesp.net/morrow/editor/mw_cscommands.shtml#startscript function will let you do that.
User avatar
Latino HeaT
 
Posts: 3402
Joined: Thu Nov 08, 2007 6:21 pm

Post » Fri Oct 16, 2009 5:19 pm

Hmm, tried the StartScript function with some thing like

Begin ScriptC

StartScript, ScriptA

StartScript, ScriptB

End

But it would only do the first.

I tried adding 'StartScript, ScriptB' to the end of ScriptA, which will work after you activate the first, but than will only activate the ScriptB from than on.
User avatar
Chloe Yarnall
 
Posts: 3461
Joined: Sun Oct 08, 2006 3:26 am

Post » Sat Oct 17, 2009 3:15 am

I'd try a do once, for instance:
Begin ScriptCshort doOnceif ( doOnce == 0 )  StartScript ScriptA  StartScript ScriptB  set doOnce to 1endifEnd
or test for script already running
Begin ScriptCif ( scriptrunning "ScriptA" == 0 )  StartScript ScriptAendifif ( scriptrunning "ScriptB" == 0 )  StartScript ScriptBendifEnd
and see what happens
User avatar
OTTO
 
Posts: 3367
Joined: Thu May 17, 2007 6:22 pm

Post » Fri Oct 16, 2009 11:30 pm

Hmm, tried the StartScript function with some thing like

Begin ScriptC

StartScript, ScriptA

StartScript, ScriptB

End

But it would only do the first.

I tried adding 'StartScript, ScriptB' to the end of ScriptA, which will work after you activate the first, but than will only activate the ScriptB from than on.


It's been a long time, but I think I remember an issue some of us investigated where it turned out that using 'StartScript' to start a script would restart all currently running scripts from the beginning.

If I'm remembering correctly, that's probably the source of your problem. Every time your script executes the 'StartScript ScriptA', all the scripts, including this one, start over from the beginning. So your script never gets past the first 'StartScript' command.

One solution is to use a counter variable to force the commands to execute in the correct sequence even if the script is restarted partway through:

Begin DT_DemoShort CountIf ( Count == 0 )    StartScript ScriptA    Set Count to 1EndIfIf ( Count == 1 )    StartScript ScriptB    Set Count to 0EndIfEnd


(I don't guarantee the syntax in that: it's been too many years...)

Actually, using a counter like in the above example is probably a very good idea any time your need a script to execute a sequence of steps in order even if the script gets restarted partway through. Otherwise you can wind up with weird bugs caused by the first steps in a sequence executing two or more times before the later steps are executed for the first time.

It's been years since I've had anything to do with Morrowind, so it's quite possible I'm totally out in left field on this. :)

...just passing through...
User avatar
Rachel Hall
 
Posts: 3396
Joined: Thu Jun 22, 2006 3:41 pm


Return to III - Morrowind