Jump to content

Need help with a script


Recommended Posts

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)

Endif

End

 

 

 

Thank you for taking your time to read :D

Edited by JimmyChooChoo
Link to comment
Share on other sites

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

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

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)
Endif
End

 

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...