View unanswered posts | View active topics It is currently Tue Apr 21, 2026 7:25 am



Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
 Port upgrader 
Author Message
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1134
Location: Augusta, GA
Unread post Re: Port upgrader
Crosby wrote:
ok, perhaps that's why my settextlinetrigger wasn't working. I didn't know about this whole CRLF biz. This is only on lines that the game is waiting on input from user?

Yeah basically. In TWX scripting, we use "*" for ENTER or RETURN. * = CR (Carriage Return, or #13 in ASCII). So if I echo the following text, it shows up as 2 lines:
echo "This is line 1.*This is line 2."
If I echo that to the screen, line 1 will be followed by CRLF (Carriage Return, Line Feed), completing line 1, and line 2 will follow it on the next line with the cursor at the end of line 2. So line 2 is still going. If I start typing, it would be continued on line 2. A setTextLineTrigger will only fire once the line is completed, which by definition means it ends with CRLF (which we abbreviate * basically). So in the game of TW, I believe the only lines that aren't terminated with CRLF are some ANSI graphics and the current prompt.

Previous prompts that have already been answered are fine for setTextLineTrigger. So if you send "pt**", you can use setTextLineTrigger on the "How many holds of " line because the first "*" will complete that line, causing the setTextLineTrigger to fire. But it wouldn't fire if you just sent "pt", because the "How many holds" prompt will still be awaiting input.

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


Wed Mar 23, 2011 1:18 pm
Profile WWW
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post Re: Port upgrader
Promethius wrote:
You might think of using arrays. Something like what is below that is not tested, but just to give you a thought on arrays:

Code:
setVar $i 3
While ($i > 0)
  send "o" $i
  waitOn "How many units do you want to invest?"
  getword currentline $toUpGrade 9
  stripText $toUpgrade "("
  send $toUpgrade "*"
  subtract $i 1
end
send "*cr*q"


Just realized I used "arrays" instead of what I meant. Ah well, posting from work, what can I say? Should have said using a "While" loop along with variables. People are slacking on not taking me to task for that.

_________________
               / Promethius / Enigma / Wolfen /

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


Thu Mar 24, 2011 11:57 am
Profile ICQ
Ensign

Joined: Sun Mar 06, 2011 12:22 am
Posts: 205
Unread post Re: Port upgrader
Besides being able to respond to different prompts, what are the advantages of setTextTrigger over waitFor (or waitOn)? Promethius, I originally had a loop, but it did not work. I guess once I saw that repeating the code did not work either I should have gone back, instead of making the same changes three times.

Vid Kid, 0.ts is my version of your test.ts. The full script is 0portUpgrader.ts and includes Singularity's nearest port trader.

Oh. Weird. I just tried Promethius's version. I think that my original was the exact same, except with waitFors instead of waitOns.

It worked.

I copied it into 0portUpgrader.ts and now I am a hundred and sixty million credits poorer.

Ouch.

Thanks guys? :)

By the way, I am not using my i7, I am using a public Dell running XP. Could it have been computer speed like Crosby said? :)

So... what is my next project? Oh, trust me, you guys will know all about it! :)

_________________
Photons away!


Fri Mar 25, 2011 8:31 pm
Profile
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1134
Location: Augusta, GA
Unread post Re: Port upgrader
A waitFor trigger is disabled if any other trigger fires. I believe all of the other triggers, including waitOn, persist until they either fire or are killed.

So if you do this:
setTextTrigger fuelHolds :getHolds "How many holds of Fuel Ore"
waitFor "We'll buy them for"

The setTextTrigger will fire first, which kills any waitFor triggers if I recall correctly. But you could do this:
setTextTrigger fuelHolds :getHolds "How many holds of Fuel Ore"
setTextLineTrigger firstOffer :getOffer "We'll buy them for "
pause

When the first trigger fires, the other trigger persists. Now many people killAllTriggers and reset triggers every time a trigger fires, which is poor trigger management. What I like to do is set all of the triggers for a particular sequence, and let the triggers flow from one to the other. Observe:
Code:
send "pt*"
waitOn "<Port>"
setTextLineTrigger productType :getProduct "How many holds of "
setTextLineTrigger agreedQty :getQty "Agreed, "
setTextLineTrigger initOffer :getOffer "We'll buy them for "
pause

:getProduct
getWord CURRENTLINE $product 5
if ($product = "Fuel")
     getWord CURRENTLINE $buyOrSell 11
else
     getWord CURRENTLINE $buyOrSell 10
end
pause

:getQty
getWord CURRENTLINE $qty 2
pause

:getOffer
getWord CURRENTLINE $offer 5
stripText $offer ","
gosub :sendOffer

Start with a waitOn that triggers on text that will always be seen just before the text we're triggering off of, like "<Port>", then all of the triggers will fire as their text is processed in. The triggers firing make our script flow from :getProduct, to :getQty, and finally to :getOffer. Notice there are no killTrigger or killAllTriggers, yet when we hit the gosub on that last line, all of the triggers have fired and are no longer active.

Let your triggers do the work.

+EP+

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


Fri Mar 25, 2011 10:18 pm
Profile WWW
Lieutenant

Joined: Fri Apr 05, 2002 3:00 am
Posts: 580
Location: USA
Unread post Re: Port upgrader
I had a script that would upgrade ports then go andf warp a planet to it and buy and sell.

I think I shared it a few times.

If anyone has it, fell free to share. I havent kept up with my scripts.

BTW Hi everyone

_________________
My scripts can be downloaded at http://www.grimytrader.com/.
Ore *****.
Even in my signature it's blocked out.


Thu Apr 07, 2011 8:31 pm
Profile ICQ YIM
Display posts from previous:  Sort by  
Reply to topic   [ 20 posts ]  Go to page Previous  1, 2

Who is online

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