Top Level Namespace
Instance Method Summary (collapse)
-
- (Hash) match_get(pattern)
Matches regex patterns and returns pattern name along with matched text.
-
- (Hash) match_get_m(pattern)
Match get for multiple lines.
-
- (Symbol) match_wait(pattern)
Matches regex patterns and returns the name of the matching pattern.
-
- (Void) match_wait_goto(pattern)
Matches regex patterns and calls the defined label.
-
- (void) wait
Waits for a prompt character.
-
- (void) wait_for(pattern)
Runs until matching regex pattern is found in game text.
-
- (void) wait_for_roundtime
Waits for roundtime and pauses for the duration.
Instance Method Details
- (Hash) match_get(pattern)
Matches regex patterns and returns pattern name along with matched text
70 71 72 73 74 75 76 77 78 |
# File 'text.rb', line 70 def match_get(pattern) validate_pattern pattern $_api_exec_state = :match_get match = api_get_match pattern, Hash[pattern.keys.collect{ |v| [v, ""] }] m = match.find{ |k, v| !v.empty? } {:key => m[0], :match => m[1]} end |
- (Hash) match_get_m(pattern)
Match get for multiple lines.
94 95 96 97 98 99 100 101 |
# File 'text.rb', line 94 def match_get_m(pattern) validate_get_m validate_pattern pattern $_api_exec_state = :match_get_m match = api_get_match pattern, Hash[pattern.keys.collect{ |v| [v, []] }] match.delete_if{ |k, v| v.empty? } end |
- (Symbol) match_wait(pattern)
Matches regex patterns and returns the name of the matching pattern.
53 54 55 56 57 58 59 |
# File 'text.rb', line 53 def match_wait(pattern) validate_pattern pattern $_api_exec_state = :match_wait match = api_get_match pattern, Hash[pattern.keys.collect{ |v| [v, ""] }] match.find{ |k, v| !v.empty? }.first end |
- (Void) match_wait_goto(pattern)
Matches regex patterns and calls the defined label.
120 121 122 123 124 125 |
# File 'text.rb', line 120 def match_wait_goto(pattern) $_api_exec_state = :match_wait_goto match = api_get_match pattern, Hash[pattern.keys.collect{ |v| [v, ""] }] goto match.find{ |k, v| !v.empty? }.first end |
- (void) wait
This method returns an undefined value.
Waits for a prompt character.
136 137 138 139 |
# File 'text.rb', line 136 def wait #$_api_queue.clear wait_for(/>/) end |
- (void) wait_for(pattern)
This method returns an undefined value.
Runs until matching regex pattern is found in game text.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'text.rb', line 25 def wait_for(pattern) $_api_exec_state = :wait_for if pattern.is_a?(Array) pattern = Regexp.new(pattern.join('|')) end (0..1000000).each do line = API::sync_read if line and line.match(pattern) $_api_exec_state = :none return end sleep 0.01 end end |
- (void) wait_for_roundtime
This method returns an undefined value.
Waits for roundtime and pauses for the duration.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'text.rb', line 8 def wait_for_roundtime $_api_exec_state = :wait_for_roundtime (0..1000000).each do line = API::sync_read if line and line.match(/Roundtime/) $_api_exec_state = :none API::sleep_rt line[/\d+/].to_i + $rt_adjust return end sleep 0.01 end end |