View unanswered posts | View active topics It is currently Sat Apr 18, 2026 3:23 am



Reply to topic  [ 50 posts ]  Go to page Previous  1, 2, 3, 4
 Simple read file to an array 
Author Message
Ensign

Joined: Sun Mar 06, 2011 12:22 am
Posts: 205
Unread post Re: Simple read file to an array
Singularity, I have continued trying to add features to your nearest-port trader skeleton, with mixed results. It worked great until my last attempt. It seems like following Vid Kid's suggestions caused permanent problems with my script, which completely confuses me. Anyway, I have been trying to understand your script better in order to figure out what I did wrong.

I have seventy-two ports in my list. Your code includes:

Code:
# Read ports file

setVar $ports_count 0
setArray $ports_list SECTORS
fileExists $exists $ports_file

if ($exists > 0)
    readToArray $ports_file $list
    setVar $i 1
    while ($i <= $list)
        getWord $list[$i] $word 1
        isNumber $num $word
        if ($num > 0)
            if (($word > 10) AND ($word <= SECTORS))
                add $ports_count 1
            end
        end
        add $i 1
    end
end

Are you making sure that each entry is valid? $ports_file and $ports_count both return 72.

I was just curious. Thank you for posting that and for all of your support since!

_________________
Photons away!


Last edited by Grey Gamer on Mon Apr 08, 2013 9:49 pm, edited 1 time in total.



Fri May 04, 2012 6:03 am
Profile
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1134
Location: Augusta, GA
Unread post Re: Simple read file to an array
Grey Gamer, please use the "Code" tag when posting code - it makes reading the code much less difficult. PM me if you need help with the tag.

Now to your question. Yes, it's a verification that the list entries were indeed numerical, and that each number was within the range 11 - SECTORS.

_________________
Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.


Sat May 05, 2012 11:06 am
Profile WWW
Ensign

Joined: Sun Mar 06, 2011 12:22 am
Posts: 205
Unread post Re: Simple read file to an array
The Quest went down about two weeks ago, so I went looking for a quiet place to jury rig my scripts. I also went back to college for summer school, so I really did not not have much attention to spare when someone blew me up, so now I am running a game on my old computer, feeling like the champion of the cupboard under the stairs.

I did not feel that I had time to work on my terribly atrocious world trade script, so I just used SWATH's, but then something would happen and it always irritated me that it would happily jettison my cargo on its own, but did not want me starting the script with anything in my holds. Instead of finding the nearest BBB port or one specific to my cargo, I made a nearest unknown script. Here it is:

Code:
echo "*Quick Unknown Sector Lookup*"
setVar $result 0
send "cku"
waitFor "  "
while $result = 0
setVar $unknown0 CURRENTLINE
getWord $unknown0 $unknown 1
isNumber $result $unknown
end
send "  q" $unknown "**"
halt


It took me hours. So sad!

I do not like how it displays five lines of sectors, but everything else caused an endless loop.

Cheers.

_________________
Photons away!


Sat May 26, 2012 6:31 pm
Profile
Commander

Joined: Sun Feb 25, 2001 3:00 am
Posts: 1838
Location: Guam USA
Unread post Re: Simple read file to an array
First thing to remeber when doing While loops is the format , without it you end up in an endless loop maxing your cpu.

Code:
# set up a counting variable
SetVar $1 "1"
# in this case a range for max
SetVar $Range 12
While ($i <= $Range)
# Get some word or check
# do something with it , like write to a file
# (you need to declare that at start of script)
# this is important , increment or it leads to endless loop
Add $ i 1
End
# Echo results or look over the file


I hope this helps , or maybe contact me on Team Speak for further help.

_________________
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


Sat May 26, 2012 7:29 pm
Profile WWW
Ensign

Joined: Sun Mar 06, 2011 12:22 am
Posts: 205
Unread post Re: Simple read file to an array
Thanks Vid Kid!

Each time that I had an endless loop I had my script display numbers between each line of code and my screen would fill with the numbers, so it was going through the loop way too fast to get input. Right now I get:

You have NOT explored the following sectors:

21 22 23 24 25 26 27 29 30 31 32
33 34 35 39 40 43 44 46 47 48 49
50 51 52 53 54 55
21

Script terminated: scripts\9qu.ts

58 59 60 61 62
64 67 68 69 70 71 72 73 74 75 76
78 79 81 82 86 88 89 90 92 93 94

Computer command [TL=00:00:00]:[7828] (?=Help)? Q

I just wish that I could reduce the output text.

Have a great weekend!

_________________
Photons away!


Sat May 26, 2012 8:20 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 50 posts ]  Go to page Previous  1, 2, 3, 4

Who is online

Users browsing this forum: No registered users and 29 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.