Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: warren on April 02, 2015, 08:59:38 PM

Title: Quotes in text
Post by: warren on April 02, 2015, 08:59:38 PM
How do you get double quotes into strings in CRPL?
Title: Re: Quotes in text
Post by: knucracker on April 02, 2015, 09:11:38 PM
You can't....
Consider using a single quote instead for any messages you want to show.
Title: Re: Quotes in text
Post by: warren on April 02, 2015, 10:30:15 PM
Okay.
Title: Re: Quotes in text
Post by: Grayzzur on April 02, 2015, 10:37:54 PM
Never say "never."


"""" 1 1 Substring ->QUOTE

<-QUOTE "Hello World" <-QUOTE Concat Concat SetPopupText

TRUE SetPopupTextAlwaysVisible


I'm not sure what causes it, but there appears to be a bug where as long as a string contains ONLY double quotes, and ONLY and even number of them, they get through. Use Substring to chop it down to one, and sprinkle liberally.

I can't recommend actually using it though, as future patches to the game could "fix" the bug, and then your maps might break.
Title: Re: Quotes in text
Post by: warren on April 03, 2015, 03:54:05 AM
Holy **** that is cool.
Title: Re: Quotes in text
Post by: planetfall on April 03, 2015, 09:13:59 AM
Alternatively you could give the script an input variable and type in a double-quote in the editor. Though that may get tedious if it's on several cores.
Title: Re: Quotes in text
Post by: knucracker on April 03, 2015, 09:51:34 AM
Quote from: Grayzzur on April 02, 2015, 10:37:54 PM
Never say "never."


"""" 1 1 Substring ->QUOTE

<-QUOTE "Hello World" <-QUOTE Concat Concat SetPopupText

TRUE SetPopupTextAlwaysVisible


I'm not sure what causes it, but there appears to be a bug where as long as a string contains ONLY double quotes, and ONLY and even number of them, they get through. Use Substring to chop it down to one, and sprinkle liberally.

I can't recommend actually using it though, as future patches to the game could "fix" the bug, and then your maps might break.

Ha... that is interesting,  I'd have thought that might be an empty string but thinking about how it gets parsed... yeah I guess so :)
"""" forms a single token.  I got lucky because the parser looks to see if the token starts with a quote.  If so, it looks at the end to make sure it ends with a quote.  Then it takes what is in the middle as a string.  I've not looked but there might be another check in the parser to look for an even number of quotes in a token as well.

The editor trick sounds interesting too.

This all goes to show that I'm officially not the best player, or even the best scripter :)  (I usually lose that first title on the first day of Alpha testing)

Title: Re: Quotes in text
Post by: Grayzzur on April 03, 2015, 12:31:01 PM
Quote from: virgilw on April 03, 2015, 09:51:34 AM
This all goes to show that I'm officially not the best player, or even the best scripter :)  (I usually lose that first title on the first day of Alpha testing)
Without you there'd be no competition at all, and for that we thank you!
Title: Re: Quotes in text
Post by: Telanir on April 07, 2015, 02:59:41 AM
I thought that was pretty neat, I made a little comment on the Wiki here (https://knucklecracker.com/wiki/doku.php?id=crpl:docs:concat) for this in case anyone else wonders. :)