| www.ClassicTW.com https://mail.black-squirrel.com/ |
|
| TWX Arrays https://mail.black-squirrel.com/viewtopic.php?f=15&t=13068 |
Page 1 of 1 |
| Author: | PHX [ Wed Dec 15, 2004 3:07 am ] |
| Post subject: | |
I am having trouble understanding using arrays. I would like to build an array holding all members of a predefined corp #. Id like it to just read the corp member listing to get the info. So if it asks what corp #, and I type "2" then it reads the corp list and grabs all names from corp 2. Ive got something done up ill try to get it posted...obviously its not working but like I said I don't understand arrays much, at least not how to make them. I tried the scripting reference...its a little confusing on that command. |
|
| Author: | PHX [ Wed Dec 15, 2004 3:11 am ] |
| Post subject: | |
send "t d r" waitfor "elp)?" echo ansi_11 "**What Corp #? " getconsoleinput $who send "d l" :corp_search waitfor "-----------------" settexttrigger 1 :corp_number pause :corp_number setvar $corp "" getword CURRENTLINE $corp 1 if ($corp = "") goto :done_corp_search elseif ($corp <> $who) goto :corp_search elseif ($corp = $who) waitfor "Creation Date:" settextlinetrigger 1 :member_line pause :member_line gosub :killem settextlinetrigger 1 :get_member pause :get_member gosub :killem getword CURRENTLINE $name 1 if ($name = "-----------------------------------------------------") send "q" goto :menu elseif ($name = "Corp") getword CURRENTLINE $name 4 end setArray $members MEMBERS setvar $members[$name] 1 goto :get_member |
|
| Author: | PHX [ Wed Dec 15, 2004 3:13 am ] |
| Post subject: | |
umm...the gosub :killem just goes to something like :killem killtrigger 1 killtrigger 2 etc etc return |
|
| Author: | ElderProphet [ Wed Dec 15, 2004 3:38 am ] |
| Post subject: | |
Well, there's a couple of ways you could arrange this array. Let's say you and I are on the target corp. You could have it arrayed like this: $members[1] = "ElderProphet" $members[2] = "PHX" This would be good for certain circumstances, but you will probably just want to do a quick test to see if the guy who hit your fig is on that predefined corp. In that case, you just want to set the corp members to have a value of 1, so the array would look like this: $members[ElderProphet] = 1 $members[PHX] = 1 Then, when the person hits a fig, you grab their name in a variable like $name, then do a check like this: if ($members[$name] = 1) goto :attack end You pretty much have it setup correctly, just loose the setArray line (setArray $members MEMBERS). The dynamic array will build automatically, and you only want to use a static array if you're dealing with lots of values, and know the quantity. Otherwise, you don't need to setArray. +EP+ P.S. The index (the part inside the [] brackets) can be anything in a dynamic array, like we used [ElderProphet] and [PHX]. But in a static array, it must be between 1 and the size you set it at. It can't contain letters, numbers, symbols, and can't be zero, negative numbers, or decimals. |
|
| Page 1 of 1 | All times are UTC - 5 hours |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|