logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
DMFI 1.08 and nwnx
Goto page 1, 2  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
Kelsys



Joined: 25 Apr 2005
Posts: 3

PostPosted: Sun May 15, 2005 12:40    Post subject: DMFI 1.08 and nwnx Reply with quote

Hello again,

i like to use the DMFI wands for my modul, but the DMFI Database inc uses the Bioware DB and not nwnx ?

i searched on nwvault , nwnx forum and google but i didn't found a translation to nwnx2 Confused

Here is the DMFI_db _inc :

Code:
//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

//Listen Pattern ** variable
//Change this to 0 to make the DMFI W&W more compatible with Jasperre's AI
const int LISTEN_PATTERN = 20600;

//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);
}


It looks allmost like the aps_include , but i'm not shure what i have to change there !? can somebody help please...

thanks and with best regards

Kelsys


** DMFI Wands are made by : http://dmfi.slightlysilly.net/index.php **
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Thu May 26, 2005 11:53    Post subject: Reply with quote

You need to remap the Get/SetCampaign calls to their NWNX counterparts.

Original code:

Code:
//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);
}


adaptation for aps/nwnx:

Code:

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

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


Just transform all calls in this manner and it should work out of the box. Btw, if it does work for you, please post a working copy of the include below.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Kelsys



Joined: 25 Apr 2005
Posts: 3

PostPosted: Sat May 28, 2005 15:37    Post subject: i tried it this way Reply with quote

Ok, i'm not a Programmer but i hope this is right. It may can be solved on an other way, i dont know.

At the moment i build the table, if i'm done i will post the MakeTable Code here in this thread..

Thanks for help !

Greetings
Kelsys

Code:



/////////////////////////////////////////////////////////////////////////////////

//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



// Include the APS "aps_include" ///////////////////////////////////////////////

#include "aps_include"

// Declare Variables ///////////////////////////////////////////////////////////

string sDBSetting;
object oPlayer;
string sDBName;
int iDBValue;
float fDBValue;
string sDBValue;

// Remap Bioware to NWNX ///////////////////////////////////////////////////////

string sVarName = sDBSetting;
object oObject = oPlayer;
// string sTable = sDBName;
int iValue = iDBValue;
float fValue = fDBValue;
string sValue = sDBValue;
int iExpiration;

// Set name of the table ///////////////////////////////////////////////////////

string sTable = "dmfi";

//Listen Pattern ** variable
//Change this to 0 to make the DMFI W&W more compatible with Jasperre's AI /////

const int LISTEN_PATTERN = 20600;


// Functions INT ///////////////////////////////////////////////////////////////

int GetDMFIPersistentInt(string sDBName, string sDBSetting, object oPlayer = OBJECT_INVALID)
{

    int iReturn = GetPersistentInt(oObject, sVarName, sTable);
    return iReturn;
}

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

    SetPersistentInt(oObject, sVarName, iValue, iExpiration = 0, sTable);
}

// Functions FLOAT /////////////////////////////////////////////////////////////

float GetDMFIPersistentFloat(string sDBName, string sDBSetting, object oPlayer = OBJECT_INVALID)
{
    float fReturn = GetPersistentFloat(oObject, sVarName, sTable);
    return fReturn;
}

void SetDMFIPersistentFloat(string sDBName, string sDBSetting, float fDBValue, object oPlayer = OBJECT_INVALID)
{
    SetPersistentFloat(oObject, sVarName, fValue, iExpiration=0, sTable);
}

// Functions STRING ////////////////////////////////////////////////////////////

string GetDMFIPersistentString(string sDBName, string sDBSetting, object oPlayer = OBJECT_INVALID)
{
    string sReturn = GetPersistentString(oObject, sVarName, sTable);
    return sReturn;
}

void SetDMFIPersistentString(string sDBName, string sDBSetting, string sDBValue, object oPlayer = OBJECT_INVALID)
{
    SetPersistentString(oObject, sVarName, sValue, iExpiration=0, sTable);
}
Back to top
View user's profile Send private message
dguntner



Joined: 31 Dec 2004
Posts: 116

PostPosted: Sun May 29, 2005 3:10    Post subject: Reply with quote

Well, that's bloody annoying. Ages ago, I sent Hansoo a persistent database wrapper that contained both the Bioware and NWNX2/APS calls, so that the end user would only have to set one variable to determine if Bioware DB was going to be used or if NWNX/APS/MySQL was going to be used. I was told it would be included in 1.08.

Nice to see my contribution was really appreciated. Evil or Very Mad

--Dave
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Sun May 29, 2005 10:19    Post subject: Reply with quote

What a pity. Especially since now everyone using it and NWNX has the same problem. Would you care to send me your code ? I could add it to some special download section on this site.

@kelsys: The way you are renaming the variables will not work (does this even compile?). You need to call the APS functions with the variable names declared in the function (like I showed above). No fancy variable renaming please Smile Copy the two functions I wrote above into your original code and modify the others accordingly.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
dguntner



Joined: 31 Dec 2004
Posts: 116

PostPosted: Sun May 29, 2005 11:18    Post subject: Reply with quote

What's your E-Mail address? You can PM me on it if you don't want to post it in the forum. Smile When I get a chance I'll send you what I'm using now; it's been revised a bit since the code I originally sent to Hansoo.

