bald1 Posted September 9, 2009 Share Posted September 9, 2009 Hey ppl FIrst off ill start by introducing myself. Im completely new to autoit and the world of writing code and scripts, and I must say, ive been sucked into this world of absolute statements and variables quite quickly. I've been lurking these forums for some time now, looking for inspiration and help. I, as many before me, got attracted to the world of automated actions in the shadow of a MMO. Even tho it seems fairly easy to make a basic bot that can do a wide variety of hunting and farming, ive decided against that and decided to go with something less offensive and more useful to the common player: A tradeskilling automation. Bear in mind that in my MMO (AO) u cannot gain credit or exp by tradeskilling. It's just a long and boring process that from the views of a "new-age" mmo gamer would seem a broken game mechanic. So, i been writing on it for some time now, and i actually only need one crucial bit to finish it. Is there a way to cycle or swap arrays ? I need to feed my code 3 sets of variables for each data input. I decided to use arrays for simplicity sake for these 3 variables. I use pixelsearch to locate the items in inv, and the 3 variables i use to ensure that i get the right item. So 3 times not @error means i got the right item. I feed pixelsearch with my array as such: $item1[0] = 0xsomecolorcode, $items1[1] = 0xsomecolorcode and $items1[2] = 0xsomecolorcode... Now i need to do this with all my arrays of $items in order for my script to figure out where and if all items are present to complete a given tradeskilling process. How do i easiet go about doing this task? _ArraySwap seems to only swap the information contained within one array.. I know there's some super easy way to this, but i just cant seem to locate it, and judging from all the other questions posed in this forum, this one strikes me as dumb >< I can post the code if what im asking is too unclear, but im not at tmy staionary at this moment Thanks in advance! Link to comment Share on other sites More sharing options...
omikron48 Posted September 9, 2009 Share Posted September 9, 2009 Are your item arrays the same size? Link to comment Share on other sites More sharing options...
bald1 Posted September 9, 2009 Author Share Posted September 9, 2009 Are your item arrays the same size?They are, all consists of 3 blocks Link to comment Share on other sites More sharing options...
omikron48 Posted September 9, 2009 Share Posted September 9, 2009 Then you can just use a size 3 array in your pixelsearch code and just assign the values of the current set you want to process. Link to comment Share on other sites More sharing options...
jvanegmond Posted September 9, 2009 Share Posted September 9, 2009 A unique feature is to create an entire copy of a array like this: #include <Array.au3> Dim $a[2] = [1, 2] Dim $b[2] = [3, 4] _SwapEntireArray($a, $b) _ArrayDisplay($a) _ArrayDisplay($b) Func _SwapEntireArray(ByRef $aArray1, ByRef $aArray2) Dim $aCopy = $aArray1 $aArray1 = $aArray2 $aArray2 = $aCopy EndFunc At times like this I love AutoIt intensely. github.com/jvanegmond Link to comment Share on other sites More sharing options...
bald1 Posted September 9, 2009 Author Share Posted September 9, 2009 A unique feature is to create an entire copy of a array like this: #include <Array.au3> Dim $a[2] = [1, 2] Dim $b[2] = [3, 4] _SwapEntireArray($a, $b) _ArrayDisplay($a) _ArrayDisplay($b) Func _SwapEntireArray(ByRef $aArray1, ByRef $aArray2) Dim $aCopy = $aArray1 $aArray1 = $aArray2 $aArray2 = $aCopy EndFunc At times like this I love AutoIt intensely. This looks fairly easy, thanks! Omikron, could u elaborate on that? I'm always open to learn alternative routes and ways to go about things While i have your attention im gonna throw a bonus noob question in there for ya; I noticed you/Manadar used the "Dim" scope to declare your variables. Could u explain in few words the difference between the 3 scopes? As i've read several times that global and local should be the the scopes used, but i guess this is not true for scripts made to run besides games? thanks! Link to comment Share on other sites More sharing options...
jvanegmond Posted September 9, 2009 Share Posted September 9, 2009 I use Dim because I'm an oldie, but we should both use Local or Global scope. Explanation of the three scopes: - Dim scope uses the local scope, unless the variable was previously declared in the Global scope. - Local scope is simple. It's local and can only be used in the current scope and other scopes that exist in the current scope. - Global scope can be used anywhere in your script (same as a local being declared on the root scope), but global can be declared anywhere in your script. Local example (as with many other programming languages): _foo() MsgBox(0, "", $bar) ; errors out Func _foo() Local $bar = 3 EndFunc Global example (uncommon): _foo() MsgBox(0, "", $bar) ; shows 3 Func _foo() Global $bar = 3 EndFunc github.com/jvanegmond Link to comment Share on other sites More sharing options...
bald1 Posted September 9, 2009 Author Share Posted September 9, 2009 Thanks alot Manadar! Seeing them used in a script makes a lot more sense than those poor descriptions Link to comment Share on other sites More sharing options...
bald1 Posted September 11, 2009 Author Share Posted September 11, 2009 It's been a few busy days, and so i've just gotten around to look at this now and i can't quite seem to get it working is there a chance that u or anyone could expand on that swap example? #include <Array.au3> Dim $a[2] = [1, 2] Dim $b[2] = [3, 4] _SwapEntireArray($a, $b) _ArrayDisplay($a) _ArrayDisplay($b) Func _SwapEntireArray(ByRef $aArray1, ByRef $aArray2) Dim $aCopy = $aArray1 $aArray1 = $aArray2 $aArray2 = $aCopy EndFunc This is the code, and i see how this works for swapping between two arrays, but what if i wanna cycle down a line of arrays like these: global Const $aItem01[3] = [0x5995EC, 0xE2FEFF, 0x415769] global Const $aItem02[3] = [0xDBD194, 0x6EB7F0, 0x252723] global Const $aItem03[3] = [0xA64542, 0xFEECD3, 0xB45B55] global Const $aItem04[3] = [0xA95A5D, 0xFE7C84, 0xFFBCD3] (and many more) Bear with this noob :/ Link to comment Share on other sites More sharing options...
omikron48 Posted September 11, 2009 Share Posted September 11, 2009 (edited) You should make a two dimensional array. global Const $aItem[$n][3] global Const $aItem[0][3] = [0x5995EC, 0xE2FEFF, 0x415769] global Const $aItem[1][3] = [0xDBD194, 0x6EB7F0, 0x252723] global Const $aItem[2][3] = [0xA64542, 0xFEECD3, 0xB45B55] global Const $aItem[3][3] = [0xA95A5D, 0xFE7C84, 0xFFBCD3] (and many more) For $i = 0 To $n - 1 For $j = 0 To 2 PixelSearch( 0, 0, 20, 300, $aItem[$i][$j]) If @error Then ExitLoop Next Next Not sure if the declaration is allowed since I've never tried declaring a constant array, but you should get the idea. Edited September 11, 2009 by omikron48 Link to comment Share on other sites More sharing options...
bald1 Posted September 12, 2009 Author Share Posted September 12, 2009 Currently at work, so ill check it out when i get home some time. However, if ya happen to know an "advanced" tutorial for autoit, i'd be happy to read it (while im at work anyway ). I went through the basic thingy, which mentions two dimensional arrays, but said it had no place in a basic tutorial, and therefor i know nothing about it. Thanks for your reply! Link to comment Share on other sites More sharing options...
Hawkwing Posted September 12, 2009 Share Posted September 12, 2009 AutoIt 1-2-3 is a great tutorial by Valuater. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
bald1 Posted September 12, 2009 Author Share Posted September 12, 2009 AutoIt 1-2-3 is a great tutorial by Valuater.Ah cool, thanks 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