Aller au contenu

Photo

Add description piece to a item


  • Veuillez vous connecter pour répondre
7 réponses à ce sujet

#1
Nebril2

Nebril2
  • Members
  • 59 messages

Hi all!! :)

 

 

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  :)

 

 

 



#2
Tchos

Tchos
  • Members
  • 5 089 messages

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.



#3
henesua

henesua
  • Members
  • 3 883 messages

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()



#4
Nebril2

Nebril2
  • Members
  • 59 messages

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)



#5
Fester Pot

Fester Pot
  • Members
  • 1 395 messages

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!


  • Rolo Kipp aime ceci

#6
meaglyn

meaglyn
  • Members
  • 815 messages

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.


  • Rolo Kipp aime ceci

#7
Nebril2

Nebril2
  • Members
  • 59 messages

Ya, it worked nicely and soft!

 

Thank you very much for the help guys!! 



#8
WhiZard

WhiZard
  • Members
  • 1 204 messages

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".