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 
 
persistant location saving

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
Tuebits



Joined: 27 Jan 2005
Posts: 18

PostPosted: Sat Feb 05, 2005 5:44    Post subject: persistant location saving Reply with quote

i am working on a persistant location save, then use of a portal to send you back to that saved location. but for some reason i not working.

I am using the sqlite database that came with ODBC, and used the aps_ demo mod to set the database.

I think i might be saving the name of my variable, and not the info for location.. same with retreiving the info.

I put this in OnRespawn to force a location save when you respawn..

Code:
            SetLocalLocation(oRespawner, "NW_L_I_DIED_HERE", GetLocation(GetLastRespawnButtonPresser()));
            SetLocalLocation(oRespawner, "loc_save", GetLocation(GetLastRespawnButtonPresser()));
            SetLocalInt(oRespawner, "NW_L_I_DIED", 1);
            SetLocalObject(oPriest, "NW_L_LASTDIED", GetLastRespawnButtonPresser());
            // * April 2002: Moved penalty here, only when going back to the death temple
            ApplyPenalty(oRespawner);
        }
        SetPersistentString(GetLastRespawnButtonPresser(),"demoName","loc_save");
        SendMessageToPC(GetLastRespawnButtonPresser(),"Location saved");
        object oSpawnPoint = GetObjectByTag(sDestTag);
        AssignCommand(oRespawner,JumpToLocation(GetLocation(oSpawnPoint)));



and this is what i put OnUsed on my portal.

Code:

#include "aps_include"

void main()
{
string port_to = GetPersistentString(GetLastUsedBy(),"demoName");

   /*   Script generated by
Lilac Soul's NWN Script Generator, v. 1.6

For download info, please visit:
http://www.lilacsoul.revility.com    */

//Put this OnUsed

object oPC = GetLastUsedBy();

if (!GetIsPC(oPC)) return;

object oTarget;
location gTarget;
gTarget = GetLocalLocation(oPC, "port_to");

//only do the jump if the location is valid.
//though not flawless, we just check if it is in a valid area.
//the script will stop if the location isn't valid - meaning that
//nothing put after the teleport will fire either.
//the current location won't be stored, either

if (GetAreaFromLocation(gTarget)==OBJECT_INVALID) return;

AssignCommand(oPC, ClearAllActions());

AssignCommand(oPC, ActionJumpToLocation(gTarget));


}


any help would be appreciated
Back to top
View user's profile Send private message
Tuebits



Joined: 27 Jan 2005
Posts: 18

PostPosted: Sat Feb 05, 2005 6:05    Post subject: Reply with quote

made small change to my portal..but still not working,

Code:

#include "aps_include"

void main()
{
string port_to = GetPersistentString(GetLastUsedBy(),"demoName","loc_save");

   /*   Script generated by
Lilac Soul's NWN Script Generator, v. 1.6

For download info, please visit:
http://www.lilacsoul.revility.com    */

//Put this OnUsed

object oPC = GetLastUsedBy();

if (!GetIsPC(oPC)) return;

object oTarget;
location gTarget;
gTarget = GetLocalLocation(oPC, "port_to");

//only do the jump if the location is valid.
//though not flawless, we just check if it is in a valid area.
//the script will stop if the location isn't valid - meaning that
//nothing put after the teleport will fire either.
//the current location won't be stored, either

if (GetAreaFromLocation(gTarget)==OBJECT_INVALID) return;

AssignCommand(oPC, ClearAllActions());

AssignCommand(oPC, ActionJumpToLocation(gTarget));


}
Back to top
View user's profile Send private message
Manuel



Joined: 30 Dec 2004
Posts: 51

PostPosted: Sat Feb 05, 2005 7:29    Post subject: Reply with quote

Can you confirm that the location values are being stored in the database? The code states that if the location is not valid, do nothing. Try connecting to SQLite and verifying the values are truly there and are valid. There are several tools around for looking into SQLite such as the simple command line utility aptly named ... SQLite: http://www.sqlite.org/sqlite.html
_________________
I only know enough to be dangerous.
Back to top
View user's profile Send private message
Tuebits



Joined: 27 Jan 2005
Posts: 18

PostPosted: Sat Feb 05, 2005 7:45    Post subject: Reply with quote

i don't know, and i too much of a noob to understand how to use that stuff there Smile
Back to top
View user's profile Send private message
Primogenitor



Joined: 08 Jan 2005
Posts: 88

PostPosted: Sat Feb 05, 2005 9:53    Post subject: Reply with quote

There is a nice freindly windows SQLite database viewer http://members.home.nl/t.m.brandts/ that should be helpful.
Back to top
View user's profile Send private message
NoMercy



Joined: 03 Jan 2005
Posts: 123
Location: UK

PostPosted: Sat Feb 05, 2005 15:09    Post subject: Reply with quote

I'm not entirely sure whats going on as the top-half of your first file is cut off, but my best guess is your using local when you should be using persistant.

In the respawn script:

Change:
Code:
SetLocalLocation(oRespawner, "loc_save", GetLocation(GetLastRespawnButtonPresser()));


To:
Code:
SetPersistentLocation(oRespawner, "loc_save", GetLocation(GetLastRespawnButtonPresser()) );


And delete:
Code:
SetPersistentString(GetLastRespawnButtonPresser(),"demoName","loc_save");


For the portal script which is so all over the shop I've re-written it:

Code:
#include "aps_include"

void main()
{
    object oPC = GetLastUsedBy();

    if (!GetIsPC(oPC)) return;

    location gTarget  = GetPersistentLocation( oPC, "loc_save");
   
    if (GetAreaFromLocation(gTarget)==OBJECT_INVALID)
    {
        SendMessageToPC( oPC, "The portal emitts a slight buzzing sound but otherwise does nothing." );
        return;
    }

    AssignCommand(oPC, ClearAllActions());
    AssignCommand(oPC, ActionJumpToLocation(gTarget));
}


Hopfully that should then work, if it doesn't well either I've missed something which someone else will point out, or the issue is with the database.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Tuebits



Joined: 27 Jan 2005
Posts: 18

PostPosted: Sat Feb 05, 2005 18:36    Post subject: Reply with quote

Awe, thank you all so much. That worked perfect!
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
Page 1 of 1

 
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