Difference between revisions of "NifOpen"
imported>DragoonWraith |
imported>DragoonWraith |
||
Line 4: | Line 4: | ||
(short:NifID) NifOpen string:FilePath ''bool:writable'' | (short:NifID) NifOpen string:FilePath ''bool:writable'' | ||
Opens a .nif 3D mesh file for reading, or if the optional bool is true, editing. Returns a unique identifier which may be passed to other NifSE functions in order to refer to the mesh. | Opens a .nif 3D mesh file for reading, or if the optional bool is true, editing. Returns a unique identifier which may be passed to other NifSE functions in order to refer to the mesh. If opening the mesh fails for whatever reason, the return value is -1. | ||
{{NifSE Example}} | {{NifSE Example}} | ||
== Notes == | == Notes == | ||
* In NifSE v1.0 α1.2, NifOpen returns 0 on a failed nif. This can lead to a script not knowing that a mesh failed and attempting to perform operations on it; these operations may be performed on the actual 0th index nif, which may be entirely undesired. | |||
* The file path must be relative to the <tt>Oblivion\Data\Meshes\</tt> folder. This is the same scheme as used by similar [[:Category:Oblivion Script Extender|OBSE]] functions. | * The file path must be relative to the <tt>Oblivion\Data\Meshes\</tt> folder. This is the same scheme as used by similar [[:Category:Oblivion Script Extender|OBSE]] functions. | ||
* NifSE creates a copy of the indicated .nif file when you request a writable nif, and the nif you are actually editing is that nif. The original nif is not altered in any way. You can get the file path of the copy with [[NifGetPath]]. | * NifSE creates a copy of the indicated .nif file when you request a writable nif, and the nif you are actually editing is that nif. The original nif is not altered in any way. You can get the file path of the copy with [[NifGetPath]]. |
Revision as of 13:40, 23 June 2010
This is a command from NifSE.
Syntax
(short:NifID) NifOpen string:FilePath bool:writable
Opens a .nif 3D mesh file for reading, or if the optional bool is true, editing. Returns a unique identifier which may be passed to other NifSE functions in order to refer to the mesh. If opening the mesh fails for whatever reason, the return value is -1.
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.
Notes
- In NifSE v1.0 α1.2, NifOpen returns 0 on a failed nif. This can lead to a script not knowing that a mesh failed and attempting to perform operations on it; these operations may be performed on the actual 0th index nif, which may be entirely undesired.
- The file path must be relative to the Oblivion\Data\Meshes\ folder. This is the same scheme as used by similar OBSE functions.
- NifSE creates a copy of the indicated .nif file when you request a writable nif, and the nif you are actually editing is that nif. The original nif is not altered in any way. You can get the file path of the copy with NifGetPath.