Welcome Forums General Single and double quotation marks Reply To: Single and double quotation marks

#34442
Marby
Moderator

I’ll explain, why I wrote this:
Yes it is nice, but only because the interpreter cannot do pretty much for us at its current state. If the functionality grows, that way to interpret quotation marks will cause problems at some point. Imagine, we would like to show the content of number variables in our dialogs. If the RPG Playground language behaves like a typical programming language, this could look like the following in the future:

hero says "Yes, I already helped the kid. She told me: 'I never expected, you'd even purchase " + hero number of "flowers" + "'!"

For the interpreter this contains the following elements:

  • hero says
  • “Yes, I already helped the kid. She told me: ‘I never expected, you’d even purchase “
  • +
  • hero number of “flowers”
  • +
  • “‘!”

With only single quotes, the engine is able to process this. Now imagine double quotes in the dialog:

hero says "Yes, I already helped the kid. She told me: "I never expected, you'd even purchase " + hero number of "flowers" + ""!"

Now the engine can no longer find out which text belongs to the dialog and which contains statements or accesses to variables.

This is because it starts for an interpreter now with the following parts:

  • hero says
  • “Yes, I already helped the kid. She told me: “
  • I
  • never”
  • expected
  • ,

… and so on. “I”, “never”, “expected” and the other words will be interpreted now as identifiers or function names and not anymore as constants.

In order to overcome this, programming languages often introduces escape sequences. If we use them our say-command could look like that:

hero says "Yes, I already helped the kid. She told me: \"I never expected, you'd even purchase " + hero number of "flowers" + "\"!"

As long as we have not a more complex programming language for RPG Playground this is okay. However, if @deWiTTERS introduce variables and functions as a return value he has to come up with something.

I would like to have a hint, if we may use double quotation marks in our texts or better not. Keep in mind, your game will not work properly anymore, if screenplay suddenly gets interpreted in a more complex context and you did not use quotation marks a way a programmer also would do. Therefore, this topic must not be forgotten and at least @deWiTTERS should think about.