Author Topic: Add description piece to a item  (Read 446 times)

Legacy_Nebril2

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Add description piece to a item
« on: May 16, 2014, 01:57:26 am »


               

Hi all!! '<img'>


 


 


I want to add a parraph to a item description in a moment of the game... lets say for example the description of the item is:


 


"Longsword given by your father longtime ago bla bla bla"


 


And when in the game you go to a blacksmith who enchants it, i want it to say:


 


 


"Longsword given by your father longtime ago bla bla bla.


 


 


Enchanted by the blacksmith."


 


And so on....


 


I tried this, should be this easy but doesnt works.



void main()
{

  //After declaring objects etc.

   string sDesc = GetDescription(oSword);


  SetDescription(oSword, sDesc + " Enchanted by the blacksmith.");











}

But this REPLACES the descriptiuon and the result is "Enchanted by the blacksmith." removing all the previous description :/


 


 


 


Any idea? 


 


 


Thanks  '<img'>


 


 


 



               
               

               
            

Legacy_Tchos

  • Sr. Member
  • ****
  • Posts: 454
  • Karma: +0/-0
Add description piece to a item
« Reply #1 on: May 16, 2014, 02:41:38 am »


               

As I understand it, GetDescription(oSword) only works if the description was set using SetDescription() in the first place.  It will not work for the description you put on the item in the toolset.



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Add description piece to a item
« Reply #2 on: May 16, 2014, 03:00:10 am »


               

What you are doing should work. Perhaps you need to play with the settings on the GetDescription function.


 


NWN Lexicon to the rescue.


GetDescription()


SetDescription()



               
               

               
            

Legacy_Nebril2

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Add description piece to a item
« Reply #3 on: May 16, 2014, 04:37:22 am »


               

Thanks for answering 


 




As I understand it, GetDescription(oSword) only works if the description was set using SetDescription() in the first place.  It will not work for the description you put on the item in the toolset.




I did that, but still doesnt works :/ 


 


What i really want to do is to give the player different charasteristics along the game, and someway make that the player can know which characteristic has been given. For example a birthsign randomly generated at the start of the game, like "spider", "unicorn" etc, i did that, but i cant find a way to write the characteristics in the Character Info, so the player can always remember wich advantages and wich birthsign he got. Some way to put it in the character info, journal or a item in inventory who adds it (thats the origin of this post)



               
               

               
            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Add description piece to a item
« Reply #4 on: May 16, 2014, 05:52:12 am »


               

You could apply a description to a set item you give the player, perhaps with a scroll icon, and give it a UNIQUE TAG.


 


Let's get to your first issue.



void main()
{

//After declaring objects etc.

string sDesc = GetDescription(oSword);


SetDescription(oSword, sDesc + " Enchanted by the blacksmith.");

Try flipping your SetDescription() around. I assume you've declared oSword somewhere in your script.



string sDesc = GetDescription(oSword);
          sDesc += "Enchanted by the blacksmith.";
SetDescription(oSword, sDesc);
 

You might need to set up a CustomToken for carriage RETURN for descriptions. If so, you can then use "\n \n" in descriptions for hard returns to space out descriptions. Just place the CustomToken in your OnModuleLoad event.



SetCustomToken(1111, "\n"); //carriage return

An example:



sDesc +="\n \nEnchanted by the blacksmith.";

This would dump two hard carriage returns after the sword's normal description, followed by Enchanged by the blacksmith.


 


Whenever you want to append text to a description, you must always get that description first. Store it, then add to it, then store it again.



string sDesc = GetDescription(oSword);
          sDesc += "\n \nUpgraded by the Swamp Hag.";
          SetDescription(oSword, sDesc);

Thus, after the above examples, the description would be:


 


"Longsword given by your father longtime ago bla bla bla"


 


 


"Enchanted by the blacksmith."


 


 


"Upgraded by the Swamp Hag."


 


 


For your second request, you'll need to have something that we can tell the script, "Hey! They picked a Unicorn!". Setting a variable would be easy enough. Then, in the script we set the description to the item, we'd use a variable check.


 


if (GetLocalInt(GetFirstPC(), "birthsign") == 1) // 1 equals UNICORN; 2 equals SPIDER; 3 equals BEAR ... etc
        {
        string sDescription = GetDescription(oBirthSign); // oBirthSign would need to be declared.
        sDescription += "Your Birthsign is that of the majestic and peace dwelling Unicorn.";
        SetDescription(oBirthSign, sDescription);
        }
 
if (GetLocalInt(GetFirstPC(), "birthsign") == 2) // 1 equals UNICORN; 2 equals SPIDER; 3 equals BEAR ... etc
        {
        string sDescription = GetDescription(oBirthSign); // oBirthSign would need to be declared.
        sDescription += "Your Birthsign is that of a lurking and web spinning arachnid.";
        SetDescription(oBirthSign, sDescription);
        }

 


FP!



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Add description piece to a item
« Reply #5 on: May 16, 2014, 02:16:00 pm »


               

Nebril2: What you have should work. I use it all the time. Are you setting the "given by your father bla bla" as the unidentified or identified description? Try putting something like SendMessageToPC(GetFirstPC(), "got orig description '" + sDesc + " ' "); between your Get and SetDescription.  This'll show that you are getting the original description.


 


FP: Your suggestion about flipping it around should have the exact same effect as the original code.  And you don't need to setup any custom tokens to use "\n" in a string.  That may be required to use it in a dlg file. But for scripts and such you can just put "\n" in the string.  Otherwise , the "\n" thing is a helpful suggestion.



               
               

               
            

Legacy_Nebril2

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Add description piece to a item
« Reply #6 on: May 16, 2014, 03:27:55 pm »


               

Ya, it worked nicely and soft!


 


Thank you very much for the help guys!! 


               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Add description piece to a item
« Reply #7 on: May 16, 2014, 06:46:41 pm »


               


FP: Your suggestion about flipping it around should have the exact same effect as the original code.  And you don't need to setup any custom tokens to use "\n" in a string.  That may be required to use it in a dlg file. But for scripts and such you can just put "\n" in the string.  Otherwise , the "\n" thing is a helpful suggestion.




 


Correct, the replacing of "\n" with the line break is part of the script compiling.  If I were to take the "\n" from another source (e.g. having manually put "\n" into and item description and retrieving it by scripted command) the retrieval would be the two character "\n" and not the line break.  Further if I were to put "\" + "n" into a script the compiler would not give me the line break character, but would instead replace the "\" with the null string "" and then add the "n" to give a result of "n".