Jump to content

[LE] [Papyrus] Question about starting and ending states.


SevenBlue

Recommended Posts

Question.

 

I'm attempting to start a state when the player enters a custom crafting menu by clicking a misc item I scripted.

 

I am fairly certain I know how to start the state, but how would I end it upon the player leaving the menu? I'm not even sure if that is possible without using OnSit and OnGetUp.

 

Any assistance anyone could provide would be most appreciated.

Link to comment
Share on other sites

I'm not sure, you'll have to test that out.

 

 

 

Doesn't look like it, ah well that's fine I can work around this using other methods. Just figured I'd try to make my crafting portable but it looks like tying it to furniture will have to do.

 

Thank you anyway!

Link to comment
Share on other sites

Here's a section of code I use in one of my personal mods to detect the crafting menu. I originally wrote it for Skyrim using the SKSE events but had to rewrite it without SKSE when Skyrim Special Edition first came out, then merged the two methods this way after SKSE64 was stable. It's not as light a script as I would normally write because it uses a while loop, but the loop is only active while you're in the crafting menu so it's light enough.

 

The non-SKSE trick I used was to simply wait for the player to turn. The player can't turn while in the crafting menu, but certainly will fairly quickly after it closes.

PlayerAlias.GoToState("CraftingRequest")
CraftingStation.Activate(PlayerRef, false)
Utility.Wait(0.1) ; give game time to get into the menu (use more if animations are involved)
if Game.GetModCount() > 0  ; SKSE support available
	while UI.IsMenuOpen("Crafting Menu") ; directly check for menu close
		Utility.Wait(0.1)
	endwhile
else ; no SKSE, so register the menu closed the first time the player turns even a little
	float angle = PlayerRef.GetAngleZ()
	while angle == PlayerRef.GetAngleZ()
		Utility.Wait(0.1)
	endwhile
endif
PlayerAlias.GoToState("")
Link to comment
Share on other sites

  • Recently Browsing   0 members

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