candlepin Posted June 21, 2017 Share Posted June 21, 2017 I'd like for a small script to run whenever a cooking station (cooking pots, cooking spits) or a tanning rack is activated and again when they are closed. What would be the best way to implement this? I would like to keep my mod as compatible as possible with other mods. One option would be to add a script directly to the cooking stations/tanning racks, but I'm not sure if that would cause issues with many other mods. My second question; I assume I can use OnActivate to trigger when the player activates cooking stations/tanning racks, but what should I use for when they exit the crafting stations? Could I use OnMenuClose (SKSE)? Link to comment Share on other sites More sharing options...
Gamer921 Posted June 21, 2017 Share Posted June 21, 2017 You have to attach a script to it that when the container is activated to change the variable then attach a registerforsingleupdate. Then do a event onupdate() and change your variable back to 0 Link to comment Share on other sites More sharing options...
Gamer921 Posted June 21, 2017 Share Posted June 21, 2017 Station not container my bad Link to comment Share on other sites More sharing options...
candlepin Posted June 22, 2017 Author Share Posted June 22, 2017 (edited) Is it better to attach the script directly to the stations in the CK or to add it via a ReferenceAlias? Also, I'm not sure how a RegistryForSingleUpdate would work here. I'd prefer the change to happen when the menu closes, not before or too much after. I think maybe I don't understand exactly what you're suggesting to do. Edited June 22, 2017 by candlepin Link to comment Share on other sites More sharing options...
foamyesque Posted June 22, 2017 Share Posted June 22, 2017 What precisely are you trying to do with the global variable, candlepin? Does it have to be updated when the menu closes? Link to comment Share on other sites More sharing options...
Gamer921 Posted June 22, 2017 Share Posted June 22, 2017 I didnt realize u were working with skse, cross off what i said about this. Im sure there is smarter ways than i suggested with that at your disposal. I dont use skse :P. Goodluck to ya. Link to comment Share on other sites More sharing options...
candlepin Posted June 23, 2017 Author Share Posted June 23, 2017 I have a spell that switches vanilla items to ingredient versions of the same item (food carrot --> ingredient carrot). It does this using formlists during OnItemAdded (it also switches the players inventory when initially cast). For the sake of compatibility, I'd like the switching spell be cast whenever one of the crafting stations is opened and cast a second time when the menu is closed. That way, the vanilla items are available for crafting, but are converted back to the ingredient version once the menu has closed. I'm open to other ideas on how to do this. Link to comment Share on other sites More sharing options...
foamyesque Posted June 23, 2017 Share Posted June 23, 2017 (edited) So if I'm understanding you correctly, the idea is that while your mod is going, stuff are ingredients, but you want to convert them back to vanilla when someone goes to use a crafting station? ... why make them ingredients in the first place then? Edited June 23, 2017 by foamyesque Link to comment Share on other sites More sharing options...
candlepin Posted June 23, 2017 Author Share Posted June 23, 2017 I would like carrots, for example, to be ingredients. I still want them to be usable for cooking though. My plan is to have the food version of carrots converted into the ingredient form so it can be used in alchemy. Those works perfectly. Now what I would like to happen is for carrots to be converted back to the food version whenever a cooking pot is activated. That way I don't have to change any recipes and it makes my mod compatible with mods that add cooking recipes. Then, when the cooking pot menu is closed, I want carrots to be converted back to the ingredient form so they can be used in alchemy. My spell can achieve this switching, I just have to figure out where to attach a script (and what triggers to use) that will cast the spell when these stations are activated and when they are exited. Does this make more sense? Link to comment Share on other sites More sharing options...
foamyesque Posted June 23, 2017 Share Posted June 23, 2017 Okay. I think my approach would be to run a search quest every time a cell attaches to the player, looking for, specifically, the cooking crafting stations (by keyword, I think). Shouldn't need more than a dozen aliases, I would say. A simple script goes on those to check for activations. Another script goes on the player via an alias, for state control, and to control the inventory swaps and check for menu closes. When one of the cooking stations is activated, it calls a function in the inactive state of the player script, which flips it into the listening state for an OnMenuClose. When the OnMenuClose fires, it flips the player script back into the inactive state. In the inactive state, there's no OnMenuClose, and in the active one, the attempted state-change function is empty. You can call your swaps on entering and leaving the active state. The state change functions are very quick to execute and should prevent weird race conditions from happening (e.g. the player triggering multiple swaps by spamming the activation button). An alternate means to find nearby stations would be through a cloak magic effect, but that tends to interfere with brawls and certain other events. Link to comment Share on other sites More sharing options...
Recommended Posts