[SOLVED]array_2d and writing

RODO

Member
hello guys, I have a problem that I am getting confused and having trouble understanding, and I would like your help. I am studying together with my teacher (video lessons, they are not live just to make this part clear) dialogue system, I am stuck in one part, this part is unique in the video where mine goes wrong and my teacher works normally even copying and trying to keep up with him

The part in question is: I'm using an array_1d and array_2d system, 1d for dialogue and 2d for multiple choices. Every time I run the code with the array_1d dialog system, it works normally, until quite quiet, but when I move to 2d it gives the problem, complaining that it expects a string (code below for better understanding):
1618222286902.png
where I marked in green is where I had to make changes, passing the value "txt [pag]" to string, because Game Maker was stating that it was giving a problem because it was not or that I expected a string there

NOTE: it appears this error ONLY in array_2d, in array_1d this error does not even exist

So i did what he asked and fixed the problem .... in parts. Now my dialog system below (don't mind if it is really messy, I'm fixing and testing it yet, so it's normal for him to be like this) is showing like this, with bars and shavings, that it is not how I would like it to be:
1618222693703.png

is there a way to take them out or do with array_2d don't complain that n is a string? already tried to put it inside another array to see if it corrected but he types the same way, if someone can help me and explain even better how array_2d works I am very grateful
 
Are you working with Game Maker 1.4 or 2.3? array_1d and array_2d functions have been deprecated in 2.3.

Otherwise, try what Nidoking says above.
 

RODO

Member
[UPDATE] hello guys, so i tried what you guys told me, to be honest i didn't solve the problem but, with your help i could locate the real problem, if it weren't for that i would be destroying my code for an error that wasn't quite what I wanted to correct, I think you understand.

well, the real problem here is that: my code / command is not writing the information dialog inside array_2d correctly. Basically, instead of writing what is inside the array, it digits the array itself, example:

array [0] [0] = "hello"

passing through the code he should type:

Hi

but even though it passes through it, the array types:

["Hi"]


And this is what I would like your help with, how can I enter the information of array_2d?

NOTE: I tried to use array_get but it runs wrong anyway

I will be grateful for the help and sorry for the inconvenience
 

gnysek

Member
In GMS < 2.3 [0][0] is a specific case, if you didn't defined any other 2D field, then array is still 1-dimensional. array[0][0] = "hello", array [0][1] = "hi" should work ok.
 

Nidoking

Member
passing through the code he should type:

Hi

but even though it passes through it, the array types:

["Hi"]
That is a two-dimensional array, yes. You need to use two indices to retrieve the value as well. How, precisely, are you attempting to retrieve the string that you put into the array? If you put it in using [0][0], why are you not using [0][0] to get it back?
 

RODO

Member
[SOLVED] well, I took all the information and tips you gave me and I managed to make it work, changed it and made the code more flexible, now it works as I would like, thank you very much for everyone's help, I am very grateful:


(print of how it was )

1618328083734.png
 
Top