Jump to content

simple scripting help, please!


Recommended Posts

I can't seem to get GetType() to work for me. Can anyone see anything obvious in the following code?

 

 

Scriptname _0BooksStorage extends ObjectReference

 

FormList Property _0FLSTBooks Auto

 

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

if ((akBaseItem.GetType() == 27) && (akBaseItem.GetType() != 48))

_0FLSTBooks.AddForm(akBaseItem)

endif

EndEvent

 

 

Basically, the use of the GetType() function is to only add books (type 27) to the form list and not notes (type 48).

The script compiles just fine and the rest of it works in-game (it's really not that much longer than what's included here). But both books and notes are added to the form list in-game.

Edited by danielleonyett
Link to comment
Share on other sites

http://www.creationkit.com/GetType_-_Form

says notes are 48 and books are 27

I had thought about differentiating by weight, but that wouldn't necessarily work if a mod adds weight to notes/papers.

I had also thought about trying to see the model path to determine if the name of the nif file has "note" in it. But, again, other mods might not use the same naming conventions.

Using a size measurement might be the best idea so far. I'll look into that!

But it still makes me wonder why this skse function isn't working for me. I've just recently started scripting and I think this is the 1st skse function that I've tried using. So I think I'm going to have to try other skse functions to see if it's an skse problem for me, or if it's just this particular function.

thanks!

Link to comment
Share on other sites

Maybe you could use skse GetWorldModelPath() and stringutil Find.
There's only 6 note models types in base skyrim all have the word "note" in the model name.

Basically you could use the string "note" to find in the model path, if so then it's a note.

eg (compiled fine, but I've not tested it):

Scriptname _0BooksStorage extends ObjectReference

FormList Property _0FLSTBooks Auto

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
    If (akBaseItem As Book) && (StringUtil.Find(akBaseItem.GetWorldModelPath(), "note") < 0)
        _0FLSTBooks.AddForm(akBaseItem)
    EndIf
EndEvent

But that will also filter out Recipes as they also use a note model.
Also it doesn't really allow for DLC or Mods that may add new Note Models that may not have the string "note" in the model name/path (haven't checked the vanilla DLCs to see if they add any note models).

Edited by sLoPpYdOtBiGhOlE
Link to comment
Share on other sites

@sLoPpYdOtBiGhOlE

thanks, I mentioned in one of my posts above that mods might not use the same naming conventions for their models.

so I don't think it matters how I do it, there will inevitably be a chance that something will slip by.

but I'm still puzzled as to why gettype() won't work for me. I have yet to try any other skse functions yet though. if I find that I can't get any of them to work then i'll probably post a new topic!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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