User:DavidJCobb

From the CreationKit Wiki
Revision as of 22:34, 9 January 2015 by imported>DavidJCobb
Jump to navigation Jump to search

My work

Rotation library
A library for working with rotations in Skyrim. If you need to position and rotate one object relative to another, this'd be the code to do that.

Current projects

Atronach Crossing
A home decoration mod with a dual focus on customization and usability. Currently in early development. Already features many "firsts" in Skyrim, such as bookshelves that can be moved around at run-time.

Scratchpad

  • Import is unreliable, and I don't know what makes it break. It works in some cases, but in others, it completely fails to import global functions from the target file.
    • Errors will not be generated when compiling in the Creation Kit. You'll only be able to detect the problem by checking the Papyrus logs, which will contain something like
      Error: Method ImportedFunctionName not found on EntityThatHasAScriptThatImportsStuff. Aborting call and returning None
    • It's consistent: if it doesn't work for a file, then it will probably never work for that file (barring massive changes).
    • You can work around this by referencing all functions in the script to be imported as methods, e.g. ScriptToBeImported.FunctionName().

Miscellaneous tips

  • This page contains two useful pieces of information:
    • Description of "dumping stacks" errors in the Papyrus log
    • Advice for modders: how to detect deleted forms, e.g. if your mod has a reference to a Form that belongs to another mod, and that mod has just been uninstalled. Detecting this and handling it properly is trickier than you might think.
  • Changes to the player's SpeedMult actor value don't take effect immediately. In order to update the player's effective movement speed after changing the actor value, you must use one of two methods:
    • Modify the player's inventory (e.g. add and then immediately remove an item)
    • Modify the player's carry weight (e.g. add and remove 0.1 to that actor value)

Code snippets

Quality? Functionality? Efficiency? Here, I guarantee nothing!!

Is an ObjectReference an item?

Works as well as is possible given the methods available to us.

Bool Function IsItem(ObjectReference akObject)
   Form akForm = akObject.GetBaseObject()
   If !akForm
      return false
   EndIf
   If akForm as Book
      ;
      ; SKSE grants read access to the Playable flag for books.
      ;
      return (akForm as Book).IsTakeable()
   EndIf
   If (akForm as Ammo) || (akForm as Armor) || (akForm as Ingredient) || (akForm as Key) || (akForm as MiscObject) || (akForm as Potion) || (akForm as Scroll) || (akForm as SoulGem) || (akForm as Weapon)
      ;
      ; Other object types don't have a script-accessible player flag. Sux.
      ;
      return true
   EndIf
   return false
EndFunction