Jump to content

Photo

PapyrusUtil - Modders scripting resource


  • Please log in to reply
138 replies to this topic

#21
MongoMonk

MongoMonk

    Old hand

  • Members
  • PipPipPip
  • 930 posts
In response to post #33712640. #33874685, #33903910, #33952360, #33969230, #34150190 are all replies on the same post.


Spoiler

I've come to the conclusion that StorageUtil is the best bet for me. I may add an export/import feature through JsonUtil later. Since I will store all values on forms (using them as the key argument) I will probably be safe from dynamic form weirdness. I might add some checks for dynamic forms specifically in any case.
Again, thank you for the elaborate answer. You're really helping me out here (although a more exhaustive documentation could also help ;) ).

I've got some more questions, they come as I code the new Papyrus stuff and as I map it out.
What happens to values I saved when the mod is uninstalled? Does StorageUtil have a way to check for that & clear the corresponding values or do I have to include some sort of "uninstaller" to my mod?

Also I stumbled across this function in MiscUtil: function ScanCellActors. It could prove very useful to me. Is it based on Cell.GetNthRef from SKSE? Or your own implementation? Also, would it be possible to optionally include dead actors into the search?


#22
exiledviper

exiledviper

    Journeyman

  • Premium Member
  • 43 posts
In response to post #33712640. #33874685, #33903910, #33952360, #33969230, #34150190, #34152155 are all replies on the same post.


Spoiler

If a mod is uninstalled, any forms from it become none in the value storage. If the form was being used as the objkey in storageutil, during load if it can't find the objkey's owning mod anymore, all of it's values are cleared.

If you're storing values on forms not owned by your mod, those values won't go away when you uninstall the mod obviously. So, I'd suggest keeping a basic "uninstall list" stored in the global space (using "none" as your objkey) via a stroageutil.formlistadd(none, "myModsList", form, false) which you would call anytime you add a value to a new form not owned by your mod. This way you can iterate over that list and clear any values set by your mod on other forms to ensure there is no lingering data.

ScanCellActors does use SKSE's GetNth functions internally. The main benefit is that it's significantly faster at filtering out specific results, since you're not doing it via papyrus. ScanCellActors specifically doesn't have anyway to disable the removal of dead actors from the results, you could simulate something like that though by using ScanCellObjects with form type 43 and keyword ActorTypeNPC.

#23
MongoMonk

MongoMonk

    Old hand

  • Members
  • PipPipPip
  • 930 posts
In response to post #33712640. #33874685, #33903910, #33952360, #33969230, #34150190, #34152155, #34258015 are all replies on the same post.


Spoiler

Okay, I'll have a look then at ScanCellObjects since I want to specifically get dead actors.
As for the uninstaller I was thinking of using ClearIntValuePrefix etc. since all my saved values start with the same prefix (" EBD_" ) which I think is unique enough so I don't touch other mods.
However, am I right in the assumption that I would not need an uninstaller if I were to use JsonUtil? Since all value associations are only written to external jsons? Or are they kept as copies in the savegame (for error checking or something) as well?

EDIT: I know it's probably not feasible but I ask anyway:
Would it be possible to provide some uninstallation framework?
I.E. I register my mod with something like RegisterModUninstall("myMod.esp", "prefix_to_clear" ). Then, when myMod.esp vanishes from the load order JsonUtil would remove all values with the "prefix_to_clear".
It's probably much more work than I think but it would really streamline removal of a mod.

EDIT 2: I had a look at the ScanCellObjects function. There seems to be an issue though with the keyword parameter.
This will return zero actors: ScanCellObjects(43, PlayerREF, 0.0, EBDScriptKeyWord)
This works fine: ScanCellObjects(43, PlayerREF, 0.0)
Checking akActor.hasKeyword(EBDScriptKeyWord) returns true for all the actors I want, so the keyword is definitely there.

Edited by MongoMonk, 07 February 2016 - 10:41 AM.


#24
2Mylent

2Mylent

    Enthusiast

  • Supporter
  • PipPip
  • 181 posts
