| Author |
Message |
|
PHX
Lieutenant
Joined: Sat Mar 03, 2001 3:00 am Posts: 592 Location: USA
|
can you use the "and" option with the wile command the same way you would with an "if" command.
|
| Fri Jun 11, 2004 3:24 am |
|
 |
|
PHX
Lieutenant
Joined: Sat Mar 03, 2001 3:00 am Posts: 592 Location: USA
|
My tests are telling me no...would be nice to be able to do.
setvar $total ($orebust / $hlds)
setvar $trips 0
while ($trips <= $total) and ($oreneeds > $hlds)
send "t n t 1* q l " $fill "* t n l 1* q l " $bust "* "
add $trips 1
subtract $oreneeds $hlds
end
|
| Fri Jun 11, 2004 3:58 am |
|
 |
|
Cherokee-TLTT
Ensign
Joined: Sat Jan 19, 2002 3:00 am Posts: 214 Location: USA
|
I don't know if you can or not, but you might try surrounding the clause with parenthesis, like this...
while (($trips <= $total) and ($oreneeds > $hlds))
If you can't get it to work then you'll need to loop without the while, like this...
setvar $total ($orebust / $hlds)
setvar $trips 0
:loop
if (($trips <= $total) and ($oreneeds > $hlds))
send "t n t 1* q l " $fill "* t n l 1* q l " $bust "* "
add $trips 1
subtract $oreneeds $hlds
goto :loop
end
_________________ Cherokee
The Lost Traders Tavern
http://tavern.homeip.net
Deployed Fighters Report Sector 911: Cherokee's Imperial Starship entered sector.
|
| Fri Jun 11, 2004 11:03 am |
|
 |
|
ElderProphet
Commander
Joined: Tue Oct 07, 2003 2:00 am Posts: 1134 Location: Augusta, GA
|
The while command (and almost every other TWX command) handles conditional statements with no problem. I agree with CK 100% about the brackets. I posted what I thought the problem was in response to your question at the TWX forum: http://www.twxproxy.com/support.php?show=654&start=1
In short, it works perfectly as stated, but I think you want the conditional statement to be OR.
while (($trips <= $total) or ($oreneeds > $hlds))
Try it and let us know.
+EP+
_________________ Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.
|
| Fri Jun 11, 2004 12:31 pm |
|
 |
|
PHX
Lieutenant
Joined: Sat Mar 03, 2001 3:00 am Posts: 592 Location: USA
|
quote:Originally posted by Cherokee-TLTT
I don't know if you can or not, but you might try surrounding the clause with parenthesis, like this...
while (($trips <= $total) and ($oreneeds > $hlds))
If you can't get it to work then you'll need to loop without the while, like this...
setvar $total ($orebust / $hlds)
setvar $trips 0
:loop
if (($trips <= $total) and ($oreneeds > $hlds))
send "t n t 1* q l " $fill "* t n l 1* q l " $bust "* "
add $trips 1
subtract $oreneeds $hlds
goto :loop
end
I don't know but assumed there would be a significant speed loss if I used the IF instead of WHILE. And in all things TradeWars, speed is key. Im not going to try this method at all unless someone tells me that it will in fact work just as fast as WHILE.
I have made scripts with IF commands that had multiple var's before and never put brackets around the whole lot like that and they work just fine. Can you guys explain why this is prefered?
|
| Fri Jun 11, 2004 5:29 pm |
|
 |
|
PHX
Lieutenant
Joined: Sat Mar 03, 2001 3:00 am Posts: 592 Location: USA
|
quote: Originally posted by ElderProphet
The while command (and almost every other TWX command) handles conditional statements with no problem. I agree with CK 100% about the brackets. I posted what I thought the problem was in response to your question at the TWX forum: http://www.twxproxy.com/support.php?show=654&start=1
In short, it works perfectly as stated, but I think you want the conditional statement to be OR.
while (($trips <= $total) or ($oreneeds > $hlds))
Try it and let us know.
+EP+
If I used OR, it seems like that after the bust planet has well run out of ore, the fill planet may still have lots of room on it and the OR statement would keep rerunning the macro because of ($oreneeds > $hlds). Ill try the AND first and if it gives me troubles ill give OR a shot.
Thanks to both for the help. Someday when I become the Legendary Super Scripter, and threaten to wipe out the entire South Galaxy, you and everyone else who helped me out will get props. Then I gotta figure out how to kick Kakaloto's (Goku's) Butt.
|
| Fri Jun 11, 2004 5:38 pm |
|
 |
|
Cherokee-TLTT
Ensign
Joined: Sat Jan 19, 2002 3:00 am Posts: 214 Location: USA
|
The while loop has to do an IF internally anyways. There should be 0 speed difference.
_________________ Cherokee
The Lost Traders Tavern
http://tavern.homeip.net
Deployed Fighters Report Sector 911: Cherokee's Imperial Starship entered sector.
|
| Fri Jun 11, 2004 5:45 pm |
|
 |
|
ElderProphet
Commander
Joined: Tue Oct 07, 2003 2:00 am Posts: 1134 Location: Augusta, GA
|
With a single And/Or condition, the brackets are inconsequential. But it is good practice for when you get into multiple conditional statements. Like mathematical functions, the conditional components are processed from the innermost to outermost brackets.
The first example below will only evaluate as true if $a or $b are > 3, and $a is > $b.
The second example is completely different. It will only evaluate as true if $a is > $b & 3, or if $b > 3.
1. if (($a > $b) and (($a > 3) or ($b > 3)))
2. if ((($a > $b) and ($a > 3)) or ($b > 3))
You can see that these two examples will not evaluate the same all of the time, like in this truth table:
Example #: |1|2|
[a=0][b=4] |0|1|
[a=5][b=0] |1|0|
Heh, you asked.
+EP+
_________________ Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.
|
| Fri Jun 11, 2004 7:33 pm |
|
 |
|
PHX
Lieutenant
Joined: Sat Mar 03, 2001 3:00 am Posts: 592 Location: USA
|
Darn.
|
| Sat Jun 12, 2004 3:14 am |
|
 |
|
ElderProphet
Commander
Joined: Tue Oct 07, 2003 2:00 am Posts: 1134 Location: Augusta, GA
|
Heh, too much? That'll teach you to question us!! <grin>
+EP+
_________________ Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.
|
| Sat Jun 12, 2004 4:26 am |
|
 |
|