Author Topic: Conversational Custom Tokens  (Read 397 times)

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Conversational Custom Tokens
« on: August 17, 2011, 05:21:46 am »


               I need some help on a basic question. I'm afraid I get some good ideas going and have zero scripting know-how to follow through with it.

This is a conversation where I want a follower of a diety to greet them using the diety's name. I wanted to used a custom conversational token so that I could have a string variable on the NPC and use any diety's name in the greeting.

The conversation might go as:

<CUSTOM30300>'s blessings to you!

For Action Taken on that line of conversation I had this script:

void main()
{
    string sDiety;

    SetCustomToken(30300, sDiety);
}


Then the NPC has a string name in their variables of sDiety

What am I neglecting here? The conversation comes out as:

's blessings to you!

Sorry to bother you folks with something basic, but custom tokens are new to me and I've spent a lot of time getting to this point. Thanks for all your help!
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Conversational Custom Tokens
« Reply #1 on: August 17, 2011, 05:39:31 am »


               First the Action Taken script does not fire ontill after the line is displayed.  Therefore the token will not be set when the line is displayed,  and it has to be set before it is displayed. 
second

Badwater wrote...


void main()
{
    string sDiety;

    SetCustomToken(30300, sDiety);
}



sDeity is not given a value therefor it is euqal to "".
You would need something more like
string sDiety= GetDeity(oPC);

of cource if the diety field is already set for the PC you could just use.
<Deity>'s blessings to you!
               
               

               


                     Modifié par Lightfoot8, 17 août 2011 - 04:39 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Conversational Custom Tokens
« Reply #2 on: August 17, 2011, 06:14:08 am »


               sorry, looks like I only half answered the question above. 

To get the token set before the conversation node is displayed you can use the Text appears when script to handle it.  Something like

int StartingConditional()
{
    string sDiety = GetLocalString(OBJECT_SELF,"VAR_NAME");

    if (sDiety=="")  sDiety = "Luck";
  
   SetCustomToken(30300, sDiety);

   return TRUE; // the nood will always show.


p.s. 
Looks like you just made the 1000th Topic on the scripting boards. 
               
               

               


                     Modifié par Lightfoot8, 17 août 2011 - 05:19 .
                     
                  


            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Conversational Custom Tokens
« Reply #3 on: August 17, 2011, 06:34:27 am »


               Well, rather than using the PC's deity, I want the NPC to have a deity variable because the NPC will be a follower of sDeity and have the appropriate variable on them. That way I can use a few greetings for any of the deities on our PW.

So I guess that crux of my question concerns having the custom token use the sDeity variable that will be a string variable on the NPC.
               
               

               


                     Modifié par Badwater, 17 août 2011 - 05:39 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Conversational Custom Tokens
« Reply #4 on: August 17, 2011, 07:08:52 am »


               the answer is just above your last post.  Link
               
               

               
            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Conversational Custom Tokens
« Reply #5 on: August 17, 2011, 07:17:55 am »


               Thank you, Lightfoot.

* Edit * - works exactly as intended, thanks again!
               
               

               


                     Modifié par Badwater, 17 août 2011 - 07:39 .
                     
                  


            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Conversational Custom Tokens
« Reply #6 on: August 17, 2011, 09:57:37 am »


               When a custom token is used, is that the only instance in a conversation in which that custom token can be used?

I ask because the first line works fine and the conversation uses the sDeity variable from the NPC. I don't seem to be having any success in using that custom token in any configuration later in the dialogue tree. To try and find out what might be going on I just put in a standard line on the first line of the conversation and then tried using the custom token along with the conditional and action script a few lines down in the tree and got nothing.

So what am I not getting here? (btw, this is why I hate scripting issues...my work grinds to a complete halt when I have to do quest and script work. <><)>

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Conversational Custom Tokens
« Reply #7 on: August 17, 2011, 03:31:15 pm »


               The token should still work.  It will also keep what ever you set it to, Untill either you change it or it is changed by another script.   So if you where doing tis for say a single player module, you could set the token when the conversation started and use it during the entire conversation, without fear of it changing.   MP modules would be a different matter all together.
               
               

               
            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Conversational Custom Tokens
« Reply #8 on: August 18, 2011, 01:53:36 am »


               So what in the world might be causal if the token is used later in the dialogue tree but does not appear in conversation? That's what is happening and for the life of me I can't figure out why.
               
               

               
            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Conversational Custom Tokens
« Reply #9 on: August 20, 2011, 10:32:10 am »


               Anyone?

All I wanted was a Pepsi.
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Conversational Custom Tokens
« Reply #10 on: August 20, 2011, 01:12:32 pm »


               We would probably need to see your scripts.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Conversational Custom Tokens
« Reply #11 on: August 20, 2011, 03:10:34 pm »


                FYI - You can also create new tokens in custom content (2da and custom TLK)

Thread Here
               
               

               
            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Conversational Custom Tokens
« Reply #12 on: August 20, 2011, 11:14:36 pm »


               First line of dialog:

<CUSTOM30300>'s blessings to you! What can I do for you?

Text Appears When:

int StartingConditional()
{
   string sDeity = GetLocalString(OBJECT_SELF,"sDeity");

   if (sDeity=="")  sDeity = "Good Fortune";

  SetCustomToken(30300, sDeity);

  return TRUE; // the nood will always show.
}


Actions Taken (same line):

void main()
{
   string sDeity;

   SetCustomToken(30300, sDeity);
}


The sDeity on the NPC shows up in the NPCs conversation on this first line. When I use the custom token later in dialog nothing happens (so no <UNRECOGNIZED TOKEN> or any other token msgs.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Conversational Custom Tokens
« Reply #13 on: August 21, 2011, 11:25:34 am »


               That ActionsTaken script is setting the custom token to a blank string. string sDeity needs to equal something. And you shouldn't need it if you are already setting the custom token in the starting conditional script.  Try getting rid of the actions taken script all together and see if it helps.

If you do need to use the actions taken script though to make sure you keep the custom token refreshed for multiplayer conversation purposes or what not, then you need to keep it more like what the starting conditional is like:

void main()
{
    string sDeity = GetLocalString(OBJECT_SELF,"sDeity");
    if (sDeity=="")  sDeity = "Good Fortune";

    SetCustomToken(30300, sDeity);
}
               
               

               


                     Modifié par GhostOfGod, 21 août 2011 - 10:32 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Conversational Custom Tokens
« Reply #14 on: August 21, 2011, 04:02:33 pm »


               Your best option is to just remove that Action taken script.  Do your refreshing in the Text appears when script if needed(Multiplayer games).