View previous topic :: View next topic |
Author |
Message |
Tuebits
Joined: 27 Jan 2005 Posts: 18
|
Posted: Sat Feb 05, 2005 5:44 Post subject: persistant location saving |
|
|
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 |
|
|
Tuebits
Joined: 27 Jan 2005 Posts: 18
|
Posted: Sat Feb 05, 2005 6:05 Post subject: |
|
|
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 |
|
|
Manuel
Joined: 30 Dec 2004 Posts: 51
|
Posted: Sat Feb 05, 2005 7:29 Post subject: |
|
|
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 |
|
|
Tuebits
Joined: 27 Jan 2005 Posts: 18
|
Posted: Sat Feb 05, 2005 7:45 Post subject: |
|
|
i don't know, and i too much of a noob to understand how to use that stuff there |
|
Back to top |
|
|
Primogenitor
Joined: 08 Jan 2005 Posts: 88
|
|
Back to top |
|
|
NoMercy
Joined: 03 Jan 2005 Posts: 123 Location: UK
|
Posted: Sat Feb 05, 2005 15:09 Post subject: |
|
|
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 |
|
|
Tuebits
Joined: 27 Jan 2005 Posts: 18
|
Posted: Sat Feb 05, 2005 18:36 Post subject: |
|
|
Awe, thank you all so much. That worked perfect! |
|
Back to top |
|
|
|
|
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
|