Author Topic: I need a NWNX Wizard (Hum/40)  (Read 396 times)

Legacy_Mad.Hatter

  • Full Member
  • ***
  • Posts: 156
  • Karma: +0/-0
I need a NWNX Wizard (Hum/40)
« on: July 20, 2011, 01:50:16 am »


               Hey guys,

I'll likely be cross-posting on the NWNX forums should I not get a response here, but I like you guys.

I am about to merge the "guts" of my DM'd campaign (for 4-6 players played eight days a month tops--campaign will persist indefinitely) together and have decided that NWNX/APS with a SQLite DB would be the best choice for what I need. I am using HCR2 by Ed Beck and DMFI 1.09 by tsunami82. Both write to a database. I would like to get HCR2 and DMFI 1.09 to both write to the same database using NWNX. I can get the three working independently.

Here is my thinking:
(a) The HCR2 documentation mentions NWNX by name, and alludes to writing a simple wrapper to define a bunch of functions to replace h2_biowaredb_c. It should be easy to create this wrapper, I just have no idea where to start.
('B)' I need to figure out how to use NWNX2 with DMFI within the HCR2 framework.

Has anyone done this before to spare me zots? I would love to finally build areas and such. '<3'
               
               

               
            

Legacy_Mad.Hatter

  • Full Member
  • ***
  • Posts: 156
  • Karma: +0/-0
I need a NWNX Wizard (Hum/40)
« Reply #1 on: July 20, 2011, 01:52:16 am »


               Alternatively, I will build, DM, or play on your PW if you help me. '<img'>
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
I need a NWNX Wizard (Hum/40)
« Reply #2 on: July 20, 2011, 04:39:48 am »


               You might catch more fish if you post the default reads and writes and checks you want converted. It's shockingly easy once you do a couple. And you will definitely want to use the same database, but I'm wondering if you mean the same table. If so, why would you only want to use one table?

Funky
               
               

               
            

Legacy_Mad.Hatter

  • Full Member
  • ***
  • Posts: 156
  • Karma: +0/-0
I need a NWNX Wizard (Hum/40)
« Reply #3 on: July 20, 2011, 05:28:37 am »


               Good call, Funky.

Here's the builder's guide on Scribd (http://www.scribd.co...-Builders-Guide). Pages 6-8 talk about persistence in HCR2 since code comes out fugly here.

Here's the DMFI wrapper.

//DMFI Persistence wrapper functions
//This include file contains the wrapper functions for the
//persistent settings of the DMFI Wand and Widget package
//Advanced users can adapt this to the database system that
//they want to use for NWN.
//
//These functions use the Bioware database by default and use a primitive form
//of "caching" to avoid lots of database R/W

//:://////////////////////////////////////////////
//:: Created By: The DMFI Team
//:: Created On:
//:://////////////////////////////////////////////
//:: 2008.07.10 tsunami282 - implemented alternate database support, initially
//::                         for Knat's NBDE


const int DMFI_DB_TYPE =DMFI_DB_TYPE_BIOWARE;

void FlushDMFIPersistentData(string sDBName)
{
   // no flushing required for Bioware database
}

int IsDMFIPersistentDataDirty(string sDBName)
{
   return FALSE; // bioware database system has no cache, so is never dirty
}

//Int functions
int GetDMFIPersistentInt(string sDBName, string sDBSetting, object oPlayer = OBJECT_INVALID)
{
   int iReturn = GetCampaignInt(sDBName, sDBSetting, oPlayer);
   return iReturn;
}

void SetDMFIPersistentInt(string sDBName, string sDBSetting, int iDBValue, object oPlayer = OBJECT_INVALID)
{
   SetCampaignInt(sDBName, sDBSetting, iDBValue, oPlayer);
}

//Float functions
float GetDMFIPersistentFloat(string sDBName, string sDBSetting, object oPlayer = OBJECT_INVALID)
{
   float fReturn = GetCampaignFloat(sDBName, sDBSetting, oPlayer);
   return fReturn;
}

void SetDMFIPersistentFloat(string sDBName, string sDBSetting, float fDBValue, object oPlayer = OBJECT_INVALID)
{
   SetCampaignFloat(sDBName, sDBSetting, fDBValue, oPlayer);
}

//String functions
string GetDMFIPersistentString(string sDBName, string sDBSetting, object oPlayer = OBJECT_INVALID)
{
   string sReturn = GetCampaignString(sDBName, sDBSetting, oPlayer);
   return sReturn;
}

void SetDMFIPersistentString(string sDBName, string sDBSetting, string sDBValue, object oPlayer = OBJECT_INVALID)
{
   SetCampaignString(sDBName, sDBSetting, sDBValue, oPlayer);
}
               
               

               
            

Legacy_DM_Vecna

  • Hero Member
  • *****
  • Posts: 501
  • Karma: +0/-0
I need a NWNX Wizard (Hum/40)
« Reply #4 on: July 20, 2011, 07:08:31 am »


               I know you posted that you are wanting to use SQLite but I can give a shining recomendation for working with MySQL and MySQL Workbench.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
I need a NWNX Wizard (Hum/40)
« Reply #5 on: July 20, 2011, 08:05:40 am »


               Ok, easy enough. These use the default aps_include and default pwdata table:


//Bioware version
//Int functions
int GetDMFIPersistentInt(string sDBName, string sDBSetting, object oPlayer = OBJECT_INVALID)
{
int iReturn = GetCampaignInt(sDBName, sDBSetting, oPlayer);
return iReturn;
}
//SQL version - will work with MySQL or SQLite, I believe
int GetDMFIPersistentInt(string sDBName, string sDBSetting, object oPlayer = OBJECT_INVALID)
{
int iReturn = GetPersistentInt(oPlayer, sDBName+"_"+sDBSetting);
return iReturn;
}






//Bioware Version
void SetDMFIPersistentInt(string sDBName, string sDBSetting, int iDBValue, object oPlayer = OBJECT_INVALID)
{
SetCampaignInt(sDBName, sDBSetting, iDBValue, oPlayer);
}
//SQL version
void SetDMFIPersistentInt(string sDBName, string sDBSetting, int iDBValue, object oPlayer = OBJECT_INVALID)
{
SetPersistentInt(oPlayer, sDBName+"_"+sDBSetting, iDBValue);
}

Once you realize that the Persistent functions in aps_inclue are set up to mirror Get/SetLocal variable functions, it gets very easy.

Note that you shouldn't be doing reads from the database in any system you use, but rather loading up locals from persistents on client enter and reading locals everywhere else, instead. When you set, set a persistent and a local. Not sure why DMFI isn't doing this, especially with bioware db - maybe they didn't want to force users to merge a client enter script.

It's also worth noting that there are MANY ways to do this better than I did above, because with SQL setups you can specify your own tables - you really should not be concatenating strings as I do, as it's simply not necessary. I only do it for the sake of simplicity, because it's what fits easily into the default pwdata table.

One minor potential issue - the DMFI functions default to having an invalid object - that will result in a pwdata entry with :

    else
    {
        sPlayer = "~";
        sTag = GetTag(oObject);
    }
I THINK a blank tag will be ok, but I'm not sure how SQLite will deal with that.

LMK if you have any questions.

Funky
               
               

               


                     Modifié par FunkySwerve, 20 juillet 2011 - 07:10 .