Author Topic: nwnx - loading external data to nwn  (Read 1414 times)

Legacy_Valgav

  • Full Member
  • ***
  • Posts: 118
  • Karma: +0/-0
nwnx - loading external data to nwn
« on: March 22, 2016, 06:54:46 pm »


               

As we all know nwnx string is the only way to feed nwn with external data. Dosen't matter if you're using sockets, sql, text files you'll always end with nwnx string.


 


My question is how effective it is for large structures? Doing many things outside nwn using object orientated languages is much simpler(it would be even simpler if i could call nwn functions to give parameters, but I have no idea how to hook main loop to call them on fly) and then use method toString() to forward it to nwn. 


 


But then I have to parse the whole string to structure or load it in sequential order during running algorithm in nwn.


 


What are best practices to work with that kind of data flow? What if i have multiple sources at the same time(sockets won't work because you have to send message and then listen for correct one)



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
nwnx - loading external data to nwn
« Reply #1 on: March 22, 2016, 07:30:41 pm »


               

can you provide a more concrete example? are you talking about retrieving data from a DB which you've stored as a custom object that you need to convert into an NWN object?


 


i wouldn't bother which such stuff. I think its easier just to store and retrieve NWN objects.


 


or do you have a need of a very complex persistent data model for all your custom systems? or something else?



               
               

               
            

Legacy_Valgav

  • Full Member
  • ***
  • Posts: 118
  • Karma: +0/-0
nwnx - loading external data to nwn
« Reply #2 on: March 22, 2016, 08:15:48 pm »


               

Problem with storing objects (as for example blobs) is that you can't get info about it any other way than using nwn. You have sword but you don't know what kind of sword. So you should store object and meta and there's no easy way to parse dat data outside nwn(even inside it's terrible, how to store that it has enchanment +2 and 1d6 against undeads when you always work on effects represented by consts.)


 


Also storing other informations like spawns. You cans simply create object or database structure for spawn which contains 5 kobolds with resref kobold_01 two shamans with resref kobold_shaman etc.


 


Then you can load erfs and add info to database to have complete info about objects on your server available from nwn and outside of it.


 


I know that for most people that kind of staff is overkill but it's crucial for modules that have many custom systems and want to maintain flexibility. Using database or external files to feed logic with parameters is best and most universal way to keep all those systems simple.



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
nwnx - loading external data to nwn
« Reply #3 on: March 23, 2016, 03:24:59 am »


               

I understand what you are saying, but you have not given a concrete use case, and you have also overstated the problem. There are ways to read the binary files outside of NWN. You may need to custom code things yourself, or glue existing apps together with NWNX using a scripting language like ruby or perl, but you can read GFFs and ERFs outside of NWN.


 


I believe you are probably somewhat limited with NWNX and other community tools since windows is your preferred server (if I heard you right). But even then you've got resources to use.



               
               

               
            

Legacy_Valgav

  • Full Member
  • ***
  • Posts: 118
  • Karma: +0/-0
nwnx - loading external data to nwn
« Reply #4 on: March 23, 2016, 10:42:28 am »


               I'm not sure if there's a method to parse object to gff or refer to corresponding uti file. Also one more question. Does resref=filename?
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
nwnx - loading external data to nwn
« Reply #5 on: March 23, 2016, 11:13:20 am »


               


Does resref=filename?




Resref is always lowercase while filename may have some uppercase letters. At least thats the case for vanilla content.


 


This is not a problem on windows, but might be on linux.


               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
nwnx - loading external data to nwn
« Reply #6 on: March 23, 2016, 01:15:42 pm »


               

A BLOB to YML and back tool would be pretty cool.  I have no idea what format the stored object is in though. I don't believe it's a GFF file since it's a representation of the in memory object. But I could be wrong...  I don't seem to have any objects persisted at the moment to look at.


               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
nwnx - loading external data to nwn
« Reply #7 on: March 23, 2016, 02:07:04 pm »


               Does this need to be in real time?

