Aller au contenu

Photo

Using " as part of a string


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

#1
BartjeD

BartjeD
  • Members
  • 249 messages
Is it possible to use the " character as part of a string? Is there someway to prevent the script editor from reading it as the beginning or end of a string?

I'm trying to sent a tell by using Speakstring /tell "playername" message


Thanks in advance :D

Modifié par BartjeD, 16 octobre 2011 - 10:46 .


#2
The Fred

The Fred
  • Members
  • 2 516 messages
I think you can escape it with a backslash, so \\". Otherwise you could use single quotes to open and close the string, with double quotes inside. One of those ought to work, haven't used either (at least recently) though.

#3
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
I don't know of an easy way to do it, single quotes seem to be what we are limited to.

I have this workaround, basically i put it into a variable on my module, and for modules that are not mine i have a waypoint blueprint dedicated to me being able to get this.

string CSL_QUOTE = "";

/**  
* Returns a Quote Character. Note must have quote defined in the module or on custom waypoint blueprint to properly do quotes.
* @author Brian Meyer
* @return A Double Quote Character
*/
string CSLGetQuote()
{
	//string sQuote = CSL_QUOTE;
	if ( CSL_QUOTE == "" )
	{
		string sQuote;
		sQuote = GetLocalString( GetModule(), "CSL_QUOTE" );
		if ( sQuote == "" )
		{
			object oQuoteHolder = CreateObject(OBJECT_TYPE_WAYPOINT, "nw_waypointquote", GetStartingLocation(), FALSE, "nw_waypointquote"); 
			sQuote = GetLocalString( oQuoteHolder, "QUOTE" );
			DestroyObject(oQuoteHolder, 0.0f, FALSE);

			SetLocalString(GetModule(), "CSL_QUOTE", sQuote );
		}	
		CSL_QUOTE = sQuote; // cache this for later use in the same script
		return sQuote;
	}
	return CSL_QUOTE;
}