Difference between revisions of "NVC Tutorial"
Jump to navigation
Jump to search
imported>Speedo (Created) |
imported>Speedo (updated) |
||
Line 6: | Line 6: | ||
*Save some basic info about each item: FormID and count of that item in the inventory | *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 | *Save some basic stats for the item in a child container "<name>\Stats": OBSE item type, gold value and weight | ||
*Once all data has been assembled, output the container as both text and XML. | |||
==The Script== | ==The Script== | ||
Line 16: | Line 17: | ||
int con | int con | ||
string_var tempStr | |||
int tempInt | int tempInt | ||
Line 28: | Line 28: | ||
if (IsContainer || IsActor) | if (IsContainer || IsActor) | ||
set con to nvcNew | set con to nvcNew | ||
set | set tempStr to sv_Construct "%e" | ||
set index to 0 | set index to 0 | ||
Line 44: | Line 43: | ||
set tempRef to GetInventoryObject index | set tempRef to GetInventoryObject index | ||
sv_Set "%n" tempRef tempStr | |||
if (nvcChildExists con 0 | if (nvcChildExists con 0 tempStr == 0) | ||
nvcSetRef tempRef con "FormID" 0 0 tempStr | |||
set tempInt to GetItemCount tempRef | set tempInt to GetItemCount tempRef | ||
nvcSetInt tempInt con "Count" 0 0 tempStr | |||
sv_Set "%z\Stats" tempStr tempStr | |||
set tempInt to GetObjectType tempRef | set tempInt to GetObjectType tempRef | ||
nvcSetInt tempInt con "Type" 0 0 tempStr | |||
set tempFloat to GetWeight tempRef | set tempFloat to GetWeight tempRef | ||
nvcSetFloat tempFloat con "Weight" 0 0 tempStr | |||
set tempInt to GetFullGoldValue tempRef | set tempInt to GetFullGoldValue tempRef | ||
nvcSetInt tempInt con "Value" 0 0 tempStr | |||
endif | endif | ||
Line 76: | Line 69: | ||
set tempRef to GetSelf | set tempRef to GetSelf | ||
sv_Set "%n Inventory.txt" tempRef tempStr | |||
nvcPrintToFile con 0 -1 tempStr | |||
nvcPrintToFile con 0 -1 | sv_Replace ".txt|.xml" tempStr | ||
nvcSaveToXml con 0 tempStr | |||
nvcDel con | nvcDel con | ||
set tempStr to sv_Destruct | |||
else | else | ||
Line 91: | Line 84: | ||
==Sample Output== | ==Sample Output== | ||
Output from a | Output from a Goblin: | ||
===Text File Output=== | |||
<pre> | <pre> | ||
Container | Container 5 | ||
Owner | Owner 01 | ||
Protected | Protected | ||
Item Count = | Item Count = 4 <int> | ||
Base FormID = | Base FormID = 00084B29 <ref> | ||
FormID = | FormID = FF00080F <ref> | ||
Iron Arrow\ | |||
Count = | Count = 5 <int> | ||
FormID = | FormID = 00017829 <ref> | ||
Stats\ | Stats\ | ||
Type = | Type = 34 <int> | ||
Value = 1 <int> | Value = 1 <int> | ||
Weight = 0. | Weight = 0.1000000 <float> | ||
Iron Bow\ | |||
Count = 1 <int> | Count = 1 <int> | ||
FormID = | FormID = 00025231 <ref> | ||
Stats\ | Stats\ | ||
Type = | Type = 33 <int> | ||
Value = | Value = 11 <int> | ||
Weight = | Weight = 8.0000000 <float> | ||
Lockpick\ | |||
Count = 1 <int> | Count = 1 <int> | ||
FormID = | FormID = 0000000A <ref> | ||
Stats\ | Stats\ | ||
Type = | Type = 27 <int> | ||
Value = | Value = 3 <int> | ||
Weight = | Weight = 0.0000000 <float> | ||
Rusty Iron Mace\ | |||
Count = 1 <int> | Count = 1 <int> | ||
FormID = | FormID = 00090614 <ref> | ||
Stats\ | Stats\ | ||
Type = 33 <int> | Type = 33 <int> | ||
Value = | Value = 6 <int> | ||
Weight = | Weight = 15.0000000 <float> | ||
</pre> | |||
===XML File Output=== | |||
<pre> | |||
Value = 0 <int> | <?xml version="1.0" ?> | ||
Weight = | <container version="1" /> | ||
<int> | |||
<value name="Item Count" data="4" /> | |||
</int> | |||
<ref> | |||
<value name="Base FormID" data="00084B29" esp="Oblivion.esm" /> | |||
<value name="FormID" data="00000000" esp="<none>" /> | |||
</ref> | |||
<child name="Iron Arrow"> | |||
<int> | |||
<value name="Count" data="5" /> | |||
</int> | |||
<ref> | |||
<value name="FormID" data="00017829" esp="Oblivion.esm" /> | |||
</ref> | |||
<child name="Stats"> | |||
<int> | |||
<value name="Type" data="34" /> | |||
<value name="Value" data="1" /> | |||
</int> | |||
<float> | |||
<value name="Weight" data="0.100000" /> | |||
</float> | |||
</child> | |||
</child> | |||
<child name="Iron Bow"> | |||
<int> | |||
<value name="Count" data="1" /> | |||
</int> | |||
<ref> | |||
<value name="FormID" data="00025231" esp="Oblivion.esm" /> | |||
</ref> | |||
<child name="Stats"> | |||
<int> | |||
<value name="Type" data="33" /> | |||
<value name="Value" data="11" /> | |||
</int> | |||
<float> | |||
<value name="Weight" data="8.000000" /> | |||
</float> | |||
</child> | |||
</child> | |||
<child name="Lockpick"> | |||
<int> | |||
<value name="Count" data="1" /> | |||
</int> | |||
<ref> | |||
<value name="FormID" data="0000000A" esp="Oblivion.esm" /> | |||
</ref> | |||
<child name="Stats"> | |||
<int> | |||
<value name="Type" data="27" /> | |||
<value name="Value" data="3" /> | |||
</int> | |||
<float> | |||
<value name="Weight" data="0.000000" /> | |||
</float> | |||
</child> | |||
</child> | |||
<child name="Rusty Iron Mace"> | |||
<int> | |||
<value name="Count" data="1" /> | |||
</int> | |||
<ref> | |||
<value name="FormID" data="00090614" esp="Oblivion.esm" /> | |||
</ref> | |||
<child name="Stats"> | |||
<int> | |||
<value name="Type" data="33" /> | |||
<value name="Value" data="6" /> | |||
</int> | |||
<float> | |||
<value name="Weight" data="15.000000" /> | |||
</float> | |||
</child> | |||
</child> | |||
</pre> | </pre> | ||
[[Category:NVC]] | [[Category:NVC]] |
Revision as of 11:22, 15 November 2008
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
- Once all data has been assembled, output the container as both text and XML.
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 string_var tempStr int tempInt float tempFloat ref tempRef int index begin ScriptEffectStart if (IsContainer || IsActor) set con to nvcNew set tempStr to sv_Construct "%e" 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 sv_Set "%n" tempRef tempStr if (nvcChildExists con 0 tempStr == 0) nvcSetRef tempRef con "FormID" 0 0 tempStr set tempInt to GetItemCount tempRef nvcSetInt tempInt con "Count" 0 0 tempStr sv_Set "%z\Stats" tempStr tempStr set tempInt to GetObjectType tempRef nvcSetInt tempInt con "Type" 0 0 tempStr set tempFloat to GetWeight tempRef nvcSetFloat tempFloat con "Weight" 0 0 tempStr set tempInt to GetFullGoldValue tempRef nvcSetInt tempInt con "Value" 0 0 tempStr endif set index to index + 1 if (index < GetNumItems) goto 0 endif set tempRef to GetSelf sv_Set "%n Inventory.txt" tempRef tempStr nvcPrintToFile con 0 -1 tempStr sv_Replace ".txt|.xml" tempStr nvcSaveToXml con 0 tempStr nvcDel con set tempStr to sv_Destruct else PrintC "Object is not a container" endif end
Sample Output
Output from a Goblin:
Text File Output
Container 5 Owner 01 Protected Item Count = 4 <int> Base FormID = 00084B29 <ref> FormID = FF00080F <ref> Iron Arrow\ Count = 5 <int> FormID = 00017829 <ref> Stats\ Type = 34 <int> Value = 1 <int> Weight = 0.1000000 <float> Iron Bow\ Count = 1 <int> FormID = 00025231 <ref> Stats\ Type = 33 <int> Value = 11 <int> Weight = 8.0000000 <float> Lockpick\ Count = 1 <int> FormID = 0000000A <ref> Stats\ Type = 27 <int> Value = 3 <int> Weight = 0.0000000 <float> Rusty Iron Mace\ Count = 1 <int> FormID = 00090614 <ref> Stats\ Type = 33 <int> Value = 6 <int> Weight = 15.0000000 <float>
XML File Output
<?xml version="1.0" ?> <container version="1" /> <int> <value name="Item Count" data="4" /> </int> <ref> <value name="Base FormID" data="00084B29" esp="Oblivion.esm" /> <value name="FormID" data="00000000" esp="<none>" /> </ref> <child name="Iron Arrow"> <int> <value name="Count" data="5" /> </int> <ref> <value name="FormID" data="00017829" esp="Oblivion.esm" /> </ref> <child name="Stats"> <int> <value name="Type" data="34" /> <value name="Value" data="1" /> </int> <float> <value name="Weight" data="0.100000" /> </float> </child> </child> <child name="Iron Bow"> <int> <value name="Count" data="1" /> </int> <ref> <value name="FormID" data="00025231" esp="Oblivion.esm" /> </ref> <child name="Stats"> <int> <value name="Type" data="33" /> <value name="Value" data="11" /> </int> <float> <value name="Weight" data="8.000000" /> </float> </child> </child> <child name="Lockpick"> <int> <value name="Count" data="1" /> </int> <ref> <value name="FormID" data="0000000A" esp="Oblivion.esm" /> </ref> <child name="Stats"> <int> <value name="Type" data="27" /> <value name="Value" data="3" /> </int> <float> <value name="Weight" data="0.000000" /> </float> </child> </child> <child name="Rusty Iron Mace"> <int> <value name="Count" data="1" /> </int> <ref> <value name="FormID" data="00090614" esp="Oblivion.esm" /> </ref> <child name="Stats"> <int> <value name="Type" data="33" /> <value name="Value" data="6" /> </int> <float> <value name="Weight" data="15.000000" /> </float> </child> </child>