400 arrays of 400 values Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

400 arrays of 400 values

17 Feb 2018, 18:32

Hello, i have a mapdata i made that is binary:
0=walkable cell
1=non-walkable cell

The thing is that this map is 400x400, trying to define this as 400 arrays of 400 values each one gives me the error that the expression is too long.
What i do is make 400 arrays (those are the Ys) with 400 values each (those are the Xs)
The thing is that i need to read this map like this:

Code: Select all

clickedcell:=array%Ycell%[Xcell]
if clickedcell=1
msgbox You can't walk there, please pick another cell
else
movecharacter(Xcell, Ycell)
Any ideas or something i can make?
i will paste the first array only to show how i'm declaring it. (i don't think you want 400 arrays here haha)

Code: Select all

array1:=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: 400 arrays of 400 values  Topic is solved

17 Feb 2018, 18:43

Here are two ideas that I might consider. Cheers.

Code: Select all

q:: ;create array / list contents
vText := " ;continuation section
(
abcd
efgh
ijkl
mnop
)"

;create array
oArray := StrSplit(vText, "`n")

;list an example
MsgBox, % SubStr(oArray[3], 3, 1)

;list contents
vOutput := ""
for vKey, vValue in oArray
	Loop, Parse, vValue
		vOutput .= A_LoopField
MsgBox, % vOutput

;create array
oArray := {}
Loop, Parse, vText, `n
	oArray[A_Index] := StrSplit(A_LoopField)

;list an example
MsgBox, % oArray[3, 3]

;list contents
vOutput := ""
for vKey, vValue in oArray
	for vKey2, vValue2 in vValue
		vOutput .= vValue2
MsgBox, % vOutput
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: 400 arrays of 400 values

17 Feb 2018, 23:07

jeeswg wrote:Here are two ideas that I might consider. Cheers.

Code: Select all

q:: ;create array / list contents
vText := " ;continuation section
(
abcd
efgh
ijkl
mnop
)"

;create array
oArray := StrSplit(vText, "`n")

;list an example
MsgBox, % SubStr(oArray[3], 3, 1)

;list contents
vOutput := ""
for vKey, vValue in oArray
	Loop, Parse, vValue
		vOutput .= A_LoopField
MsgBox, % vOutput

;create array
oArray := {}
Loop, Parse, vText, `n
	oArray[A_Index] := StrSplit(A_LoopField)

;list an example
MsgBox, % oArray[3, 3]

;list contents
vOutput := ""
for vKey, vValue in oArray
	for vKey2, vValue2 in vValue
		vOutput .= vValue2
MsgBox, % vOutput
return
Thank you! 1 or 2 minutes before you answered this i tried copying the mapdata to a txt and then doing the following:

Code: Select all

loop, 400
{
FileReadLine, aux, Town.txt, %asdf%
mapy%a_index%:= StrSplit(aux, ",", " `t" "]" "[")
asdf--
}
return
and works! But needs a file outside the exe.
And yours is better if i need everything in 1 exe (and i do) so that's the way to do it. Thank you!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Joey5, JPMuir, matt101, Thorlian and 168 guests