Author Topic: Information across modules  (Read 538 times)

Legacy_Ralthis

  • Jr. Member
  • **
  • Posts: 90
  • Karma: +0/-0
Information across modules
« on: December 17, 2011, 05:45:13 pm »


               Hello,

I was wondering what different kinds of methods people use to translate information across modules. For example, I have an NPC in one module who may or may not die depending on what the PCs do. In the next, I want him to be present if alive, and dead if not.

I've assumed integers saved on a PC (or item) are wiped once a new module is loaded, though I could be wrong. An item could always be made and given to a PC if a certain event happens in the first module (i.e. my NPC's death), but I don't want to clutter up the player's inventories with undroppable items. New feats could also be added and applied to a PC's skin, but I don't want to create a dozen feats just to save information across modules.

Ideas?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Information across modules
« Reply #1 on: December 17, 2011, 05:53:15 pm »


               The options are.   NWDataBase( SetCampaign* functions) , DBitem( Local vars are saved with the item), PCSkin as DB Item(This can get complex with the x3 system), Or the nwnx DB(Servers only, You have to installit.)
               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Information across modules
« Reply #2 on: December 17, 2011, 07:51:21 pm »


               If its a single player module, I'd just use a small weight free and undroppable item given to the PC. The item(s) can be checked for in the later module and even removed after whatever effect is set for it.
               
               

               
            

Legacy_Ralthis

  • Jr. Member
  • **
  • Posts: 90
  • Karma: +0/-0
Information across modules
« Reply #3 on: December 17, 2011, 08:10:55 pm »


               Thanks guys! I didn't even know those functions existed!
Next question: How do I make my modules into a campaign (for the SetCampaign functions), or does it automatically assume one if I start the second module from my first?
               
               

               
            

Legacy_Ralthis

  • Jr. Member
  • **
  • Posts: 90
  • Karma: +0/-0
Information across modules
« Reply #4 on: December 17, 2011, 08:12:40 pm »


               
               
               

               


                     Modifié par Ralthis, 17 décembre 2011 - 08:12 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Information across modules
« Reply #5 on: December 17, 2011, 08:21:12 pm »


               

Ralthis wrote...

Thanks guys! I didn't even know those functions existed!
Next question: How do I make my modules into a campaign (for the SetCampaign functions), or does it automatically assume one if I start the second module from my first?


There is no differance.    Between a campaign module and a normal module as far as the toolset goes.   any time the SetCampaign* functions are used, it just reads the information from the DB in the "database folder" with the given name passes to it from the function.   The main draw back is not getting it read the correct information for the character at hand.   this becomes a problem if two players , or the same player for that matter, play characters with the same name.    All in all a BD Item may be a simpler solution.   just one undorppable item in the inventory with as many local varables as you want to place on it.  
               
               

               
            

Legacy_wyldhunt1

  • Sr. Member
  • ****
  • Posts: 443
  • Karma: +0/-0
Information across modules
« Reply #6 on: December 17, 2011, 08:29:26 pm »


               I'll third the vote for the item.
A single item can store a nearly unlimited amount of information on it.
It's a bit like a mobile database tailored to that character.
Just be careful to never destroy the item... For that reason, I don't generally use PC Skin items. People love to destroy skin items in their scripts for some reason.
               
               

               
            

Legacy_jackkel dragon

  • Full Member
  • ***
  • Posts: 178
  • Karma: +0/-0
Information across modules
« Reply #7 on: December 18, 2011, 02:48:03 am »


               I really loved how the HeX Coda by Stefan Gagne handled bringing information from HX1 to HX2. It used the SetCampaign<Variable> functions to set functions in the DB files and StoreCampaignObject (or whatever it was called) to save henchman inventories. To ensure that running multiple characters through the endgame of HX1 wouldn't end up causing problems later, the player is allowed to choose one of five "slots" (each a different database) at the end of the game. The conversation that handled this also saved the name of the character whose information was being saved to the database, so the player didn't even have to memorize which slot had which character's information.

I haven't specifially checked how HX2 did the import, but I'm sure that after choosing the database to import variables from you could just set local variables on the module based on the campaign variables and use the local variables for most purposes.

Alternatively, you could use items to track things. I'm biased toward the database system after seeing it work with the HeX Coda and how it preserves henchmen inventories, but items are perfectly fine when just transferring flags and variables. I'd just suggest giving the player the items right before the final export of the first (export) module, then take them away after setting the necessary flags in the second (import) module.

Edit: There is no specific campaign flag to set, but campaign variables will save to a default database unless you specify your own database (which I recommend). I'll take a quick look to see how to set the database being written to, unless someone else beats me to it...

Edit 2: It appears I was wrong. The SetCampaign<Variable> and GetCampaign<Variable> functions require a campaign database as arguments, so something else that I use must be writing to the default database. So just make sure you're reading and writing to the correct databases if you go that route.
               
               

               


                     Modifié par jackkel dragon, 18 décembre 2011 - 02:55 .
                     
                  


            

Legacy_Ralthis

  • Jr. Member
  • **
  • Posts: 90
  • Karma: +0/-0
Information across modules
« Reply #8 on: December 18, 2011, 05:31:39 am »


               So, if I understand this correctly all I have to do is create an undroppable DB item on which to save my variables. Do I have to set a flag in order for an item to become a DB item, or are all items DB items on creation (i.e. items don't have their vars wiped at the end of modules)?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Information across modules
« Reply #9 on: December 18, 2011, 05:49:16 am »


               That is correct,  All Local variables stored on an item (any Item) are part of the items structure and get saved/moved with the item.  

Local variables Stored on a PC are not a part of the PC's structure, they are instead stored in a structure that is part of the module called the TURD.  Therefore locals on a PC DO NOT get saved/moved with the PC.
               
               

               
            

Legacy_Ralthis

  • Jr. Member
  • **
  • Posts: 90
  • Karma: +0/-0
Information across modules
« Reply #10 on: December 18, 2011, 06:00:11 am »


               Thanks again Lightfoot!
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Information across modules
« Reply #11 on: June 27, 2012, 07:29:03 pm »


               I'm going to ask a really dumb question but keep in mind that I use LilacSoul's Script Generator to do my scripting. I don't recall seeing in the Script Generator a way to store variables on an item. How do you do this? Also, examples of what variables you have stored on an item and their purpose would help me greatly in my understanding. I mean...I understand the purpose of storing variables on a PC but not on an item. The help is greatly appreciated. Thanks!
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Information across modules
« Reply #12 on: June 28, 2012, 10:56:24 am »


               variables stored on items are done via


SetLocalInt(oItem,"VARIABLENAME",123);  // For ints
SetLocalString(oItem,"VARIABLENAME","mystring");  // For strings
SetLocalFloat(oItem,"VARIABLENAME",123.33);  // For floats
SetLocalLocation(oItem,"VARIABLENAME",GetLocation(oPC));  // For locations



Once you have the value u want to preserve in your script, just feed its variable, in as the 3rd argument, the second argument is the name of the variable, and the first argument is the object to store it on.