moneo is a great tool for reading and updating the uti files etc, but it edits the module, not the current session.
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
nwnx - loading external data to nwn
« Reply #8 on: March 23, 2016, 02:33:16 pm »


               

Those tools and the YML ones I prefer work on GFF files.  Do you know that the stored object (SCO/RCO) format is actually also a GFF format?  I suppose it could still be GFF but these are not uti files.  If it is still GFF then it could be pulled out of MYSQL and modified and replaced. 



               
               

               
            

Legacy_Valgav

  • Full Member
  • ***
  • Posts: 118
  • Karma: +0/-0
nwnx - loading external data to nwn
« Reply #9 on: March 23, 2016, 02:56:29 pm »


               In fact nwnx_dynres and nwnx_data have functions for converting  objects to files. Dynres converts creatures to utc,  data to bic and both convert items to uti.


So we can parse whole objects to database using nwn library.


Then we can probably use html gui to create new objects and parse them to uti or utc files. Including texts from dialog.tlk and relations between item properties we can reproduce creating items on fly.


That allows us to create new crafting resources on fly,  assign them to drops and give them parameters for crafting.


It makes nwn much more modular and dynamic from builder perspective.
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
nwnx - loading external data to nwn
« Reply #10 on: March 23, 2016, 03:13:50 pm »


               


In fact nwnx_dynres and nwnx_data have functions for converting objects to files. Dynres converts creatures to utc, data to bic and both convert items to uti.




Cool. I did not know it would do that. That could do the trick although you'd have to persist it differently than SCORCO.


 


Edit: Those are both windows plugins aren't they? I don't see them in the linux tree.



               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
nwnx - loading external data to nwn
« Reply #11 on: March 23, 2016, 04:18:49 pm »


               

You can also export the blob to file. I keeps it's gff format. You can then use any gff reader/editor program, like the Leto program, to actualy look at the file, modify it as needed, then save the file. If you are familiar with moneo, you can use that to modify the item file as well.That same file can then be imported into the database using SQL from with in nwn->nwnx, or with a script from the whatever program you use to evaluate your database directly. From there you can reinsert it into the running game using the retrieve object function in NWNX.


 


That would be platform independant.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
nwnx - loading external data to nwn
« Reply #12 on: March 23, 2016, 04:29:40 pm »


               

So the blob is GFF?  That makes it pretty straight forward then... I'll have to poke at that.


 


Edit: Coolio.  the blob is indeed just a gff formatted file. In my persisted chest case its a utc.  nwn-lib was perfectly happy with it. That'll be fun to play with. So many things to hack on so little time... '<img'>


               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
nwnx - loading external data to nwn
« Reply #13 on: March 23, 2016, 04:55:19 pm »


               

Poke, Poke...... Is it dead yet? ':ph34r:'



               
               

               
            

Legacy_Valgav

  • Full Member
  • ***
  • Posts: 118
  • Karma: +0/-0
nwnx - loading external data to nwn
« Reply #14 on: March 23, 2016, 06:21:28 pm »


               

@meaglyn yes they're windows plugins.


 


The approach with blob is nice but it's not what i want.


 


I want to be able to load objects(especially items) to gui(html form?) in form that user will understand. So properties showed not as numbers but e.g.. 1d6 fire dmg.


Then i can edit them create copies with other parameters etc.


 


There are to possible approaches. Full database and db + yaml. In both cases i would store in db resref, instances, owner of instances etc.


 


In full db approach main problem is to parse between yaml and db in both directions. Also I would need additional tables to store values of parameters for every instance which could lead to very big tables.


 


Advantage of that approach is that we're separated from nwn logic, any tool can import data from db and load it back. Yaml is simpel but it has to be yaml that yml2gff will understand. Potentially it would allow to create objects on fly without toolset. We'are able to identify single instance of object by table id stored on item as variable.


 


 Another approach is to use yaml files to store properties. Parser is between yaml and gui so we can work straight on files which sound much easier. Disadvantage is that we're still tied to nwn technology also we have to store multiple files if instances are different which lead as to multiple resrefs etc. But it's easier to get object back to game.


 


 


Any thoughts?