Need help with commas in expressions

PapiDimmi
06 Dec 2015, 05:45
Hello!

I want to use this expression as shown in one of the official tutorials, but I want to move the comma.

This works great: "You say \"" + text + "\", but nobody replies."

The problem is that I want to remove the comma before "but" so it is placed within the quotes, but I can't do it.
I always get an error when trying to put the comma within the quotes.

Please help!

OurJud
06 Dec 2015, 05:53
I'm not sure myself, but may I ask for what reason you want to do this? If you put the comma inside the quotes, the sentence will look exactly the same anyway.

The + text + part of this repeats whatever the player types, so where exactly are you wanting the comma to be placed in the sentence?

As it stands, if the player types "Say hello", the response will be, "You say "hello", but nobody replies." So how are you wanting the sentence to read?

PapiDimmi
06 Dec 2015, 05:55
I want the sentence to read:
You say "hello," but nobody replies.

OurJud
06 Dec 2015, 06:11
Mmm. You're right. That is the way the sentence should be written, grammatically speaking. Unfortunately I'm not sure it's possible, because anything you add between \"" + text + "\" will cause an error in the syntax.

PapiDimmi
06 Dec 2015, 06:13
Aw, that's too bad.
I was hoping there was a way to add something inbetween those quotation marks.

OurJud
06 Dec 2015, 06:23
Don't give up hope yet. I'm by no means an authority on this game.

Wait for the someone who knows more than me to confirm it.

HegemonKhan
06 Dec 2015, 10:18
the secret trick of writing msg expressions (text+VARIABLES):

break it up into chunks

there's two types of chunks:

1. "text"
2. +VARIABLES+

for example:

HK is a 18 year old adult male human warrior.

player.alias = "HK"
player.age_integer = 18 // I wish I was 18, lol
player.age_string = "adult"
player.sex = "male"
player.race = "human"
player.class = "warrior"

msg (player.alias + " is a " + player.age_integer + " year old " + player.age_string + " " + player.sex + " " + player.race + " " + player.class + ".")

the chunks: 12

01) player.alias +
02) " is a "
03) + player.age_integer +
04) " year old "
05) + player.age_string +
06) " "
07) + player.sex +
08) " "
09) + player.race +
10) " "
11) + player.class +
12) "."

--------------------------

see if you can understand this, and then apply it to the string in your post

the backslash ( \ ) is called an 'escape' character, it allows you to display characters that you normally wouldn't be able to display (and it does other things too, like a newline, tab, etc --- not sure what quest has programmed into it though). So, \", causes the double quote to be displayed. The backslash~escape character is always on the left side and the character that goes with it is on its right side.

but, if you can't figure it out:

the chunks:

"You say \"" // Outputs: You say "
+ text + // Outputs (example): hello // You say "hello
",\" but nobody replies." // Outputs: ," but nobody replies. // You say "hello," but nobody replies.

"You say \"" + text + ",\" but nobody replies."
// outputs: You say "hello," but nobody replies.

The Pixie
06 Dec 2015, 10:34
PapiDimmi wrote:Hello!

I want to use this expression as shown in one of the official tutorials, but I want to move the comma.

This works great: "You say \"" + text + "\", but nobody replies."

The problem is that I want to remove the comma before "but" so it is placed within the quotes, but I can't do it.
I always get an error when trying to put the comma within the quotes.

Please help!

Try this:

"You say \"" + text + ",\" but nobody replies."

What you have is three chunks of a string:

You say \"
text
,\" but nobody replies.


... which are added together with the plus sign. The first are last are "literal" strings, which means they are what they are, the middle is, of course a variable. The literal strings have to have double quotes at the start and end to tell Quest what they are. That means you need something else to have a double quote appear in the text.

The bit \" does that. That means you need to keep the \ and the " together; together they mean show a double quote. Therefore, you need to moe the comma before them, but after the first " of that chunk.

OurJud
06 Dec 2015, 11:24
Told you not to give up hope. These people have a solution for every problem.

PapiDimmi
06 Dec 2015, 17:37
The Pixie wrote:

"PapiDimmi"

Hello!

I want to use this expression as shown in one of the official tutorials, but I want to move the comma.

This works great: "You say \"" + text + "\", but nobody replies."

The problem is that I want to remove the comma before "but" so it is placed within the quotes, but I can't do it.
I always get an error when trying to put the comma within the quotes.

Please help!


Try this:

