FiftyTifty Posted March 24, 2020 Share Posted March 24, 2020 Fixing up one of my mods, and one of the issues is that when multiple ingestible items are ussed, that call their own script effect, only the first one is processed properly. Subsequent ingestibles used without closing the pipboy and re-opening it after using a single ingestible, causes the item to be used and the menu to appear. But no actor is spawned. The workflow goes: Ingestible -> Base Effect -> Script Effect -> Script The script then goes: On ScriptEffectStart, ShowMessage() -> On ScriptEffectUpdate, set iWait due to ScriptEffectUpdate() being called repeatedly -> Check result from ShowMessage(), spawn a specific NPC respectively Here's one such script: scn AAAFyTyRoboticianMisterHandyKitScript int iButton int iWait ref refSpawn Begin ScriptEffectStart ShowMessage AAAFyTyRoboticianMessageRepairMisterHandy let iWait := 1 End Begin ScriptEffectUpdate if iWait == 1 let iButton := GetButtonPressed if iButton == 0 let refSpawn := Player.PlaceAtMe AAAFyTyMisterOrderly 1 let iWait := 0 Dispel AAAFyTyRoboticianMisterHandyKit elseif iButton == 1 let refSpawn := Player.PlaceAtMe AAAFyTyMisterHandy 1 let iWait := 0 Dispel AAAFyTyRoboticianMisterHandyKit elseif iButton == 2 let refSpawn := Player.PlaceAtMe AAAFyTyMisterHandyDC 1 let iWait := 0 Dispel AAAFyTyRoboticianMisterHandyKit endif endif End There's a bunch of others, but they follow the exact same structure. I had to use iWait, as ScriptEffectUpdate is called multiple times, and loses the result from ShowMessage, as it's data is lost in subsequent frames. Using iWait as a lock avoids message spam and invalid script stuff. So how should I go about this? Link to comment Share on other sites More sharing options...
FiftyTifty Posted March 25, 2020 Author Share Posted March 25, 2020 I figured it out. You use MessageBoxExAlt at the ScriptEffectStart block to create the menu, which calls back to a UDF script. And it automatically passes the selected button to your script. This is how my Mister Handy menu script now looks: scn AAAFyTyRoboticianMisterHandyKitScriptBegin ScriptEffectStart Print "Starting script effect for Mister Handy!" MessageBoxExAlt AAAFyTyRoboticianMenuSpawnMisterHandyScript "^Mr. Handy Assembly^ |Mister Orderly|Mister Handy (Mojave)|Mister Handy (Washington)"End And my UDF just has the iButton checks block in it. Boom. Problem solved. Link to comment Share on other sites More sharing options...
dubiousintent Posted March 25, 2020 Share Posted March 25, 2020 Nice tip. Noted for posting to the wiki. -Dubious Link to comment Share on other sites More sharing options...
Recommended Posts