View unanswered posts | View active topics It is currently Tue Apr 21, 2026 6:24 pm



Reply to topic  [ 10 posts ] 
 Problem with array 
Author Message
Boo! inc.
User avatar

Joined: Sat Oct 09, 2004 2:00 am
Posts: 865
Location: USA
Unread post Problem with array
Im having an issue, without posting my entire code here Ill try my best to explain my problem.

Basically what Ive done is written certain sectors to an array
setvar $foundsec[$count] $idx
echo "*" & #9 & $foundsec[$count]

Everything echo's out correctly at this point.
Problem is when I go to use the information in the array using a while.
Ill post the testing portion of that code:

setvar $count 1
setvar $idx 1
while ($idx <= $count)
send "p" & $foundsec[$count] & "*"
waitfor "Citadel command (?="
add $count 1
add $idx 1
end
echo "** done **"


Basically after cycling through all the stored sectors I'd like it to quit for testing purposes, problem is that after it hits the last sector in the array it sends 0. Ive tried 10 different ways and either its the same outcome or it doesn't work.
So now im at the point Im not thinking about it right so I need some input, I realize the answer is probably RIGHT in front of my face..and prolly easy. An outside brain would greatly help :)

-mob

_________________
“The object of war is not to die for your corp but to make the other bastard die for his.”

Boo! inc.


Sun Mar 29, 2009 7:59 am
Profile
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post Re: Problem with array
Uhm. You're incrementing $count too. I don't see how that could ever exit. But if you're printing 0 it's prolly because there's a 0 somewhere in your array.

Code:
setvar $idx 1
while ($idx <= $count)
    if ($foundsec[$idx] > 10) AND ($foundsec[$idx] <= SECTORS)
        send "p" & $foundsec[$idx] & "*"
        waitfor "hops away from here."
    end
    add $idx 1
end
echo "** done **"


Notice that I changed the loop, got rid of count (you can't increment both count and idx at the same time and exit the loop unless you've got some other control somewhere), used a combo if statement to filter out any impossible sectors and changed the waitFor, since waiting for citadel command will not work the way you expect (it'll trigger on the text before the jump, so there's no real waitfor).

_________________
May the unholy fires of corbomite ignite deep within the depths of your soul...

1. TWGS server @ twgs.navhaz.com
2. The NavHaz Junction - Tradewars 2002 Scripts, Resources and Downloads
3. Open IRC chat @ irc.freenode.net:6667 #twchan
4. Parrothead wrote: Jesus wouldn't Subspace Crawl.

*** SG memorial donations via paypal to: dpocky68@booinc.com
Image


Sun Mar 29, 2009 8:27 am
Profile ICQ WWW
Boo! inc.
User avatar

Joined: Sat Oct 09, 2004 2:00 am
Posts: 865
Location: USA
Unread post Re: Problem with array
Singularity wrote:
Uhm. You're incrementing $count too. I don't see how that could ever exit. But if you're printing 0 it's prolly because there's a 0 somewhere in your array.

Code:
setvar $idx 1
while ($idx <= $count)
    if ($foundsec[$idx] > 10) AND ($foundsec[$idx] <= SECTORS)
        send "p" & $foundsec[$idx] & "*"
        waitfor "hops away from here."
    end
    add $idx 1
end
echo "** done **"


Notice that I changed the loop, got rid of count (you can't increment both count and idx at the same time and exit the loop unless you've got some other control somewhere), used a combo if statement to filter out any impossible sectors and changed the waitFor, since waiting for citadel command will not work the way you expect (it'll trigger on the text before the jump, so there's no real waitfor).


Ok yes...I could have sworn I tried that, but yours worked mine did not. What I posted was a last ditch effort to get it to stop trying to warp to 0. Worked perfect, I wish I saved my while with the if included so I could have got your opinion on that also. Also I had the waitfor at citadel because I was just testing, if you notice its not actually saying y to warp. Thanks alot Sing!

_________________
“The object of war is not to die for your corp but to make the other bastard die for his.”

Boo! inc.


Sun Mar 29, 2009 8:53 am
Profile
Boo! inc.
User avatar

Joined: Sat Oct 09, 2004 2:00 am
Posts: 865
Location: USA
Unread post Re: Problem with array
If im writing a stand alone script (not using m()m commands), would it be good practice to get and set my own sector parms? Just would seem a pain to have to run >figs/>cim everytime I want to run my script?

