NifClose

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

This is a command from NifSE.

Syntax

(bool:success) NifClose short:nifID

Indicates to NifSE that the NIF is no longer being used; it will be wiped from NifSE's memory and will not be saved in savegames.

Will cause missing mesh markers to appear if the mesh is still being used by any visible references.

Example

As an example of using NifSE, consider this code:

ref playerWeapon
string_var filepath
short nifID

Begin GameMode

  if ( playerWeapon != player.GetEquippedObject 16 )
    if ( playerWeapon )
      let filepath := NifGetOriginalPath nifID
      SetModelPath $filepath playerWeapon
      NifClose nifID
    endif
    let playerWeapon := player.GetEquippedObject 16
    let filepath := GetModelPath playerWeapon
    let nifID := NifOpen $filepath 1
    let filepath := NifGetPath nifID
    SetModelPath $filepath playerWeapon
  endif

End

Every time the player equips a new weapon, creates a copy of the weapon's model that can be edited using NifSE, and sets the weapon's model to the copy. If a previous weapon had been affected, sets that weapon's model back to its original file, and closes that nif in NifSE. From here, one would presumably have further blocks dedicated to determining when to apply various changes using the other NifSE functions.

Note[edit | edit source]

  • In some cases, closed NIFs will still be included in savegames, if other NIFs are dependent on them (for example, if NiNodeCopyChild was used to copy a branch from this NIF to another). NifSE will save only exactly as much information as is necessary to correctly recreate the mesh that was copied to when reloading the game. If the mesh that requires a NIF is closed, then any savedata retained for the purpose of recreating it will be discarded in future saves.

See Also[edit | edit source]