Property names

Post » Sun Feb 09, 2014 8:47 am

Is it possible to get the names of properties that of a script?

So that i would be able to do something like this:

Script myScript extends anotherScriptint Property prop1 = 1234 Autostring Property prop2 Auto

and then call something like

myProperties = myScript.getPropertyNames() 

which would return an array

["prop1", "prop2"]

and then get the values of those properties by using something like

myScript.getProperty(myProperties[1]);=> 1234

To put this into more context: I'm trying to create a mod that implements the capabilities of http://www.nexusmods.com/skyrim/mods/48265/ into http://www.nexusmods.com/skyrim/mods/3863/?. What I want to do is get all properties from a mod's MCM script, and store their name and value in an xml file using FISS to essentially allow saving MCM configurations and loading them between saves.

User avatar
Kelly Osbourne Kelly
 
Posts: 3426
Joined: Sun Nov 05, 2006 6:56 pm

Post » Sun Feb 09, 2014 11:30 am

to answer your question, no, its not possible to get properties without knowing their names ahead of time.

in broader terms, I also considered doing this very same thing, somehow implementing fiss so it could work for any mod. However there are serious challenges to this idea. for instance, many mod MCM options do much more than simply changing a value when the user selects them, they also may call many functions and events, start quests, or do a number of other things in response to user input that cannot be easily tracked or replicated. the best way I could think to implement this would be to call the option event explicitly with the saved value.

however, more problems:
1) text options may have no value associated with them and could act only as a toggle affecting other options, their values may not even be stored in properties, but could be local only. same for other option types.
2) this would somehow require hooking into SkyUI itself to figure out which option events are called for each MCM setting of the mod, which would probably require altering the SkyUI action script itself so that it records these events.
3) a lot of other problems I surely havent thought hard enough to figure out yet

In short, you could go ahead and make this, but its unlikely to work as expected for many mods, particularly mods with bigger or more complex MCM menus
User avatar
Heather beauchamp
 
Posts: 3456
Joined: Mon Aug 13, 2007 6:05 pm

Post » Sun Feb 09, 2014 7:27 pm

thanks! seeing how this is (would be) my first papyrus project, it seems i'm not able (yet) to pull this one off... i don't really understand the problems you elaborate on (a little though) but it from what i understand, implementations may differ from modder to modder, so there's too many things to account for. thanks for the explanation!

User avatar
IsAiah AkA figgy
 
Posts: 3398
Joined: Tue Oct 09, 2007 7:43 am

Post » Sun Feb 09, 2014 2:22 pm

MCM is not designed for this kind of thing. The framework itself keeps no state other than mod names (state = evil :smile: or well, it makes things easier doing it this way). AddBlahOption is more like drawing onto a canvas than registering data.
How to store the actual configuration data is up to each mod, which makes it flexible and easy to integrate.

Automagically converting all existing MCM menus to support persistence could only be done at low level, i.e. persist actual script state and restore it, but even that would probably not be enough, since globals can hold data as well.

Integrated support for persistence in a future MCM version would require a redesign to include mandatory mechanisms for data storage.
But that's only going to happen for the next game, changing the established API at this point would be unwise. And frankly, I think the current API works pretty well, though I understand that from a user perspective, having to re-configure everything on each new character is annoying.

The alternative would be providing an optional API - but that's already there (FISS).
So, in summary: Automatically adding support for data persistence to all existing MCM menus is pretty much impossible. Doing it manually is possible and tools for that exist.
User avatar
Prue
 
Posts: 3425
Joined: Sun Feb 11, 2007 4:27 am

Post » Sun Feb 09, 2014 1:00 pm

Thanks again for the explanation. I completely agree that changing the existing API would be bad, and might cause more harm than good.

I'm currently doing it manually for mods that I use and aren't that complex. Might even contact those authors to implement it in their own mod so they don't have to anymore.

And thanks for making the mod configs possible at all :) I remember the oblivion days and the hassle with .ini files. God that was a mess

User avatar
Dina Boudreau
 
Posts: 3410
Joined: Thu Jan 04, 2007 10:59 pm


Return to V - Skyrim