AlmarM Posted June 22, 2010 Share Posted June 22, 2010 Hiya! I tried making a 2DArray in autoit and im confused now. Could someone help me a hand? #include <Array.au3> Global $Array[10, 10] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] _ArrayDisplay($Array) AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Juvigy Posted June 22, 2010 Share Posted June 22, 2010 (edited) Global $Array[7][10] = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],[1, 0, 0, 0, 0, 0, 0, 0, 0, 1],[1, 0, 0, 0, 0, 0, 0, 0, 0, 1],[1, 0, 0, 0, 0, 0, 0, 0, 0, 1],[1, 0, 0, 0, 0, 0, 0, 0, 0, 1],[1, 0, 0, 0, 0, 0, 0, 0, 0, 1],[1, 0, 0, 0, 0, 0, 0, 0, 0, 1]] _ArrayDisplay($Array) Edited June 22, 2010 by Juvigy Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted June 22, 2010 Share Posted June 22, 2010 You use a underscore to continue lines.Here's how it should look:#include <Array.au3> Global $Array[10][10] = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]] _ArrayDisplay($Array)If you think the helpfile isn't very good at teaching arrays, there's a tutorial in the wiki LINK .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
AlmarM Posted June 22, 2010 Author Share Posted June 22, 2010 (edited) Found. #include <Array.au3> Global $Array[10][10] = [ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] ] _ArrayDisplay($Array)Thanks Juvigy.EDIT: Oh, didn't saw AdmiralAlkex's post. EDIT: So why isn't this working?expandcollapse popup#include <Array.au3> Global $Array[10][10] = [ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], _ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] ] $GUI = GUICreate("", 320, 320) For $y = 0 To 10 For $x = 0 To 10 If ($Array[$y][$x] == 0) Then GUICtrlCreatePic(@DesktopDir & "\floor.jpg", $x * 32, $y * 32, 32, 32) EndIf If ($Array[$y][$x] == 1) Then GUICtrlCreatePic(@DesktopDir & "\wall.jpg", $x * 32, $y * 32, 32, 32) EndIf If ($Array[$y][$x] == 2) Then GUICtrlCreatePic(@DesktopDir & "\prop.jpg", $x * 32, $y * 32, 32, 32) EndIf If ($Array[$y][$x] == 3) Then GUICtrlCreatePic(@DesktopDir & "\player.jpg", $x * 32, $y * 32, 32, 32) EndIf Next Next GUISetState() While 1 Switch GUIGetMsg() Case -3 Exit EndSwitch WEndC:\Documents and Settings\--\Bureaublad\Nieuw - AutoIt v3 Script.au3 (18) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: If ($Array[$y][$x] == 0) Then If (^ ERRORFound it. Edited June 22, 2010 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now