Author Topic: Changing the name of a waypoint  (Read 394 times)

Legacy_Krevett

  • Full Member
  • ***
  • Posts: 203
  • Karma: +0/-0
Changing the name of a waypoint
« on: July 15, 2012, 11:59:43 am »


               Hi guys! Is there a way to change the name of a waypoint by script? Because the SetName command only works on creature, items, placeables or doors...

Thanks!
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Changing the name of a waypoint
« Reply #1 on: July 15, 2012, 01:04:16 pm »


               Is it infact the name you need to change and not the tag?

If it is the name, then Im afraid that if the SetName() function doesnt work, then there isnt any alternative methods available.
If we could debug to find out why it wasnt working, then other suggestions could be made.I think nwnx funcs or nwnx cool - has functions for setting first name and set last name etc.
While waypoints are different from creatures etc, they do share some similarities in gff format, and may possess the firstname/lastname fields - cant remember.
If SetName didnt work, a nwnx method may work?
If it is infact tag editing you need done, in order to change a GetWaypointByTag  call, then nwnx funcs has a SetTag function.
Also - I would double check the SetName function.
Alot of things that nwscript does, doesnt register visually until you have either exited the area, or the module and re-entered.
eg- Things like waypoints etc, will not be updated in your DM Chooser, until the SendAreaToDM internal method has been called.
(There is no native way to do that from nwscript)
I would try the SetName method one more time, leave the game, and re-enter, and see if it is reflected?

PS - This is the buggiest forum ever ... I keep getting Access is restricted!!
               
               

               
            

Legacy_Krevett

  • Full Member
  • ***
  • Posts: 203
  • Karma: +0/-0
Changing the name of a waypoint
« Reply #2 on: July 15, 2012, 01:14:25 pm »


               I need to change both the Tag and the Name of the waypoint.
The description of the SetName function is as follow
// Set the name of oObject.
// - oObject: the object for which you are changing the name (a creature, placeable, item, or door).
// - sNewName: the new name that the object will use.
// Note: SetName() does not work on player objects.
//       Setting an object's name to "" will make the object
//       revert to using the name it had originally before any
//       SetName() calls were made on the object.
void SetName(object oObject, string sNewName="")
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Changing the name of a waypoint
« Reply #3 on: July 15, 2012, 01:16:47 pm »


               I would experiement with the SetName again - leave the area, and re-enter.
Just because it doesnt list Waypoints as being something it works on, doesnt mean it wont work.

As far as waypoint tags go.
You can either 'CreateObject'   and use the last argument to specify a new tag, and then destroy the original waypoint.

Or
Use nwnx funcs and set the tag directly.
               
               

               
            

Legacy_Krevett

  • Full Member
  • ***
  • Posts: 203
  • Karma: +0/-0
Changing the name of a waypoint
« Reply #4 on: July 15, 2012, 01:30:10 pm »


               For the tag there is no problem I use CreateObject but the SetName doesn't seem to work on waypoints I tested both in DM mode and player mode, leaving and returning the area
               
               

               
            

Legacy_Rubies

  • Hero Member
  • *****
  • Posts: 508
  • Karma: +0/-0
Changing the name of a waypoint
« Reply #5 on: July 15, 2012, 02:35:34 pm »


               Create a new waypoint of the same time using GetLocation on the old waypoint - then you can change the tag on creation. '<img'>

EDIT: Sorry, that was already suggested. Silly me.
               
               

               


                     Modifié par Rubies, 15 juillet 2012 - 01:38 .
                     
                  


            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Changing the name of a waypoint
« Reply #6 on: July 15, 2012, 02:43:08 pm »


               Are you referencing the name of the waypoint for something?  I can't think of a valid reason to need to change the name of a waypoint besides that, if the tag is set properly.
If you're using it as a reference, set the name on it as a variable instead.
               
               

               
            

Legacy_Krevett

  • Full Member
  • ***
  • Posts: 203
  • Karma: +0/-0
Changing the name of a waypoint
« Reply #7 on: July 15, 2012, 03:21:52 pm »


               referencing it as a variable won't work i'm trying to play with NESS spawn system so I need to change the name...
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Changing the name of a waypoint
« Reply #8 on: July 16, 2012, 06:16:12 pm »


                Krevitt, you do not need to use the name and tag fields on a NESS spawn point. You can use local variables.

See this from the "spawn__history" file:

// +++ Start Version 8.1.1//
//   2/1/04 - 5/28/04
//
//
//      NESS now allows you to specify the spawn tag by adding a variable, named
//      "NESS_TAG", on the spawn waypoint.  If this variable exists, it will use
//      it's value as the spawn tag instead of waypoint's tag.
//
//      Always retrieve spawn tag and spawn name from the variables written on
//      the the spawn instead of using GetTag() an GetName().  This is necessary
//      to support use of the "NESS" and "NESS_TAG" variables.

