Aller au contenu

Photo

using "\\n" in a description.


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

#1
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Normally when using the function SetDescription you can add "\\n" to drop down to a new line for more text. I made a chat command that takes the typed text from the chat bar and turns it into a string and sets that as a description on an object.

I was hoping that if a player added "\\n" to what they were typing they could make the description look nicer but it isn't working. The text just shows the characters "\\n".

Is there a certain way that one can type something like this in the chat bar that is different from a string that you'd put in a script manually? I don't understand why this doesn't work.

Thanks in advance for any help.

Modifié par GhostOfGod, 23 mars 2011 - 09:33 .


#2
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
Pop open a text entry screen and let them type into that.

Either that or search for any \\n or perhaps <br> if you want and replace them with new lines.

#3
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Thanks pain. I'll look into these options. I know <br> doesn't work. And I'm new to NWN2 so not sure yet how I'd do the text entry screen. I'm trying to avoid more widgets and pctools. Just typing the description in the chat bar is the simplest way so far.

Thanks again.

#4
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
it does not work, however you replace them afterwards with a scripted \\n and it does work.

#5
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Right on. I'll give that a shot. Thanks pain.

#6
dethia

dethia
  • Members
  • 146 messages
Hi Ghost Of God. Can you explain a bit more what you are trying to do. In general you will not be able to enter a new line character into the description as it doesn't get formatted in the same way as other strings.

I had a similar problem but before I tell you how I resolved it let me just put in perspective what I was trying to achieve. The descriptions we were using were completely custom and had nothing to do with the way the game generates descriptions, they would stored on an item as a variable and then assigned to the examine gui text field.

Now to circumvent the problem the toolset or in-game engine does recognise the \\n character as strings so I made a simple ReplaceString function which allowed us to use a custom new line character <n> in our case, replaced it via script with the \\n character which would be recognized as a new line and formatted as such and after all that was done assigne the actual formatted string to the description field.

I am fairly certain I can help you resolve whatever issue you are having but I would need to know a lot more information as to how you generate the description, where it comes up (from items in inventory etc....). It's not difficult at all but is also very scope specific.

#7
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Thanks for the reply and info dethia.

Basically what i have is an item that when used creates a merchant stall for players at their location. If they use the item a second time it destroys the merchant stall.
I then used the OnChat event to make a custom command to let players give the created merchant stall a new description. This way they can put what they are selling and for how much etc..But I wanted the player to be able to drop the text down to a new line in the description so they could separate the items they were selling, and typing the "\\n" in the chat bar wasn't converting over to the string in the OnChat event.
I took pain's advice and what looks like the same thing you did and got it working. I jacked the ReplaceString function from NWN1. Now the player can just type a ";", which then gets replaced by "\\n", to drop to a new line.

#8
The Fred

The Fred
  • Members
  • 2 516 messages
I expect that anything the player types in is already handled to be a "normal" string. So if they type in a slash, \\, it probably comes in as an escaped slash (e.g. \\\\). So \\n will be an actual string rather than a special character.

#9
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Hmm..would it then spit it back out as a "normal" string? Just for fun I sent the message back out to the player using the SendMessageToPC function and it didn't show any changes.

I'm not really sure how that works. My knowledge of code is limited to nwnscript.

Also while on the subject of strings I was going to start another post but I will try to just keep it to this one...
I'm not sure how the colors work for strings in NWN2 scripting. I was reading the wiki and I see how you can change a specific strings color using html. If i wanted a constant in my script would I just do:

const string COLOR1 = "<color=blue>";

I know with nwn1 you had to do something like:

const string COLOR1 = "<cyyy>";

Could i also use Hexidecimal at all? #FF3399

And then I see there are already some color constants in the Globals list.
It's all soo confusing.

Modifié par GhostOfGod, 24 mars 2011 - 12:38 .


#10
Dann-J

Dann-J
  • Members
  • 3 161 messages
You can use hexidecimals, in the form of <color=#000000>. Here's a handy online hex colour chart:
http://www.december....spec/color.html

See also this thread:
http://social.biowar...-5336569-1.html

Here's a visual representation of the colour constants defined in NWN2_Colors.2DA:
http://www.worldofal....uk/colours.htm

Modifié par DannJ, 24 mars 2011 - 02:23 .


#11
The Fred

The Fred
  • Members
  • 2 516 messages
In NWN2 you had to use a sort of hexadecimal or similar (some sort of other base, anyway), where, IIRC, the character's ASCII value was a constant value greater than a fraction of each colour channel that character represented (convoluted, huh?). In NWN2 that's not necessary - in fact, I don't think it actually works. I remember I had made a Nabassu in NWN1 for which I had faked combat messages using this (to avoid the need for custom content) and when I ported it over to NWN2, I had to change the color system. I think hexadecimal works, though.

#12
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
That is exactly what I needed. Thank you very much guys.

#13
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Double post.  :whistle:

Modifié par GhostOfGod, 24 mars 2011 - 03:16 .


#14
The Fred

The Fred
  • Members
  • 2 516 messages
Argh, ninjad by DannJ! Must post faster!

#15
Dann-J

Dann-J
  • Members
  • 3 161 messages
If anyone is interested, I've uploaded a PDF to the vault with all of the predefined NWN2 colour names:
http://nwvault.ign.c...r.Detail&id=279

I modified the HTML table from this link (with all due credits):
http://www.worldofal....uk/colours.htm

Modifié par DannJ, 27 mars 2011 - 09:22 .


#16
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

DannJ wrote...

If anyone is interested, I've uploaded a PDF to the vault with all of the predefined NWN2 colour names:
http://nwvault.ign.c...r.Detail&id=279

I modified the HTML table from this link (with all due credits):
http://www.worldofal....uk/colours.htm



Hi DannJ,

That link takes me back a bit .... It was one of the first web pages that I ever put up. Posted Image

Lance.