View unanswered posts | View active topics It is currently Thu Apr 23, 2026 5:20 pm



Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
 Has anyone ever seen....... 
Author Message
Veteran Op
User avatar

Joined: Sat Dec 29, 2007 5:06 pm
Posts: 2059
Location: Oklahoma
Unread post Re: Has anyone ever seen.......
Simple method for getting planet numbers. I am sure there are better methods but for me this made it easy for me to piece though and understand when I first started. I am sure others can explain it better but I hope this helps a little. Best thing is take a simple script like figs and start looking at it and changing a few lines and you will start seeing what things do.
Cut the CODE and paste in a text editor and name it "something.ts" then run the script that use just made in TWX.

then type $sv then type planet and hit enter ... that will show the planet numbers I have used an echo so you can see the numbers.

Also when testing scripts it is best not to have MoMbot loaded or any other scripts because if you accidently hit $sv <enter> you will be sitting there for a while :)

$parm1 - $parm8 and $command <-- these are just variables that are being used in the script somewhere.
loadvar "$bot_name" <-- that loads the variable from Mombot into your script so that you could use like so.

send "'" $bot_name citcap on*" <-- and mombot citcap will startup.

Code:
setvar $i 1
send "l"
waitfor "----"
:triggers
settexttrigger end :end "Land"
settexttrigger planet :planet "<"
pause
pause

:planet
killalltriggers
getwordpos CURRENTLINE $pos "<"
add $pos 1
cuttext CURRENTLINE $planet[$i] $pos 4
striptext $planet[$i] " "
add $i 1
goto :triggers

:end
killalltriggers
send "q*"
setvar $k 1
gosub :list
halt

:list
if ($k < $i)
   echo ANSI_15 "*" $k ". " $planet[$k]
   add $k 1
   goto :list
end

return

_________________
T0yman (Permanently Retired since 2012)
Proverbs 17:28 <-- Don't know it, most should it would stop a lot of the discussions on here.


Fri Dec 10, 2010 7:52 am
Profile ICQ YIM WWW
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post Re: Has anyone ever seen.......
T0yman wrote:
Simple method for getting planet numbers. I am sure there are better methods but for me this made it easy for me to piece though and understand when I first started. I am sure others can explain it better but I hope this helps a little. Best thing is take a simple script like figs and start looking at it and changing a few lines and you will start seeing what things do.
Cut the CODE and paste in a text editor and name it "something.ts" then run the script that use just made in TWX.

then type $sv then type planet and hit enter ... that will show the planet numbers I have used an echo so you can see the numbers.

Also when testing scripts it is best not to have MoMbot loaded or any other scripts because if you accidently hit $sv <enter> you will be sitting there for a while :)

$parm1 - $parm8 and $command <-- these are just variables that are being used in the script somewhere.
loadvar "$bot_name" <-- that loads the variable from Mombot into your script so that you could use like so.

send "'" $bot_name citcap on*" <-- and mombot citcap will startup.

Code:
setvar $i 1
send "l"
waitfor "----"
:triggers
settexttrigger end :end "Land"
settexttrigger planet :planet "<"
pause
pause

:planet
killalltriggers
getwordpos CURRENTLINE $pos "<"
add $pos 1
cuttext CURRENTLINE $planet[$i] $pos 4
striptext $planet[$i] " "
add $i 1
goto :triggers

:end
killalltriggers
send "q*"
setvar $k 1
gosub :list
halt

:list
if ($k < $i)
   echo ANSI_15 "*" $k ". " $planet[$k]
   add $k 1
   goto :list
end

return


I am a proponent of whatever gets the job done as anyone who has looked at my scripts can attest.

I would suggest using self canceling settriggers - cleaner in approach, and for me simpler.


Code:
setVar $pnumCnt 0
send "l"
waitfor "---------"
:getPlanetNum

  # initial set triggers
  setTextLineTrigger pNum :pNum "   <"
  setTextTrigger pNumDone :pNumDone "Land on which"
  pause

  :pNum
    add $pNumCnt 1
    getWord currentline $pNumber[$pNumCnt] 2
    stripText $pNumber[$pNumCnt] ">"
   
   # resetting the trigger that was just used and eliminates goto, pNumDone trigger still active
    setTextLineTrigger pNum :pNum "   <"
    pause
 
  :pNumDone
  killtrigger pNum

  # display
  setVar $i 1
  while ($i <= $pNumCnt)
     echo ANSI_11 "**---> " $pNumber[$i]
     add $i 1
  end


If you have over 999 planet numbers then this will fail. You can use getText "<" ">" and then strip the " " out.

_________________
               / Promethius / Enigma / Wolfen /

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


Fri Dec 10, 2010 12:29 pm
Profile ICQ
Veteran Op
User avatar

Joined: Sat Dec 29, 2007 5:06 pm
Posts: 2059
Location: Oklahoma
Unread post Re: Has anyone ever seen.......
Nice, thanks for some different ways of looking at it. I am always trying to find new methods and improve scripts I wrote when I first started.

_________________
T0yman (Permanently Retired since 2012)
Proverbs 17:28 <-- Don't know it, most should it would stop a lot of the discussions on here.


Fri Dec 10, 2010 12:37 pm
Profile ICQ YIM WWW
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post Re: Has anyone ever seen.......
T0yman wrote:
Nice, thanks for some different ways of looking at it. I am always trying to find new methods and improve scripts I wrote when I first started.


A lot of different methods used by different people, and as long as they get the job done, all is well. My scripts still scare me when I look at them - sometimes I wonder why I did something - rewrite and run - then remember, "oh yeah, that kept me from getting podded" when xyz happened unexpectedly. I need to comment my scripts.

_________________
               / Promethius / Enigma / Wolfen /

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


Fri Dec 10, 2010 12:47 pm
Profile ICQ
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post Re: Has anyone ever seen.......
Whatever works. Question tho, what happens if you
have only 1 planet in the sector and no pscanner?

Here's my take...

Code:
gosub :get_planet_list
echo "*Count: " & $planet_count & "*"
setVar $i 1
while ($i <= $planet_count)
    echo $i & "  " & $planet_list[$i] & "*"
    add $i 1
end

# ---------------------------------------------------------
halt
# ---------------------------------------------------------

:get_planet_list
    setVar $planet_count 0
    send "q q q q z a 99999* l*  *  "
    waitFor "<Preparing ship to land on planet surface>"

    :grab_planet_line
        killTrigger grab_planet_line
        setVar $line CURRENTLINE
        stripText $line "<"
        stripText $line ">"
        getWord $line $pln 1 "%%@@%%"
        if ($pln = "Command")
            return
        elseif ($pln = "Planet")
            send "dq"
            waitFor "Planet #"
            getWord CURRENTLINE $pln 2
            stripText $pln "#"
            setVar $planet_count 1
            setVar $planet_list[$planet_count] $pln
            waitFor "Command [TL="
            return
        elseif ($pln <> "%%@@%%")
            isNumber $num $pln
            if ($num > 0)
                add $planet_count 1
                setVar $planet_list[$planet_count] $pln
            end
        end
        setTextLineTrigger grab_planet_line :grab_planet_line ""
        pause

# ---------------------------------------------------------


Prolly a few ways to shrink that down tho.

_________________
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


Fri Dec 10, 2010 1:30 pm
Profile ICQ WWW
Display posts from previous:  Sort by  
Reply to topic   [ 20 posts ]  Go to page Previous  1, 2

Who is online

Users browsing this forum: Google [Bot] and 12 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.