Bravo and a big "Thank you" for all work. A Skyrim even more fun. Really great job.

#25
Chesko

Chesko

    Resident poster

  • Supporter
  • PipPipPipPipPip
  • 6,385 posts
First, thank you so much for PapyrusUtil. It has enabled features in Campfire and Simply Knock that wouldn't be possible otherwise.

I have a couple of questions:

* Is it best practice to require users to download PapyrusUtil separately, or is bundling certain components with the mod (personally, I use JsonUtil a lot) OK? The permissions section has no data so I wanted to be sure.

* If old PapyrusUtil components (say, 3.1) are bundled in a mod, and then a user loads PapyrusUtil as a separate mod and places it at the end of their load order, will the mod in question inherit the latest changes and bug fixes? Since the components in question will be overridden / replaced, I'm inclined to say "yes" (assuming the API doesn't change), but again, wanted to make sure.

Thanks!

Edited by Chesko, 08 February 2016 - 05:27 AM.


#26
exiledviper

exiledviper

    Journeyman

  • Premium Member
  • 43 posts
In response to post #34327505.


Spoiler

* I'm not really picky about how it's packaged. Feel free to package it with your mod and just leave a credit or link users here listing it as a separate dependency. I understand the desire to keep the install process short for users by not requiring them to install to many other seperate mods as dependencies.

On the other hand though, I will say my biggest annoyance when dealing with support for my other mod (SL) is users complaining that it's telling them their PapyrusUtil install is outdated because they've recently installed another mod that has an older version bundled- this is apparently incredibly cryptic going by how often I see it. That's my problem though, not yours. Do whatever you think best for your users.

---

* Versions are rarely not backwards or forwards compatible. The syntax for any functions rarely, if ever, changes. If a new versions syntax for a function does have to change for some reason, it's done under a new function name so it doesn't break any compatibility with existing mods. You're fine to develop on 3.1 or older, then in the majority of cases throw in 3.2 later without having to recompile anything. Same applies vice versa, if you develop in and bundle 3.2, if a user overrides it with 3.1 there shouldn't be any problems (other than the possible obvious bug/performance regression) so long as you didn't use any functions that were added by 3.2+ specifically.

#27
exiledviper

exiledviper

    Journeyman

  • Premium Member
  • 43 posts
In response to post #33712640. #33874685, #33903910, #33952360, #33969230, #34150190, #34152155, #34258015, #34291360 are all replies on the same post.


Spoiler

Will look into the keyword issue, and possibly just add an updated actor scan function that has a bool parameter for including/ignoring dead actors.

#28
Chesko

Chesko

    Resident poster

  • Supporter
  • PipPipPipPipPip
  • 6,385 posts
In response to post #34327505. #34367225 is also a reply to the same post.


Spoiler

Thanks for the clarification!

#29
SwitchbackNexus

SwitchbackNexus

    Regular

  • Account closed
  • PipPip
  • 50 posts
Thanks to this I can have Simply Knock, SL Framework AND Campfire without any restrictions!

Godbless you sir. ^^

#30
qiemem

qiemem

    Newbie

  • Supporter
  • Pip
  • 19 posts
This is such a fantastic collection of well-thought out utility functions. Thank you so much!

I do have a few questions relating to best practices around StorageUtil (with ObjKeys). I have a few spells that add values to actors and I want to make sure I clean up the values correctly. The spell unsets the values after a specified amount of time, but if it gets dispelled, the player leaves the area, or the actor dies, this doesn't happen. So, my questions are:

1. If an actor is killed, are the values that have them as their ObjKey automatically cleared? I did notice that the actor's body is removed correctly on cell reset, but I wanted to make sure the value itself was cleared as well.
2. If the cell containing the actor is reset, are the values associated with that actor cleared?
3. Is calling `StorageUtil.ClearAllPrefix(<my mod's prefix> ) ` a good way of clearing all stored values when my mod is uninstalled?

Any general recommendations for cleaning up safely?

Edited by qiemem, 23 February 2016 - 03:26 PM.





Page loaded in: 0.862 seconds