NVC Tutorial
Revision as of 22:26, 3 November 2008 by imported>Speedo (Created)
This tutorial shows a simple example taking advantage of NVC's capabilities to create a spell script which can dump some basic info about a in-game container or actor's inventory contents to a text file for examination out of game.
Goals
- Save some basic info about the object: FormID, Base FormID, total item count
- Information about each item should be saved in a seperate child container with the name of that item
- Save some basic info about each item: FormID and count of that item in the inventory
- Save some basic stats for the item in a child container "<name>\Stats": OBSE item type, gold value and weight
The Script
To use this script, simply save it as a spell effect, create a spell which uses it and then add that spell to the player.
Note that this script requires Pluggy; its string functions are used to retrieve the item's name and to name the output file.
scn nvcExampleSpellScript int con int key int loc int tempInt float tempFloat ref tempRef int index begin ScriptEffectStart if (IsContainer || IsActor) set con to nvcNew set key to CreateString -1 0 1 1 set loc to CreateString -1 0 1 1 set index to 0 set tempRef to GetSelf nvcSetRef tempRef con "FormID" set tempRef to GetBaseObject nvcSetRef tempRef con "Base FormID" set tempInt to GetNumItems nvcSetInt tempInt con "Item Count" label 0 set tempRef to GetInventoryObject index StringGetName tempRef loc if (nvcChildExists con 0 1 loc == 0) SetString key "FormID" nvcSetRef tempRef con 0 0 1 key loc set tempInt to GetItemCount tempRef SetString key "Count" nvcSetInt tempInt con 0 0 1 key loc SetString key "\Stats" StringCat loc key set tempInt to GetObjectType tempRef SetString key "Type" nvcSetInt tempInt con 0 0 1 key loc set tempFloat to GetWeight tempRef SetString key "Weight" nvcSetFloat tempFloat con 0 0 1 key loc set tempInt to GetFullGoldValue tempRef SetString key "Value" nvcSetInt tempInt con 0 0 1 key loc endif set index to index + 1 if (index < GetNumItems) goto 0 endif set tempRef to GetSelf StringGetName tempRef key SetString loc " Inventory.txt" StringCat key loc nvcPrintToFile con 0 -1 1 key nvcDel con DestroyString key DestroyString loc else PrintC "Object is not a container" endif end
Sample Output
Output from a Legion Soldier:
Container 6 Owner 02 Protected Item Count = 13 <int> Base FormID = 000700C6 <ref> FormID = 000700F3 <ref> Flax Tunic\ Count = 1 <int> FormID = 0002C0FA <ref> Stats\ Type = 22 <int> Value = 1 <int> Weight = 1.0000000 <float> Gold\ Count = 3 <int> FormID = 0000000F <ref> Stats\ Type = 27 <int> Value = 1 <int> Weight = 0.0000000 <float> Laced Leather Pants\ Count = 1 <int> FormID = 000229AB <ref> Stats\ Type = 22 <int> Value = 1 <int> Weight = 1.0000000 <float> Legion Boots\ Count = 1 <int> FormID = 00028ADE <ref> Stats\ Type = 20 <int> Value = 50 <int> Weight = 10.5000000 <float> Legion Cuirass\ Count = 1 <int> FormID = 00028ADF <ref> Stats\ Type = 20 <int> Value = 180 <int> Weight = 35.0000000 <float> Legion Gauntlets\ Count = 1 <int> FormID = 00028AE0 <ref> Stats\ Type = 20 <int> Value = 50 <int> Weight = 7.0000000 <float> Legion Greaves\ Count = 1 <int> FormID = 00028AE1 <ref> Stats\ Type = 20 <int> Value = 95 <int> Weight = 21.0000000 <float> Legion Helmet\ Count = 1 <int> FormID = 00028AE2 <ref> Stats\ Type = 20 <int> Value = 50 <int> Weight = 7.0000000 <float> Legion Shield\ Count = 1 <int> FormID = 000352D3 <ref> Stats\ Type = 20 <int> Value = 95 <int> Weight = 14.0000000 <float> Mutton\ Count = 4 <int> FormID = 00033686 <ref> Stats\ Type = 25 <int> Value = 2 <int> Weight = 2.0000000 <float> Sack Cloth Sandals\ Count = 1 <int> FormID = 0002731A <ref> Stats\ Type = 22 <int> Value = 1 <int> Weight = 2.0000000 <float> Silver Longsword\ Count = 1 <int> FormID = 0002521F <ref> Stats\ Type = 33 <int> Value = 125 <int> Weight = 28.0000000 <float> Torch\ Count = 1 <int> FormID = 0002CF9F <ref> Stats\ Type = 26 <int> Value = 0 <int> Weight = 0.0000000 <float>