"You say \"" + text + ",\" but nobody replies."

What you have is three chunks of a string:

You say \"
text
,\" but nobody replies.


... which are added together with the plus sign. The first are last are "literal" strings, which means they are what they are, the middle is, of course a variable. The literal strings have to have double quotes at the start and end to tell Quest what they are. That means you need something else to have a double quote appear in the text.

The bit \" does that. That means you need to keep the \ and the " together; together they mean show a double quote. Therefore, you need to moe the comma before them, but after the first " of that chunk.


Wow, thank you very much! That works perfectly!

OurJud
06 Dec 2015, 17:53
HegemonKhan wrote:
the chunks:

"You say \"" // Outputs: You say "
+ text + // Outputs (example): hello // You say "hello
",\" but nobody replies." // Outputs: ," but nobody replies. // You say "hello," but nobody replies.

"You say \"" + text + ",\" but nobody replies."
// outputs: You say "hello," but nobody replies.

This is handy to have, as I'm a stickler for correct punctuation, too.

XanMag
08 Dec 2015, 20:26
Just throwing this out there... I asked the grammar Nazi at school how to punctuation that sentence... She said it should be:

You say, "Hello", but no one replies.

Not sure if that is correct but I'd be surprised if it isn't (or at least an acceptable alternative).

PapiDimmi
08 Dec 2015, 20:33
XanMag wrote:Just throwing this out there... I asked the grammar Nazi at school how to punctuation that sentence... She said it should be:

You say, "Hello", but no one replies.

Not sure if that is correct but I'd be surprised if it isn't (or at least an acceptable alternative).

There is should be no comma after "say" at all, the capital H is optional at best, and the comma should be within the quotation marks.

By the way, it's spelled Grammar Nazi with a capital G since it's a title, and titles are always capitalized.

The Pixie
08 Dec 2015, 21:39
I agree with PapeDimmi the comma goes in the quotes
http://www.oxforddictionaries.com/words ... ect-speech

But with XanMag about the capital H, and the the comma after "you say"
http://www.grammarly.com/handbook/mecha ... ce-that-i/

OurJud
08 Dec 2015, 21:56
Yes, I third the comma inside the speech marks. I also concur with the capital H, but not with the comma after 'say'.

PapiDimmi
09 Dec 2015, 01:47
I thought the capital H was optional, not required, since it was just one word.
It might very well be required, so I do agree with it.

Still, there should be no comma after "and" as it makes absolutely no sense whatsoever, and the comma should be placed within the quotation marks.

I'm pretty sure I cannot make the first letter of the word or sentence within the quotation marks a capital letter, though.
The comma is still more important.
I don't know, maybe I can, but I don't think so.

XanMag
09 Dec 2015, 03:28
Haha.

If it were my game I probably would have written it as: You speak but no one gives a damn enough to answer. Go figure.

But I'm a smart ass like that. :lol:

PapiDimmi
09 Dec 2015, 03:31
XanMag wrote:Haha.

If it were my game I probably would have written it as: You speak but no one gives a damn enough to answer. Go figure.

But I'm a smart ass like that. :lol:

Haha, that's amazing.

By the way, whilst we're on the topic of grammar, you need a comma before "but."

You speak, but no one gives a damn enough to answer.

XanMag
09 Dec 2015, 03:40
That's debatable, too.In many instances now it is acceptable to even write that previous sentence as - That's debatable too. Sometimes the rule is that a comma is used if the writer wishes there to be a pause. Correct? And in informal message boards I can but a comma here, if I like. Or, there. Or not at all. :D

XanMag
09 Dec 2015, 03:48
Reminds me of one of my favorite movie scenes. https://www.youtube.com/watch?v=bitPep8Gjz8
=)

Father thyme
09 Dec 2015, 07:14
I think there should be no comma after 'say'. A comma denotes a pause, it makes it look as if you were not sure what to say, and had to think about something as simple as 'hello." The comma after the quotes just does not look right, it looks as if it's not sure where it belongs. Having said that I have difficulty with commas.

OurJud
09 Dec 2015, 09:21
Father thyme wrote:Having said that I have difficulty with commas.

So does Arnold J Rimmer :D

https://www.youtube.com/watch?v=wWUWIxNduxA

PapiDimmi
09 Dec 2015, 10:38
It's funny how a question about how to move the comma within the quotes has turned into this big discussion about grammar.

You can stop now, guys.