JimmyChooChoo Posted February 11, 2020 Share Posted February 11, 2020 (edited) Hello, I have been working on a mod and currently I'm working on a feature that is going to be in the mod, the type of script is a magic effect that will happen when you drink this potion, my problem is that when I drink the potion the effect happens whilst in the menu still, and I fear that will cause problems for people, like crashing ect. Here is my script; ScriptName (name of script) Begin ScriptEffectStart If Player (so npcs don't end up doing this) Player.Moveto (things ID)EndifEnd Thank you for taking your time to read :D Edited February 11, 2020 by JimmyChooChoo Link to comment Share on other sites More sharing options...
DrakeTheDragon Posted February 11, 2020 Share Posted February 11, 2020 Hmm, luckily, as long as the Script Effect is still in place, you can also use the other block types, like GameMode here. So just make a flag variable, which is set to 1 inside the ScriptEffectStart block, also conditionally, if you like, and make a GameMode block where it just checks for said variable to be 1, then does the MoveTo and sets it back to 0 to prevent repeated teleportation. This way you should be able to drink the potion and only once you leave the menu again the teleport should kick in. I haven't tried something like this myself yet though, but it should work. But if my script-foo doesn't betray me, a condition like "if Player" should actually always be true. If you want to check if the effect is running on the player, I think to recall it should be "if GetIsReference Player" instead, or something similar. Unless that's just a simplification for brevity's sake. Link to comment Share on other sites More sharing options...
JimmyChooChoo Posted February 11, 2020 Author Share Posted February 11, 2020 Thank you, I will try this out, i may also make this thing a mod of it's own in case people don't want the rest of the mod i'm making it in :D Link to comment Share on other sites More sharing options...
VencGanence Posted February 12, 2020 Share Posted February 12, 2020 Like DrakeTheDragon alluded to there's a gamemode and menumode block you can use in scripting. scn ScriptName short DoOnce begin menumode ;I don't know the exact code for here, so this is pseudo code if Player.DrinkPotion Set DoOnce to 1 endif end begin gamemode if DoOnce == 1 Player.MoveTo Location Set DoOnce to 0 endif end Link to comment Share on other sites More sharing options...
JimmyChooChoo Posted February 12, 2020 Author Share Posted February 12, 2020 It's ok now, I have figured it out, I will share my solution for future. So basically, I made the effect last 5 seconds as I wanted, by doing that via the effects box instead of putting it in the script. Begin ScriptEffectFinish (this will make you teleport at the last second then) If Player Player.Moveto (ID name of marker)EndifEnd Thank you for all your help too, I wouldn't have tried to figure out if there was a script effect end command XD Link to comment Share on other sites More sharing options...
DrakeTheDragon Posted February 12, 2020 Share Posted February 12, 2020 Using the ScriptEffectFinish block directly, now why didn't I think of that? Of course the spell duration won't run down, while still in the menus. No need for a GameMode block, if you need to be in GameMode for this block to be called. :thumbsup:And as an additional benefit, the ScriptEffectFinish block will also only run once, so you also won't need a variable for making it so. (Unless the game acts up for some reason, of course.) And yes, that's exactly what I meant with "as long as the Script Effect is still in place". The "duration" has of course to be set up in the potion's/spell's settings and can't really be done in/through the script. Link to comment Share on other sites More sharing options...
Recommended Posts