704 monitor


SUBMITTED BY: rpgfilms

DATE: Aug. 16, 2015, 12:15 a.m.

FORMAT: Text only

SIZE: 6.3 kB

HITS: 17649

  1. =begin
  2. 704 monitor
  3. Will pop up a window when the script starts and write to it when ever you phase a container showing it's name and duration left.
  4. If you would like to change the window height open up the script(notepad will do) and change the line at the top that reads height = 55
  5. *** Update
  6. 29/4/2012 - Updated duration to cap at level
  7. ***Contact Me***
  8. If there is a problem with the script or you have suggestions feel free to contact Stormtov on http://forum.gsplayers.com
  9. =end
  10. Settings.load
  11. Settings[Char.name] = Hash.new unless Settings[Char.name].kind_of? Hash
  12. before_dying{;puts("<closeDialog id=\"704_monitor\"\/>");Settings.save;}
  13. height = 55 #Change the height of the window here(deafult 55, enough for 3 lines. With default font size add 11 for any extra line). If window is already open will need to be closesd before this change can take effect.
  14. def save_durations()
  15. if $time_phased.empty?
  16. Settings[Char.name]["time"] = "empty"
  17. else
  18. x=0
  19. saved_time = Array.new
  20. loop{
  21. saved_time[x] = Time.now - $time_phased[x]
  22. x = x + 1
  23. break if x > ($time_phased.length - 1)
  24. }
  25. Settings[Char.name]["time"] = saved_time
  26. $container_full.compact!
  27. Settings[Char.name]["saved_container_full"] = $container_full.compact
  28. $container_short.compact!
  29. Settings[Char.name]["saved_container_short"] = $container_short.compact
  30. end
  31. end
  32. def load_duration()
  33. if Settings[Char.name]["time"] == "empty"
  34. clear_arrays()
  35. else
  36. x = 0
  37. $time_phased = Array.new
  38. loop{
  39. $time_phased[x] = Time.now - Settings[Char.name]["time"][x]
  40. x = x + 1
  41. $x = x
  42. break if x > (Settings[Char.name]["time"].length - 1)
  43. }
  44. $container_full = Settings[Char.name]["saved_container_full"]
  45. $container_short = Settings[Char.name]["saved_container_short"]
  46. end
  47. end
  48. def shorten()
  49. x = 0
  50. y = 0
  51. $container_split = $container_full[$x].split(" ")
  52. $container_split.compact!
  53. $check = false
  54. loop {
  55. if $container_split[x]== $container_short[$x]
  56. $check = true
  57. x = x + 1
  58. end
  59. if $check == true
  60. $container_split[x] = nil
  61. end
  62. x = x + 1
  63. break if x > ($container_split.length - 1)
  64. }
  65. $container_full[$x] = $container_split.compact! * " "
  66. end
  67. def remove()
  68. x = 0
  69. loop {
  70. if $container_full[x] =~ /#{$remove_item}/
  71. $time_phased[x] = $time_phased[x] - $duration
  72. break
  73. else
  74. x = x + 1
  75. break if x > ($container_full.length - 1)
  76. end
  77. }
  78. end
  79. def clear_arrays()
  80. $container_full = Array.new
  81. $container_short = Array.new
  82. $time_phased = Array.new
  83. $x = 0
  84. end
  85. puts("<openDialog type='dynamic' id='704_monitor' title='Phase Duration Monitor' location='center' height='#{height}' width='300'><dialogData id='espWindowControl'><label id='lblHeader' value='' top='0' left='0' width='138'/></dialogData></openDialog>")
  86. if Settings[Char.name]["first_time?"] != "no"
  87. echo "This script should track your durations fine unless you kill the script and stayed logged into game. It will save the durations though so if you log out it will remember the durations. Just make sure to add the script to your favourates so it runs on startup"
  88. respond "If for what ever reason the timing is off you can remove them from the window manually using ';send 704monitor clear (all/1/2/3...)' Entering all clears all the window entering a number clears just the line only(ie entering 2 will clear just the second line)"
  89. respond "This message will only display once so hope you were paying attention"
  90. clear_arrays()
  91. else
  92. load_duration()
  93. end
  94. Settings[Char.name]["first_time?"] = "no"
  95. Settings.save
  96. if Spells.sorcerer > Char.level
  97. $duration = 600 + (Char.level * 6)
  98. else
  99. $duration = 600 + (Spells.sorcerer * 6)
  100. end
  101. phase_monitor = Thread.new {
  102. loop {
  103. line = get
  104. if line =~ /You gesture at a shifting (.+)\./
  105. $remove_item = $1
  106. line = get
  107. if line =~ /Your spell has no effect/
  108. $remove_item = nil
  109. else
  110. remove()
  111. end
  112. elsif line =~ /You gesture at (a|an) (.+)\./
  113. $container_full[$x] = $2
  114. elsif line =~ /The (.+) becomes momentarily insubstantial and appears lighter\.|The (.+) becomes somewhat insubstantial and appears lighter\./
  115. if $1.empty? == false
  116. $container_short[$x] = $1
  117. else
  118. $container_short[$x] = $2
  119. end
  120. $time_phased[$x] = Time.now
  121. shorten()
  122. $x = $x + 1
  123. elsif line =~ /Your (.+) feels somewhat heavier./
  124. #ill get there
  125. elsif line =~ /(Your|The) (.+) flickers in and out of existence for a moment but then stabilizes. It seems heavier./
  126. $remove_item = $2
  127. remove()
  128. elsif line =~ /^704monitor clear (\w+)$/
  129. clear = $1
  130. if clear == "all"
  131. x = 0
  132. loop {
  133. $time_phased[x] = $time_phased[x] - $duration
  134. x = x + 1
  135. break if x > ($time_phased.length - 1)
  136. }
  137. else
  138. $time_phased[clear.to_i-1] = $time_phased[clear.to_i-1] - $duration
  139. end
  140. end
  141. z = 0
  142. loop {
  143. z=z+1
  144. break if z > ($container_short.length - 1)
  145. }
  146. }
  147. }
  148. duration_thread = Thread.new {
  149. loop {
  150. if $container_short.length > 0
  151. time_now = Time.now
  152. z=0
  153. loop {
  154. time_elapsed = time_now - $time_phased[z]
  155. $time_left = $duration - time_elapsed
  156. mins = $time_left/60
  157. secs = $time_left%60
  158. if $time_left > 0
  159. puts("<dialogData id='704_monitor'><label id='duration#{z}' value='#{$container_full[z]}: #{mins.to_i}M #{secs.to_i}' top='#{z*15}' left='0' height='20' align='n' width='300' tooltip='Meh'/></dialogData>")
  160. z=z+1
  161. else
  162. a=z
  163. $container_short[a] = nil
  164. $container_short.compact!
  165. $container_full[a] = nil
  166. $container_full.compact!
  167. $time_phased[a] = nil
  168. $time_phased.compact!
  169. loop {
  170. puts("<dialogData id='704_monitor'><label id='duration#{a}' value='' top='0' left='0' height='20' align='n' width='300' tooltip='Meh'/></dialogData>")
  171. a = a + 1
  172. break if a > ($container_short.length)
  173. }
  174. $x = $x - 1
  175. #z=z+1
  176. end
  177. #sleep 1
  178. break if z > ($container_short.length - 1)
  179. }
  180. else
  181. sleep 1
  182. end
  183. sleep 1
  184. }
  185. }
  186. save_thread = Thread.new {
  187. loop {
  188. save_durations()
  189. Settings.save
  190. sleep 1
  191. }
  192. }
  193. phase_monitor.join
  194. duration_thread.join
  195. save_thread.join

comments powered by Disqus