I've been using these variables for some time now. Works just fine.
The advantage is that you can assign a spawn point a unique tag and search for it by tag. Very handy!
               
               

               


                     Modifié par henesua, 16 juillet 2012 - 05:17 .
                     
                  


            

Legacy_Krevett

  • Full Member
  • ***
  • Posts: 203
  • Karma: +0/-0
Changing the name of a waypoint
« Reply #9 on: July 16, 2012, 10:50:27 pm »


               thanks henesua I'll take a look at how informations are stocked on a spawn point... at first I wanted to create a waypoint with my specified tag and a SP-SN, etc... Style-name so if all informations about the flags are set locally on the wp i'll probaby go that way!
               
               

               


                     Modifié par Krevett, 16 juillet 2012 - 09:52 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Changing the name of a waypoint
« Reply #10 on: July 16, 2012, 11:21:55 pm »


               I'm not clear on what you are planning. But you should look into the NESS scripts specifically: spawn_functions

In that script is a function called SetSpawns(). I don't recall if I tweaked this function. In anycase here is what my version looks like:

int SetSpawns(location lBase)
{
    string sSpawnName, sSpawnNum, sSpawnTag;
    int nNth = 1;
    int nSpawnNum = 0;

    // Enumerate Waypoints in the Area
    object oSpawn = GetFirstObjectInArea(OBJECT_SELF);
    while (oSpawn != OBJECT_INVALID)
    {
        // Check for a local string called "NESS" on the waypoint
        // first.  If it exists, use it instead of the name
        sSpawnName = GetLocalString(oSpawn, "NESS");

        if (GetStringLeft(sSpawnName, 2) != "SP")
        {
            // Retrieve Name
            sSpawnName = GetName(oSpawn);
        }

        // Check if Waypoint is a Spawn Controller
        if (GetStringLeft(sSpawnName, 2) == "SP")
        {
            // Set Spawn
            nSpawnNum++;
            sSpawnNum = "Spawn" + PadIntToString(nSpawnNum, 2);
            SetLocalObject(OBJECT_SELF, sSpawnNum, oSpawn);


            sSpawnTag = GetLocalString(oSpawn, "NESS_TAG");
            if (sSpawnTag == "")
            {
              sSpawnTag = GetTag(oSpawn);
            }

            DelayCommand(0.0, InitFlags(oSpawn, sSpawnName, sSpawnTag));
        }
        nNth++;
        oSpawn = GetNextObjectInArea(OBJECT_SELF);
    }
    SetLocalInt(OBJECT_SELF, "Spawns", nSpawnNum);
    return nSpawnNum;
}

You'll note that it looks first at the NESS local string, then looks to the name.  Then it looks to the NESS_TAG local string, followed by looking at the actual tag.
               
               

               
            

Legacy_Krevett

  • Full Member
  • ***
  • Posts: 203
  • Karma: +0/-0
Changing the name of a waypoint
« Reply #11 on: July 16, 2012, 11:32:35 pm »


               what i would be able to do is to change some waypoint value on the spot like the number of monster it spawns etc... Or even create a spawn waypoint from scratch with a custom DM tool
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Changing the name of a waypoint
« Reply #12 on: July 17, 2012, 12:10:06 am »


               You'll have to dig in to NESS to determine whether spawn points are initialized once, or if the go back to the original NESS and NESS_TAG variables and parse them each time. I suspect that there is an initialization pass which parses those terms, and thereafter the spawn point is covered with many local vars. In this later case you'll need to find out NESS's internal naming conventions and use that to make selective changes.
               
               

               
            

Legacy_Krevett

  • Full Member
  • ***
  • Posts: 203
  • Karma: +0/-0
Changing the name of a waypoint
« Reply #13 on: July 17, 2012, 12:16:42 am »


               Yes i'm not on my computer for now, so i'll check these tomorrow I just hope that they are initialized once and stocked as locals it would make it much easier for me '<img'> if that's the case i could just check my dm string for the same flags and set the vars in just one script. Thanks for your help henesua
               
               

               
            

Legacy_Krevett

  • Full Member
  • ***
  • Posts: 203
  • Karma: +0/-0
Changing the name of a waypoint
« Reply #14 on: July 17, 2012, 01:26:26 pm »


               Working with no problem now, everything is stored as locals on the area and the waypoints, so now I got a dm tool that can select any NESS waypoint in the area, create new waypoint or change flag/resref of existing ones! Thanks for your help!
               
               

               


                     Modifié par Krevett, 17 juillet 2012 - 12:26 .