Error in this specific code? (Easy to Read Color Coding)

M

MotherlandRuskiushi

Guest

if
(currCharIndes < string_length(text[convoIndex, 1]) +1);​
{
spriteToDisplay = dialogue[convoIndex, 0];
stringToDisplay += string_char_at(dialogue[convoIndex, 1], currCharIndex++);​

else // ( The Error is here apparently, why?)
{
if (keyboard_check_pressed(vk_space))​
{
convoIndex++;
stringToDisplay = "";
currCharIndex = 1;​
if (convoIndex == convodialogueCount)​
{
active = false;​
}
}

}
 
Last edited by a moderator:
if (currCharIndes < string_length(text[convoIndex, 1]) +1);{ spriteToDisplay = dialogue[convoIndex, 0];
stringToDisplay += string_char_at(dialogue[convoIndex, 1], currCharIndex++);
else // ( The Error is here apparently, why?)
I'm guessing it is because you are missing the } before the else.
Would be helpful if you would post code in code tags (the guidelines have how to do that), and if you are getting an error you should really be showing us what the error is.
 
The error is actually here:

if (currCharIndes < string_length(text[convoIndex, 1]) +1);
If statements don't have a semi-colon at the end if you want them to be any use.

Because you have a semi-colon, GMS treats it as the end of the if() statement, so when it see the rogue "else" further down below with no matching if() previously, it throws an error.

Edit: @BaBiA Game Studio is also correct, you are missing a } there.
 
It would have been a lot easier to spot all the problems if the actual error message had been provided, and if there was no colouring of text being done.
 

TsukaYuriko

☄️
Forum Staff
Moderator
Even the fanciest color coding won't make code readable when you have three closing curly braces (and all of them in general) on the same horizontal position because you didn't wrap them in a code tag and the blank space filter gobbled them up. I can see the original formatting when editing the post, but... :p

You can find further information regarding how to most efficiently post code and questions in general in the guidelines and How to Q&A.
 
D

dannyjenn

Guest
I like the color coding :) But yeah, users BaBiA Game Studio and TsukaYuriko make some good points.

Also, in addition to the two problems which have already been mentioned, I see that on the first line you misspelled currCharIndex as currCharIndes. That has nothing to do with the error you're getting, but it will cause problems if you don't fix it. I'm not sure if anything else is wrong.
 
M

MotherlandRuskiushi

Guest
I'm guessing it is because you are missing the } before the else.
Would be helpful if you would post code in code tags (the guidelines have how to do that), and if you are getting an error you should really be showing us what the error is.
The error is actually here:



If statements don't have a semi-colon at the end if you want them to be any use.

Because you have a semi-colon, GMS treats it as the end of the if() statement, so when it see the rogue "else" further down below with no matching if() previously, it throws an error.

Edit: @BaBiA Game Studio is also correct, you are missing a } there.
It would have been a lot easier to spot all the problems if the actual error message had been provided, and if there was no colouring of text being done.
Even the fanciest color coding won't make code readable when you have three closing curly braces (and all of them in general) on the same horizontal position because you didn't wrap them in a code tag and the blank space filter gobbled them up. I can see the original formatting when editing the post, but... :p

You can find further information regarding how to most efficiently post code and questions in general in the guidelines and How to Q&A.
I like the color coding :) But yeah, users BaBiA Game Studio and TsukaYuriko make some good points.

Also, in addition to the two problems which have already been mentioned, I see that on the first line you misspelled currCharIndex as currCharIndes. That has nothing to do with the error you're getting, but it will cause problems if you don't fix it. I'm not sure if anything else is wrong.
Thank you all for your helpful replies, I now changed the subject as I completely fixed the problem. Now I just have a normal question

New problem, I want to enter a new room (for story telling purposes) after I'm done talking to an NPC.

(Context: The child (player) finds himself in a pitch-black area, in front of him is a man in red; he is bald. The child (player) speaks to him, and is then asked if he is lost. After a brief conversation, the man begins to explain what he means by "lost".) And that's where I want to go to a new room.​
 

TsukaYuriko

☄️
Forum Staff
Moderator
(Please don't change topic titles or contents after problems have been solved. I reverted the topic to its original state to avoid confusion.)

New problem, I want to enter a new room (for story telling purposes) after I'm done talking to an NPC.

(Context: The child (player) finds himself in a pitch-black area, in front of him is a man in red; he is bald. The child (player) speaks to him, and is then asked if he is lost. After a brief conversation, the man begins to explain what he means by "lost".) And that's where I want to go to a new room.
You've only told us what you're trying to do, but not what issues you're facing with this. Please let us know what you have tried and which problems you ran into so that we can help you resolve them.​
 
Top