Oct. 21, 2018

Hello der,  Guest
Trader Name:
Password:
 | Home | Forum List | Active Threads | Search:
Page: of 1   
TWX Support > Port  
<< Thread >>
Subscribed:  
Krovach

Joined: Apr 2009

posted: 04/18/2009 at 02:56 PM Post #1

Hi!  I've seen a lot of different tutorials on scripting in TWX.  Are there any tutorials that specifically teach ports scripts?  I've seen several extremely good planet related script tutorials, but no port scripting tutorials?!

Can anyone recommend one?  Thanks!
ElderProphet
TWX Development Team

Joined: Mar 2005

posted: 04/23/2009 at 09:42 PM Post #2

I have no recommendations, but ask any questions and I'm sure you'll get plenty of answers.

Haggle Blog-> http://jroller.com/page/ElderProphet
Krovach

Joined: Apr 2009

posted: 04/26/2009 at 02:06 PM Post #3

I was wanting to start off with a script similar to "SellOff" for ZOC.  I wanted to eventually evolve it into something a bit more advanced.

For the time being, I want it to start from the sector and the player specifies which product(s) to sell and which planet(s) to sell from.  I don't need the popup windows that ZOC uses, but are these available in TWX?
ElderProphet
TWX Development Team

Joined: Mar 2005

posted: 04/27/2009 at 06:10 PM Post #4

There aren't any pop up windows where you ask for starting information.  You just echo your question and use getConsoleInput to capture their response.  So to get the products and planets... you might do this:

:getProduct
echo "*What product to sell off? (F/O/E)"
getConsoleInput $product SINGLEKEY
upperCase $product
if ($product <> "F") and ($product <> "O") and ($product <> "E")
  echo "*Invalid.  Enter F, O, or E.*"
  goto :getProduct
end
echo "*Selling " $product "*"

:getPlanets
echo "*Enter the planet number, or blank when done."
getConsoleInput $planetNumber
while ($planetNumber <> "")
  add $planetCount 1
  setVar $planets[$planetCount] $planetNumber
  echo "*Added Planet " $planetNumber "*"
  goto :getPlanets
end

:sellOff
setVar $i 1
while ($i <= $planetCount)
  send "pn" $planets[$i] "*"
  setTextLineTrigger product :sellProduct "How many units of "
  setTextTrigger done :sellDone "Command"
  pause
  :sellProduct
  getWord CURRENTLINE $sellProduct 5
  cutText $sellProduct $firstLetter 1 1
  if ($firstLetter = $product)
    send "**"
    # Or to use with my haggle...
    # send "*"
    # waitOn "You have "
  else
    send "0*"
  end
  setTextLineTrigger product :sellProduct "How many units of "
  pause
  :sellDone
  add $i 1
end

That should give you a fair taste of basic techniques.  You can use some of the techniques from :getPlanets if you wanted to get more than one product... but that will be a good exercise for you to try out.  Caveat: I have no idea if that will compile, as I haven't tested it.  It looks good to me, though I've used some abbreviated subroutines for the sake of brevity.

+EP+

Haggle Blog-> http://jroller.com/page/ElderProphet
Krovach

Joined: Apr 2009

posted: 04/28/2009 at 07:11 PM Post #5

Wow!  Thanks!

BTW: I was checking out your perfect haggle script and was wondering how to use it?  I mean like with Swath World Trade for instance?
ElderProphet
TWX Development Team

Joined: Mar 2005

posted: 04/29/2009 at 09:41 PM Post #6

Obviously it requires TWX.  Beyond that, just launch it, make sure swath offer capture is on, and hit semi-colon to make it wait in the background.

Then whenever swath (for example) initiates a trade, the haggle script will jump in and do it's thing.  It's like other haggles, only more green.  That's right, it's environmentally and wallet friendly.

edited by: ElderProphet on 04/29/2009 at 09:44 PM

Haggle Blog-> http://jroller.com/page/ElderProphet
Krovach

Joined: Apr 2009

posted: 05/02/2009 at 04:57 PM Post #7

What if the other script tries to haggle at the same time?  Won't some "wires" get "crossed"?
Krovach

Joined: Apr 2009

posted: 05/02/2009 at 11:33 PM Post #8

Ok, it seems to work with SellOff for ZOC, but it tries to warp out of the sector for some reason (after a dozen or so trades).  I guess your script is attempting to make an offer and TW mistakes it for a command to warp.  Nice, though.  I get 2 exp per trade every time.  Plus the money!  Thanks!
Krovach

Joined: Apr 2009

posted: 05/03/2009 at 09:20 AM Post #9

So how exactly does that "setTextLineTrigger" work?  For instance, if I'm trying to determine whether a port is buying or selling and how much of each (from the command prompt)?

I understand the concept, but the syntax is a little confusing...

Or maybe you could explain this portion from your sample and I could write my own script for the above:
setTextLineTrigger product :sellProduct "How many units of "
setTextTrigger done :sellDone "Command"

Thanks!

UPDATE: Ah!  I found "script.html" in the TWXProxy's main folder!  Excellent reference!  Thanks for posting that in another thread!  ;-)

edited by: krovach on 05/03/2009 at 10:28 AM
Krovach

Joined: Apr 2009

posted: 05/03/2009 at 02:25 PM Post #10

I think I found the problem I was having with Zoc's SellOff script and ep_haggle2009.  I have to close Firefox and have Zoc on the front of my screen while the SellOff script is running.  This means I can't do other things (like program my own trading script) while I'm running it...

But I haven't had any problems when I do this.
ElderProphet
TWX Development Team

Joined: Mar 2005

posted: 05/05/2009 at 03:26 PM Post #11

You need to know more about the SellOff script.  It isn't part of ZOC.  If this script sends haggle attempts, then my haggle will attempt to trap them if option 6 is on, but it is dependant on how the SellOff script behaves.  Certainly, enable option 6 - Swath Offer Capture, and that may take care of it for you.

Having it at the front of your other windows will not affect it one way or the other, though it may allow you to respond to an error more quickly.

Regards,
+EP+

Haggle Blog-> http://jroller.com/page/ElderProphet
Krovach

Joined: Apr 2009

posted: 05/06/2009 at 02:22 PM Post #12

I think the reason it only works when I have ZOC open and up front is because the computer isn't that powerful and when your haggle script sends a bid the haggle is already over and it receives it as a command to warp.

Make no mistake: when I close other internet applications and have ZOC up front it works fine.  If I even have Notepad up front the script will crash.  This applies to any script I use with ZOC it seems.
TWX Support >  Port
<< Thread >>
Subscribed:  
 | Home | Forum List | Active Threads | Search:
Page: of 1   

"why hello der matey! have a sit and buy me an ale, eh?" -- The Grimy Old Trader

The Grimy Trader is best viewed at 1024x768 resolution -- this page was generated in: 0.391 seconds.