CheeseBiscuit Posted February 1, 2014 Posted February 1, 2014 I am trying to make a map with little 16x16 rects for each 'coordinate'. Now I have the map size already set in a two dimensional array, and another array that will hold the GUI Graphic ID so I can loop through them and tell whether one was clicked or not (If it was clicked then change the graphic color and set ANOTHER two dimensional array value at the position of the map coordinate). But besides that I can't seem to get past this "Array badly formatted error"... My code: expandcollapse popup;----INCLUDES----; #include <GUIConstantsEx.au3> #include <GUIConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <array.au3> Global Const $mapX = 51 Global Const $mapY = 31 Global Const $IMGX = 16 Global Const $IMGY = 16 Global $labryinthMap[$mapY,$mapX] ;Our maze Global $GUID[$mapY,$mapX] ;Holds each GUI graphic ID so we can check if it was clicked Global $posX = 16 Global $posY = 16 GUICreate("Labyrinth", 900, 900) Local $y, $x for $y = 0 To $mapY $posX = $IMGX ;Reset posX to start position $posY += $IMGY ;Increase Y axis by 16 (img size) for $x = 0 To $mapX $GUID[$y,$x] = GUICtrlCreateGraphic($posX, $posY, $IMGX, $IMGY) GUICtrlSetGraphic( $GUID[$y,$x], $GUI_GR_RECT, $posX, $posY, $posX + 16, $posY + 16) Next MsgBox(0, "", "Row " & $y & " complete.") Next Local $msg GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd On a side note, how do I draw a rect in a certain color? I didn't see any values to set in GUICtrlSetGraphic for the color. Thanks.
Moderators Melba23 Posted February 1, 2014 Moderators Posted February 1, 2014 CheeseBiscuit,Autoit arrays have each dimension inside square brackets, not comma-separated: ; Bad Global $labryinthMap[$mapY,$mapX] ; Good Global $labryinthMap[$mapY][$mapX]As for graphics colour, the first parameter in my Help file page for GUICtrlSetGraphic is $GUI_GR_COLOR. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
CheeseBiscuit Posted February 1, 2014 Author Posted February 1, 2014 CheeseBiscuit, Autoit arrays have each dimension inside square brackets, not comma-separated: ; Bad Global $labryinthMap[$mapY,$mapX] ; Good Global $labryinthMap[$mapY][$mapX] As for graphics colour, the first parameter in my Help file page for GUICtrlSetGraphic is $GUI_GR_COLOR. M23 Oh I see... Now I have another error, it says incorrect number of subscripts or dimension range exceeded. On this line: GUICtrlSetGraphic( $GUID[$y][$x], $GUI_GR_RECT, $posX, $posY, $posX + 16, $posY + 16) Which is impossible, because its set to 31 and 51.. The Y for loop only goes to 31 and the X for loop goes to 51, so I don't see how the range was exceeded? Are these not zero based?
Moderators Melba23 Posted February 1, 2014 Moderators Posted February 1, 2014 CheeseBiscuit,You declare the array as [31][51] - so the max index is [30][50] and you are trying to access [31][51]. So either declare the array as $GUID[$mapY + 1][$mapX + 1] or loop one less time. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
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