Author Topic: Obtaining All Variables On An Object By Script  (Read 589 times)

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Obtaining All Variables On An Object By Script
« on: February 04, 2016, 08:19:23 pm »


               

Is it possible to create a tool that when used on an item in game, will return the variable's and their names a message to the PC? I've been fumbling about trying to create code that can do this for a while now.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Obtaining All Variables On An Object By Script
« Reply #1 on: February 04, 2016, 09:09:26 pm »


               

If you know the names and types of all of the variables you care about it's easy. If you don't know that information you need NWNX.  The Linux version of nwnx_funcs for example has these:



/* Get the first local variable from an object. */
struct LocalVariable GetFirstLocalVariable (object oObject);

/* Get the next local variable from an object. */
struct LocalVariable GetNextLocalVariable (struct LocalVariable lv);

               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Obtaining All Variables On An Object By Script
« Reply #2 on: February 04, 2016, 09:12:04 pm »


               

It can not be done in vanilla nwn script.   There is a way to do it with nwnx,  But I have never used nwnx.  


 


 


If you are just looking for a way to see the variables on an object you can do that by saving the game. then opening the game in the toolset.   



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Obtaining All Variables On An Object By Script
« Reply #3 on: February 04, 2016, 11:36:03 pm »


               If this is for debugging, I imagine you could analyse a saved game using moneo.


You mention "the PC" so I guess you mean SP, for which NWNX isn't available!
               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Obtaining All Variables On An Object By Script
« Reply #4 on: February 05, 2016, 02:13:38 am »


               

If this is for debugging, I imagine you could analyse a saved game using moneo.

You mention "the PC" so I guess you mean SP, for which NWNX isn't available!


If its for a single player module, saved or otherwise, there are no variables stored on items unless you are launching it as a server and using server vault PCs. Variables aren't saved onto items in local vault uses.
               
               

               
            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Obtaining All Variables On An Object By Script
« Reply #5 on: February 05, 2016, 03:25:30 am »


               

Solid info, thanks guys!


 


EDIT: Are you saying you can't store variables on items in Single Player Modules... at all? Including by script?



               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Obtaining All Variables On An Object By Script
« Reply #6 on: February 05, 2016, 06:01:46 am »


               

Solid info, thanks guys!
 
EDIT: Are you saying you can't store variables on items in Single Player Modules... at all? Including by script?


I you launch the games as a server/LAN and join using a server vault PC it works. Variables however don't get written to items when using a local vault PC (or for DM Avatars in MP).
               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Obtaining All Variables On An Object By Script
« Reply #7 on: February 05, 2016, 08:05:37 am »


               

If its for a single player module, saved or otherwise, there are no variables stored on items unless you are launching it as a server and using server vault PCs. Variables aren't saved onto items in local vault uses.

I did a test which seems to disprove this.

On acquiring an item in SP, I set a local int. Put it down on the ground. Save. Open the save container with NWN Explorer. The area .git file has List > Entry 1 for the item, which has a Var_Table with the Name, Type and Value of the local int.

In game, loading the saved file and picking up the item again, the script recognizes that the variable is already set.

Incidentally, this use of NWN Explorer might satisfy the OP, if the number of items to examine is small.

Remember, we're talking about saving a game, not exporting a character (which might be different).

Perhaps I'm missing something?
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Obtaining All Variables On An Object By Script
« Reply #8 on: February 05, 2016, 02:16:27 pm »


               

No. That's right. Variables work on items just fine in SP. They just don't export with the exported character I think.  As long as you are looking at them in game or in a saved game they will be there. Otherwise all sorts of things would not work that do work ...