Jump to content

How to access SKSE member forms / objects?


JMSFedaykin

Recommended Posts

Howdy Everybody!

 

Right now I need to make use of the DefaultObjectManager to solve the problems I'm having. But the only way I can access it is through SKSE. So, how do I actually make use of SKSE objects? I've got it installed but these are the errors I get with my code as it stands, right now.

 

First, I tried putting this line up towards the top with all of my variables and properties (outside of any functions and events):

DefaultObjectManager kDefObjMan = Game.GetFormFromFile(0x00000031, "Skyrim.esm") as DefaultObjectManager 

And the compiler barfs after Game, because it's my understanding that GetFormFromFile has to be inside an event?

 

So, I split it to this:

DefaultObjectManager kDefObjMan

Event OnInit()
     kDefObjMan = Game.GetFormFromFile(0x00000031, "Skyrim.esm") as DefaultObjectManager
EndEvent

When I do that, the first, fundamental error I get is that DefaultObjectManager is an unknown type. I'm guessing because DefaultObjectManager requires SKSE?

 

So, my question is how do I get access to SKSE objects? If this were something like C#, I'd just put it in an include at the beginning of the file. But I've got no clue what I need to do with Papyrus. And trying to find any information on how to use SKSE is like trying to find a needle in a stack of "How to install SKSE" needles...

Link to comment
Share on other sites

Double check to make sure you have installed all skse source files. they should be in your data\scripts\Source. Papyrus has access to all files in the source folder you don't need to include them like in C# or C++.

Link to comment
Share on other sites

Doesn't look right what your trying to do.
I'm unsure of the objectmanager in SKSE ( or in game so I have no idea).
But using my logic (which is probably flawed) and reading the DefaultObjectManager.psc script it looks like your trying to use it the wrong way to what it's for.

Basically you can:
Returns the default form for this key
pure assumption example (I really have no idea, but this is what my logic deciphers it as):

Form WerewolfSpell = DefaultObjectManager.GetForm("WWSP")

Or

Sets the default form for the particular key.
DefaultObjectManager.SetForm(WWSP, 0xXXXXXXXX)

Just check out the DefaultObjectManager.psc as it has a list of all the valid string keys you can use with the 2 functions
Link to comment
Share on other sites

Thanks for the advice, but I was pretty sure the rest of my usage was fine. What I was having trouble with was actually getting the DefaultObjectManager object. You have to set a variable to be an instance of the DefaultObjectManager. Then you call the functions using them attached to that variable. At least that's how I understand it. So for example, this actually worked (once I had the SKSE source scripts installed):

DefaultObjectManager kDefObjMan

Event OnInit()
     kDefObjMan = Game.GetFormFromFile(0x00000031, "Skyrim.esm") as DefaultObjectManager
EndEvent

Function <FunctionWhereYouNeedToSetValues>()
     kDefObjMan.SetForm("<formKey>", <FormYouWantToSetItTo>)
EndFunction
Link to comment
Share on other sites

It's funny how I perceive things,my logic would have been along these lines.

The same way I'd call any other SKSE native functions

Form kDefObjMan

Event OnInit()
     kDefObjMan = Game.GetFormFromFile(0x00000031, "Skyrim.esm")
EndEvent

Function <FunctionWhereYouNeedToSetValues>()
    DefaultObjectManager.SetForm("<formKey>", kDefObjMan)
EndFunction
Link to comment
Share on other sites

  On 7/29/2015 at 6:20 PM, sLoPpYdOtBiGhOlE said:

 

It's funny how I perceive things,my logic would have been along these lines.

The same way I'd call any other SKSE native functions

 

SKSE adds both global and non-global functions. Global functions, which follow the logic that you described, can be called without the need to have an instance of that script/class (e.g. Debug.Notification, UI.IsMenuOpen) while non-global functions have to be called on instances of a script/class (e.g. Actor.GetLevel, DefaultObjectManager.GetForm).

 

JMSFedaykin's approach is correct (the line appears to be from the relevant CK wiki article, which I updated several months ago when I ended up using DefaultObjectManager in a mod). GetFormFromFile is not the only function that cannot be called outside of an event or another function. No functions or events can be called outside of an event or function.

Edited by mrpwn
Link to comment
Share on other sites

  • Recently Browsing   0 members

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