--Dave
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Sun Jun 05, 2005 10:53    Post subject: Reply with quote

Thanks, dgunter. I added the files you sent me to the new contributions section on the download page !
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
dguntner



Joined: 31 Dec 2004
Posts: 116

PostPosted: Wed Jun 08, 2005 4:36    Post subject: Reply with quote

Unfortunately, you goofed where you made your comments to the two functions in dg_i_persist. I'll E-Mail you the correction. If someone follows the directions you provide there, they'll break the script because you've got them commenting the wrong things. Smile

Look for my E-Mail with the corrected dg_i_persist script, and please add it to the download archive ASAP. Thanks.

--Dave
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Wed Jun 08, 2005 11:01    Post subject: Reply with quote

You are right, the comments are misleading. I fixed them in the download.

I checked what you sent me, and I am not sure this would improve things, though. The OBJECT_INVALID - OBJECT_SELF conversion is not what is usually done with NWNX and the automatic table creation would not work in this case (since the scorco function expects a different table structure, including a blob field).
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
dguntner



Joined: 31 Dec 2004
Posts: 116

PostPosted: Wed Jun 08, 2005 19:09    Post subject: Reply with quote

True, I hadn't thought about that (table creation differences) when I sent it. I've E-Mailed you an updated dg_i_persist script which addresses this, and in the process makes it easier for the end user to pick between old ODBC and new ODBC2 methods. Smile

OBJECT_SELF, OBJECT_INVALID & oModule(which is the stored value of GetModule()): I haven't looked at the new aps_include script (not much point for me, since I can't use it Sad), so I don't know what SetPersistentObject() is doing with it. For all the others, it's used. I've never seen anyone feed OBJECT_INVALID to an aps_include function, so I don't know what the results would be. I seem to remember that those functions do look to see if the passed object is the value of GetModule() and then stores the player and tag columns appropriately. The Bioware DB doesn't care about those things and in fact defaults the object value to OBJECT_INVALID. That conversion is being done for compatability between the two DB systems, so please don't take it out. The idea of this wrapper is to make it so that all someone has to do once they've put it in is set one local variable in OnModuleLoad to decide which DB system they're going to use (Bioware or NWNX/APS/MySQL). So please leave the oModule/OBJECT_INVALID checks in place. While it's no secret that I consider the Bioware DB to be a three-coil turd and am a big fan of MySQL and NWNX, I do not want my wrapper to specifically favor one over the other - I want it to allow the end user the choice. When getting everything to work the first time, I found that those conversions were needed. In short, it works this way, so please don't "fix" it. Very Happy

--Dave
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Thu Jun 09, 2005 9:19    Post subject: Reply with quote

dgutner, it's your script, so you are designing the interface and the functionality. I just pointed out that NWNX normally works a bit differently, but if you decide to lean towards the way the Bioware DB does its thing, I have no problem with it.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
dguntner



Joined: 31 Dec 2004
Posts: 116

PostPosted: Thu Jun 09, 2005 10:02    Post subject: Reply with quote

Well, to be precise, I'm leaning in a direction which works for both DB systems, so that the end user (module runner) can make the choice of which system he/she wants to use. Smile My normal inclination would be to totally ignore the Bioware DB altogether. Mr. Green But I realize that some people might not want to deal with an external database system, thus the support for both. Naming the functions (inside the wrapper) the way they are makes it really easy for someone to install it in an existing module and then do a global change of "SetCampaignInt(" to "SetCampaignInt2(" (for example) and then they're done.

So, thanks for honoring my wishes. Smile

BTW, did you receive the changes I sent?

--Dave
Back to top
View user's profile Send private message
dguntner



Joined: 31 Dec 2004
Posts: 116

PostPosted: Mon Jun 13, 2005 23:46    Post subject: Reply with quote

Hey Pap, I don't suppose I could get you to put those changes in I sent you a while ago now, could I? Smile Let me know if for some reason you didn't get the new dg_i_persist and readme and I'll resend. But if you did, please put them into the archive ASAP. Thanks!

--Dave
Back to top
View user's profile Send private message
dguntner



Joined: 31 Dec 2004
Posts: 116

PostPosted: Wed Jun 29, 2005 3:21    Post subject: Reply with quote

Pap has updated the archive to have the correct version of the scripts. Anyone using my wrapper should probably download the archive again and use the updated scripts.

Thanks, Pap!

--Dave
Back to top
View user's profile Send private message
Frang



Joined: 22 May 2005
Posts: 32

PostPosted: Sat Oct 14, 2006 5:13    Post subject: Reply with quote

Sorry to bring up such an old thread but im just coming back to nwn and working on a new PW Mod and have found a few nice systems on the vault but they use the bioware database system and im already setup for nwnx and mysql. And I would really like to use the wrapper dguntner has made but I am having some trouble figuring it out. I understand how to change over the code to use the code in his include file but im not sure of what he means by
Quote:
Instead of uncommenting and commenting in many places, you only have to change a variable ("MySQL") in OnModuleLoad.
Im not sure how to add the variable to mod load he dont give an example of this wich would help alot of people. If someone could give me an example of this I would be very greatful.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group