Thornhunt Posted January 25, 2010 Share Posted January 25, 2010 been a while since i tackled them.. and wasnt that gread at them last time anyway. its coming up with a error, and cant seem to figure out why. and the help file isnt helping me much this time here it is, hopefully someone can help expandcollapse popup;Save Function Global $charactername , $characterlevel , $charactersex ;declare the array for $a = 20 to 0 step -1 for $b = 11 to 0 step -1 for $c = 2 to 0 step -1 for $d = 1 to 0 step -1 Global $Inventory[$a][$b][$c][$d] Next Next Next Next ;Sets All The Inventory Slots to null For test preferances For $iainv = 20 To 0 Step -1 $Inventory[$iainv][1][0][0] = "Empty" ;Name $Inventory[$iainv][2][0][0] = "-" ;Item type, W = weapon, A = Armour, P = potion, M = Materials, AM = Ammo, S = Scroll $Inventory[$iainv][2][1][0] = "-" ;Specific item type, ////W:: S = Sword, W = Wand, B = Bow, D = Dagger, C = Crossbow, A = Amulet, M = Mace. ;////A:: A = Archer, C = Caster, D = Druid, W = Worrior, ;////P:: H = HP, M = MP ;////M:: A = Aramite(special), B = Bronze, C = Cotton, D = Deadwood, E = Slate, F = Feather, I = Iron, S = Steel ;////AM:: B = Bolt, A = Arrow ;////S:: F = Fire, S = Shock, I = Ice, E = Earth $Inventory[$iainv][2][2][0] = "0" ;Ammount $Inventory[$iainv][3][0][0] = "0" ;Level $Inventory[$iainv][4][0][0] = "0" ;CurrentDuribility $Inventory[$iainv][4][1][0] = "0" ;MaxDuribility $Inventory[$iainv][5][0][0] = "0" ;MinDamage $Inventory[$iainv][5][1][0] = "0" ;MaxDamage $Inventory[$iainv][6][0][0] = "0" ;Defence $Inventory[$iainv][7][0][0] = "-" ;1st Raw Material $Inventory[$iainv][7][1][0] = "-" ;2nd Raw Material $Inventory[$iainv][8][0][0] = "-" ;Class Specific , N = All , W = Worrior, A = Archer, C = Caster , D = druid $Inventory[$iainv][9][0][0] = "-" ;1st MaterialNeeded $Inventory[$iainv][9][0][1] = "0" ;Amount needed $Inventory[$iainv][9][1][0] = "-" ;2ns MaterialNeeded $Inventory[$iainv][9][1][1] = "0" ;Amount Needed $Inventory[$iainv][9][2][0] = "-" ;3rd MaterialNeeded $Inventory[$iainv][9][2][1] = "0" ;Amount Needed $Inventory[$iainv][10][0][0] = "0" ;BuyCost $Inventory[$iainv][10][1][0] = "0" ;SellCost $Inventory[$iainv][10][2][0] = "0" ;RepairCost $Inventory[$iainv][11][0][0] = "0" ;Hp Bonus $Inventory[$iainv][11][1][0] = "0" ;Mp Bonus $Inventory[$iainv][11][2][0] = "0" ;DefenceBonus Next Save() Func Save() IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Bios", "Name", $charactername) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Bios", "Level", $characterlevel) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Bios", "Sex", $charactersex) for $i = 20 to 0 step -1 IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][1]", $Inventory[$i][1]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][2][0]", $Inventory[$i][2][0]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][2][1]", $Inventory[$i][2][1]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][2][2]", $Inventory[$i][2][2]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][3]", $Inventory[$i][3]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][4][0]", $Inventory[$i][4][0]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][4][1]", $Inventory[$i][4][1]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][5][0]", $Inventory[$i][5][0]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][5][1]", $Inventory[$i][5][1]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][6]", $Inventory[$i][6]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][7][0]", $Inventory[$i][7][0]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][7][1]", $Inventory[$i][7][1]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][8]", $Inventory[$i][8]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][9][0][0]", $Inventory[$i][9][0][0]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][9][0][1]", $Inventory[$i][9][0][1]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][9][1][0]", $Inventory[$i][9][1][0]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][9][1][1]", $Inventory[$i][9][1][1]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][9][2][0]", $Inventory[$i][9][2][0]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][9][2][1]", $Inventory[$i][9][2][1]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][10][0]", $Inventory[$i][10][0]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][10][1]", $Inventory[$i][10][1]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][10][2]", $Inventory[$i][10][2]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][11][0]", $Inventory[$i][11][0]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][11][1]", $Inventory[$i][11][1]) IniWrite(@ScriptDir & "\Character\" & $charactername & ".ini", "Inv" & $i, "$Inventory[ " & $i & " ][11][2]", $Inventory[$i][11][2]) next EndFunc Budweiser + room = warm beerwarm beer + fridge = too long!warm beer + CO2 fire extinguisher = Perfect![quote]Protect the easly offended ... BAN EVERYTHING[/quote]^^ hmm works for me :D Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 25, 2010 Moderators Share Posted January 25, 2010 Thornhunt,Perhaps if you declared the array correctly?;WTF!!!!! ;declare the array for $a = 20 to 0 step -1 for $b = 11 to 0 step -1 for $c = 2 to 0 step -1 for $d = 1 to 0 step -1 Global $Inventory[$a][$b][$c][$d] Next Next Next Next ; This is how you do it! Global $Inventory[21][11][3][2]You need to put in the MAXIMUM number of elements in each dimension just the once. You need loops to fill and read an array, but not to declare it! 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 Link to comment Share on other sites More sharing options...
Thornhunt Posted January 25, 2010 Author Share Posted January 25, 2010 ahhhh thankyou Budweiser + room = warm beerwarm beer + fridge = too long!warm beer + CO2 fire extinguisher = Perfect![quote]Protect the easly offended ... BAN EVERYTHING[/quote]^^ hmm works for me :D Link to comment Share on other sites More sharing options...
Thornhunt Posted January 25, 2010 Author Share Posted January 25, 2010 C:\MyGame\Save.au3 (50) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $Inventory[$iainv][11][0][0] = "0" ^ ERROR ------------------------- ok .. getting this.. anyidea ? cant see how its exceeding :S Budweiser + room = warm beerwarm beer + fridge = too long!warm beer + CO2 fire extinguisher = Perfect![quote]Protect the easly offended ... BAN EVERYTHING[/quote]^^ hmm works for me :D Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 25, 2010 Share Posted January 25, 2010 C:\MyGame\Save.au3 (50) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $Inventory[$iainv][11][0][0] = "0" ^ ERROR ------------------------- ok .. getting this.. anyidea ? cant see how its exceeding :S Array indexes are 0-based. Second subscript was declared [11], so the possible indexes are 0 thru 10. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Thornhunt Posted January 25, 2010 Author Share Posted January 25, 2010 meaning i will have to declare it with [21][12][3][2] instead of [21][11][3][1] i dont think i follow you fully. Budweiser + room = warm beerwarm beer + fridge = too long!warm beer + CO2 fire extinguisher = Perfect![quote]Protect the easly offended ... BAN EVERYTHING[/quote]^^ hmm works for me :D Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted January 25, 2010 Share Posted January 25, 2010 meaning i will have to declare it with [21][12][3][2] instead of [21][11][3][1] i dont think i follow you fully. No, he means you count from 0. There is a Array tutorial on the wiki, maybe you should take a look at it: 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...
Moderators Melba23 Posted January 25, 2010 Moderators Share Posted January 25, 2010 Thornhunt;PsaltyDS and I are (unconsciously) doing a "good cop - bad cop" routime. Up to you to decide who is which! Ok, short array tutorial.Arrays in AutoIt begin at 0 - so declaring $aArray[3] gives you the following elements:$aArray[0]$aArray[1]$aArray[2]Note that the highest element is 1 less that the number of elements.Remember I told you that you needed to declare " the MAXIMUM number of elements in each dimension" - well that means that the top element is $aArray[MAXIMUM - 1].So if you have 12 items you wish to put in an array you can do one of 2 things:1. Declare $aArray[12] and then fill elements [0] to [11]2. Declare $aArray[13], fill elements [1] to [12], and waste element [0]. (Actually Autoit often uses element [0] as a count of the other elements) Guess which is considered best practice? 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 Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 25, 2010 Share Posted January 25, 2010 (edited) PsaltyDS and I are (unconsciously) doing a "good cop - bad cop" routime. Up to you to decide who is which! Here's a hint: Melba23 is being helpful, while I brought my rubber hose and dental tools. Edited January 25, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 25, 2010 Moderators Share Posted January 25, 2010 PsaltyDS, Hey, when do I get to have some fun! 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 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