Nuascura Posted October 9, 2023 Posted October 9, 2023 If anyone has used OnSit() in their scripts before, I’d like to know if you’ve come across any unreliable cases as mentioned in the notes section under its page on the creationkit wiki. My use case for this event is to detect if player is using a specified workbench. The alternative is to use PO3’s Papyrus Extender Item Crafted event (since the similar onstoryevent is apparently broken). However, OnSit() is still the ideal event since it fires on activation of a furniture. Based on my use case, either of the two methods is fine. With OnSit(), I sacrifice milliseconds of performance time to detect event at an ideal time. With Item Crafted, I sacrifice that ideal time for an optimized conditional, as I do also want to exclude cooking pot furnitures for my use case. It all comes down to reliability.
Mister X Posted October 9, 2023 Posted October 9, 2023 How about creating a magic effect with the fitting conditions and add the script to that? 6 hours ago, Gyra said: My use case for this event is to detect if player is using a specified workbench Using IsInFurnitureState AND IsCurrentFurnitureRef as the conditions for the magic effect to apply, then do your things within OnEffectStart event in your script. Should be quite sufficient and reliable, especially if it's only for the player aswell as a specific workbench reference
Nuascura Posted October 9, 2023 Author Posted October 9, 2023 2 hours ago, Mister X said: How about creating a magic effect with the fitting conditions and add the script to that? Using IsInFurnitureState AND IsCurrentFurnitureRef as the conditions for the magic effect to apply, then do your things within OnEffectStart event in your script. Should be quite sufficient and reliable, especially if it's only for the player aswell as a specific workbench reference To be more specific, I want to know when the player uses any workbench besides cooking pot. Wouldn’t the amount of conditional keywords make it quite messy? And is that good practice? I assume it requires as many keywords as I’m currently using for the getup event.
wareware Posted October 9, 2023 Posted October 9, 2023 You can look at what Breakable Equipment System does for its workbench detection. For a universal approach you can just check if the player is in Crafting Menu using IsInMenuMode but that doesn't seem to have a way to exclude cooking pots.
Nuascura Posted October 10, 2023 Author Posted October 10, 2023 7 hours ago, wareware said: You can look at what Breakable Equipment System does for its workbench detection. For a universal approach you can just check if the player is in Crafting Menu using IsInMenuMode but that doesn't seem to have a way to exclude cooking pots. As per its creationkit wiki page, IsInMenuMode doesn't properly track crafting inside Menu. But, taking a cue from BES, I can make my main script RegisterForMenu and listen for OnMenuOpen, parameter string "Crafting Menu". Still, like you said, it can't exclude cooking pots.
Mister X Posted October 10, 2023 Posted October 10, 2023 15 hours ago, Gyra said: To be more specific, I want to know when the player uses any workbench besides cooking pot. Wouldn’t the amount of conditional keywords make it quite messy? OK, the sentence I quoted first sounds like it was one special workbench you want to track. If you just want to exclude cooking pots, you might use IsCurrentFurnitureObj and set it to NOT be cooking pots. The thing with this is, it would include any bed, bench, chairs and alike, too. Come to think of it: how many workbenches are there? 4 at a smithing place (smith, rack, workbench, grinding stone), 1 for alchemy and 1 for enchanting. Any more? I get 6 object types. That's not much. And why should a magic effect not be good practice? Create a quest, add the spell that holds the effect to the player and attach the script to the effect. Condition the effect correctly and all that stuff runs ONLY when you activate a furniture object. This probably even could be faster, as the filtering is done natively by the engine instead of the Papyrus code.
wareware Posted October 10, 2023 Posted October 10, 2023 4 hours ago, Gyra said: As per its creationkit wiki page, IsInMenuMode doesn't properly track crafting inside Menu. But, taking a cue from BES, I can make my main script RegisterForMenu and listen for OnMenuOpen, parameter string "Crafting Menu". Still, like you said, it can't exclude cooking pots. Listening for crafting menu is only part of what BES does. It also has a quest dedicated to tracking if the player opens up a workbench or sharpening wheel.
Nuascura Posted October 10, 2023 Author Posted October 10, 2023 (edited) 11 hours ago, Mister X said: And why should a magic effect not be good practice? Create a quest, add the spell that holds the effect to the player and attach the script to the effect. Condition the effect correctly and all that stuff runs ONLY when you activate a furniture object. This probably even could be faster, as the filtering is done natively by the engine instead of the Papyrus code. I was not asking that question rhetorically, with concern, or whatnot. And I was also not asking whether a "magic effect" is good practice, which seems to me a clearer question than what I'd initially asked regarding furniture detection in my OP, like you pointed out. I asked, out of genuine ignorance because I'm new to CK and have never dabbled with spells and magic effects, whether a large set of conditions is bad practice (and also what is considered "large" for native processing). Currently, I have 14 OR conditions under the Effect Item. Detecting IsInFurnitureState Sit OR Lean, and then 12 conditions checking workbenches, excluding cooking pots. However, this latter set includes "WorkbenchTableTop" and SkyForge and WR variants, as well as SmelterMarker1 and TanningMarker. Do you know how these obj references differ and what they mean? Okay, this combination seems to work: IsInFurnitureState Sit AND Alchemy OR Alchemy Tabletop OR Anvil OR ArmorWorkbench OR Forge OR ForgeSkyforge OR ForgeWR OR SharpeningWheel OR Enchanting OR Enchanting Tabletop OR SmelterMarker OR TanningRackMarker OR Edited October 10, 2023 by Gyra
Nuascura Posted October 10, 2023 Author Posted October 10, 2023 Alright, I've got it to work withIsInFurnitureState AND IsCurrentFurnitureObj. Thank you all for the tips
Mister X Posted October 12, 2023 Posted October 12, 2023 (edited) On 10/10/2023 at 6:51 PM, Gyra said: I was not asking that question rhetorically, with concern, or whatnot. And I was also not asking whether a "magic effect" is good practice, which seems to me a clearer question than what I'd initially asked regarding furniture detection in my OP, like you pointed out. I asked, out of genuine ignorance because I'm new to CK and have never dabbled with spells and magic effects, whether a large set of conditions is bad practice (and also what is considered "large" for native processing). For one: normally it's considered good practice to do as much as possible with "native" engine possibilities and to use Papyrus to only glue this stuff together. Classic example, a quest: you create most stuff (text, ReferenceAliases, dialogues, scenes,...) natively and only set stages by Papyrus. For two: of course, more conditions slow things down. I have no idea where this number comes from, but I did read somewhere that you should try to keep it below 15 at all cost and below 10 would be ideal. Nevertheless, it's still way better to have 15 native conditions than 5 Papyrus checks. And sometimes you simply can't avoid it. All in all you can keep for yourself: anything that's done "natively" always will be much faster than any Papyrus code could ever be. Edited October 12, 2023 by Mister X
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now