_________________
“The object of war is not to die for your corp but to make the other bastard die for his.”

Boo! inc.


Sun Mar 29, 2009 10:43 am
Profile
Veteran Op

Joined: Tue Nov 28, 2006 4:04 pm
Posts: 5025
Unread post Re: Problem with array
mob wrote:
If im writing a stand alone script (not using m()m commands), would it be good practice to get and set my own sector parms? Just would seem a pain to have to run >figs/>cim everytime I want to run my script?


An option would have a file with a time/date stamp on when the last refresh was done and ask the user if they would like to refresh or not.


Sun Mar 29, 2009 10:46 am
Profile
Boo! inc.
User avatar

Joined: Sat Oct 09, 2004 2:00 am
Posts: 865
Location: USA
Unread post Re: Problem with array
Big D wrote:
mob wrote:
If im writing a stand alone script (not using m()m commands), would it be good practice to get and set my own sector parms? Just would seem a pain to have to run >figs/>cim everytime I want to run my script?


An option would have a file with a time/date stamp on when the last refresh was done and ask the user if they would like to refresh or not.


Great point...
Ill use that!
Now can't I just save that to a variable and check it everytime the script runs or will that not work?

*last edit*
Also I noticed you changed $foundsec[$count] to [$idx]?? I bet thats what did it, I didn't notice it before...any reason behind that?

_________________
“The object of war is not to die for your corp but to make the other bastard die for his.”

Boo! inc.


Sun Mar 29, 2009 10:51 am
Profile
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post Re: Problem with array
Use parms. Fig files are ancient technology, outdated by a mile.

There are numerous scripts that write the parms. All you have to do is read them.

_________________
May the unholy fires of corbomite ignite deep within the depths of your soul...

1. TWGS server @ twgs.navhaz.com
2. The NavHaz Junction - Tradewars 2002 Scripts, Resources and Downloads
3. Open IRC chat @ irc.freenode.net:6667 #twchan
4. Parrothead wrote: Jesus wouldn't Subspace Crawl.

*** SG memorial donations via paypal to: dpocky68@booinc.com
Image


Sun Mar 29, 2009 12:16 pm
Profile ICQ WWW
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post Re: Problem with array
I agree with Sing on the fig parms. As a solo, I have real-time updates of my fig parm list by running a system script that monitors killed fighters. All of my scripts set the parm when deploying a fighter so I don't have to do the fighter update unless I get dropped from the server for a while and need to refresh. If corped, I would have to update the list as normal when a gridder is out, but I still run the system script to monitor killed fighters.

_________________
               / Promethius / Enigma / Wolfen /

"A man who has no skills can be taught, a man who has no honor has nothing."


Sun Mar 29, 2009 12:53 pm
Profile ICQ
Commander

Joined: Sun Feb 25, 2001 3:00 am
Posts: 1838
Location: Guam USA
Unread post Re: Problem with array
Yes , Mob .. use a quick figs and a fig hit scripts I posted on grimmies.
One reads and stores params of your figs the other records and removes the hits as they happen.

They will keep you current on the parameters during game play.

Keep up the coding :)

_________________
TWGS V2 Vids World on Guam Port 2002
Telnet://vkworld.ddns.net:2002
Discord @ DiverDave#8374
Vid's World Discord

Founding Member -=[Team Kraaken]=- Ka Pla

Image
Winners of Gridwars 2010
MBN Fall Tournament 2011 winners Team Kraaken
Undisputed Champions of 2019 HHT Just for showing up!

The Oldist , Longist Running , Orginal Registered Owner of a TWGS server :
Vids World On Guam


Sun Mar 29, 2009 9:04 pm
Profile WWW
Boo! inc.
User avatar

Joined: Sat Oct 09, 2004 2:00 am
Posts: 865
Location: USA
Unread post Re: Problem with array
Vid Kid wrote:
Yes , Mob .. use a quick figs and a fig hit scripts I posted on grimmies.
One reads and stores params of your figs the other records and removes the hits as they happen.

They will keep you current on the parameters during game play.

Keep up the coding :)


Yes thank you, I talked to a couple peeps and they pointed me (hit me over the head) in the right direction. Mostly that late night coding gets you no where!

_________________
“The object of war is not to die for your corp but to make the other bastard die for his.”

Boo! inc.


Sun Mar 29, 2009 9:49 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users and 28 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by wSTSoftware.