1_Port.ts 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. # Copyright (C) 2005 Remco Mulder
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 2 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software
  15. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. #
  17. # For source notes please refer to Notes.txt
  18. # For license terms please refer to GPL.txt.
  19. #
  20. # These files should be stored in the root of the compression you
  21. # received this source in.
  22. # TWX Script Pack 1: Port pair trading script
  23. # Author : Xide
  24. # Description : Trades between two sectors with ports, buying and
  25. # selling products between them.
  26. # Haggles with a variable markup/markdown.
  27. # First docking is at the CURRENT sector of the player.
  28. # Trigger Point : Sector command prompt
  29. # Warnings : Ports must have enough products on board to make
  30. # this script worthwhile. Ideally trading should stop
  31. # once a port hits below 20%. This script assumes
  32. # there are no one-way warps between ports and that
  33. # they are adjacent to eachother. Be
  34. # sure there are no obstructions in either sector.
  35. # Other : I wouldn't try learning the script language here,
  36. # this script is quite complex and basically goes all
  37. # over the damn place :)
  38. # check if we can run it from here
  39. cutText CURRENTLINE $location 1 12
  40. if ($location <> "Command [TL=")
  41. clientMessage "This script must be run from the command prompt"
  42. halt
  43. end
  44. logging off
  45. # show script banner
  46. echo "**" ANSI_3 " --" ANSI_11 "===| " ANSI_15 "Port Pair Trading v2.00" ANSI_11 " |===" ANSI_3 "--**"
  47. echo ANSI_7 "No registration is required to use this script,*it is completely open source and can be opened*in notepad."
  48. echo "**" ANSI_15 "For your own safety, please read the warnings*written at the top of the script before*using it!*"
  49. # get user input
  50. getinput $sector2 "Enter sector to trade to" 0
  51. getinput $timesLeft "Enter times to execute script" 0
  52. getinput $percent "Enter markup/markdown percentage" 5
  53. # get the current sector
  54. send "d"
  55. setTextLineTrigger 1 :getSectorNumber "Sector : "
  56. pause
  57. :getSectorNumber
  58. getWord CURRENTLINE $sector1 3
  59. setVar $thisSector $sector1
  60. :sub_Trade
  61. killTrigger 0
  62. killTrigger 1
  63. killTrigger 2
  64. killTrigger 3
  65. killTrigger 4
  66. send "pt"
  67. waitfor "-----"
  68. getSector $thisSector $thisSect
  69. if ($thisSector = $sector1)
  70. getSector $sector2 $otherSect
  71. else
  72. getSector $sector1 $otherSect
  73. end
  74. if ($thisSect.Port.Class = 3) or ($thisSect.Port.Class = 4) or ($thisSect.Port.Class = 5) or ($thisSect.Class = 7)
  75. setVar $portStage 0
  76. end
  77. if ($thisSect.Port.Class = 2) or ($thisSect.Port.Class = 6)
  78. setVar $portStage 1
  79. else
  80. setVar $portStage 2
  81. end
  82. # haggle it!
  83. setTextLineTrigger 1 :selectHoldsSell "We are buying up to"
  84. setTextLineTrigger 2 :selectHoldsBuy "We are selling up to"
  85. setTextTrigger 3 :done "Command [TL="
  86. setTextTrigger 4 :sub_Trade "We're not interested."
  87. pause
  88. :selectHoldsSell
  89. send "*"
  90. setTextLineTrigger 1 :Haggle_Sell "We'll buy them for"
  91. pause
  92. :Haggle_Sell
  93. getWord CURRENTLINE $startPrice 5
  94. stripText $startPrice ","
  95. setVar $sellPerc (100 + $percent)
  96. :sub_Sell
  97. killTrigger 1
  98. killTrigger 0
  99. setVar $price $startPrice
  100. multiply $price $sellPerc
  101. divide $price 100
  102. send $price "*"
  103. subtract $sellPerc 1
  104. setTextLineTrigger 1 :sub_Sell "We'll buy them for"
  105. setTextLineTrigger 0 :sub_Sell "Our final offer"
  106. pause
  107. :selectHoldsBuy
  108. killTrigger 1
  109. killTrigger 0
  110. # see if we should buy this stuff - there might be a more profitable
  111. # thing to buy here
  112. # first see what we're trading
  113. setTextTrigger 2 :getTradeType "How many holds of"
  114. pause
  115. :getTradeType
  116. getWord CURRENTLINE $tradeType 5
  117. if ($tradeType = "Fuel")
  118. if (($thisSect.Port.Class = 5) or ($thisSect.Port.Class = 7)) and (($otherSect.Port.Class = 2) or ($otherSect.Port.Class = 3) or ($otherSect.Port.Class = 4) or ($otherSect.Port.Class = 8))
  119. # can buy equipment - fuel ore is worthless.
  120. send "0*"
  121. setTextLineTrigger 2 :selectHoldsBuy "We are selling up to"
  122. pause
  123. end
  124. if (($thisSect.Port.Class = 4) or ($thisSect.Port.Class = 7)) and (($otherSect.Port.Class = 1) or ($otherSect.Port.Class = 3) or ($otherSect.Port.Class = 5) or ($otherSect.Port.Class = 8))
  125. # can buy organics - fuel ore is worthless.
  126. send "0*"
  127. setTextLineTrigger 2 :selectHoldsBuy "We are selling up to"
  128. pause
  129. end
  130. if (($thisSect.Port.Class = 4) or ($thisSect.Port.Class = 7) or ($thisSect.Port.Class = 3) or ($thisSect.Port.Class = 5)) and (($otherSect.Port.Class = 3) or ($otherSect.Port.Class = 4) or ($otherSect.Port.Class = 5) or ($otherSect.Port.Class = 7))
  131. # no point buying fuel if it can't be sold
  132. send "0*"
  133. setTextLineTrigger 2 :selectHoldsBuy "We are selling up to"
  134. pause
  135. end
  136. end
  137. if ($tradeType = "Organics")
  138. if (($thisSect.Port.Class = 6) or ($thisSect.Port.Class = 7)) and (($otherSect.Port.Class = 2) or ($otherSect.Port.Class = 3) or ($otherSect.Port.Class = 4) or ($otherSect.Port.Class = 8))
  139. # can buy equipment - organics is worthless.
  140. send "0*"
  141. setTextLineTrigger 2 :selectHoldsBuy "We are selling up to"
  142. pause
  143. end
  144. if (($thisSect.Port.Class = 2) or ($thisSect.Port.Class = 4) or ($thisSect.Port.Class = 6) or ($thisSect.Port.Class = 7)) and (($otherSect.Port.Class = 2) or ($otherSect.Port.Class = 4) or ($otherSect.Port.Class = 6) or ($otherSect.Port.Class = 7))
  145. # no point buying organics if it can't be sold
  146. send "0*"
  147. setTextLineTrigger 2 :selectHoldsBuy "We are selling up to"
  148. pause
  149. end
  150. end
  151. if ($tradeType = "Equipment")
  152. if (($otherSect.Port.Class = 1) or ($otherSect.Port.Class = 5) or ($otherSect.Port.Class = 6) or ($otherSect.Port.Class = 7))
  153. # no point buying equipment if it can't be sold
  154. send "0*"
  155. setTextLineTrigger 2 :selectHoldsBuy "We are selling up to"
  156. pause
  157. end
  158. end
  159. send "*"
  160. setTextLineTrigger 2 :Haggle_Buy "We'll sell them for"
  161. pause
  162. :Haggle_Buy
  163. getWord CURRENTLINE $startPrice 5
  164. stripText $startPrice ","
  165. setVar $buyPerc (100 - $percent)
  166. :sub_Buy
  167. killTrigger 1
  168. killTrigger 0
  169. setVar $price (($startPrice * $buyPerc) / 100)
  170. send $price "*"
  171. add $buyPerc 1
  172. setTextLineTrigger 1 :sub_Buy "We'll sell them for"
  173. setTextLineTrigger 0 :sub_Buy "Our final offer"
  174. pause
  175. :done
  176. if ($thisSector = $sector1)
  177. send $sector2 "*"
  178. setVar $thisSector $sector2
  179. else
  180. subtract $timesLeft 1
  181. if ($timesLeft <= 0)
  182. halt
  183. end
  184. send $sector1 "*"
  185. setVar $thisSector $sector1
  186. end
  187. waitfor "Sector : "
  188. goto :sub_Trade