Top Level Namespace

Instance Method Summary (collapse)

Instance Method Details

- (void) echo(value)

This method returns an undefined value.

Sends a message to client main window.

Examples:

Echoing into client main window.

echo "hello"
echo 1

Parameters:

  • value (#to_s)

    message.



172
173
174
# File 'main.rb', line 172

def echo(value)
  puts "#{API::API_ECHO_PREFIX}#{value.to_s}#{API::API_CMD_SUFFIX}"
end

- (Integer) get_match_rt

Current match round time – can be used in secondary threads while main thread is stuck in round time

Returns:

  • (Integer)

    current round time value



205
206
207
# File 'main.rb', line 205

def get_match_rt
  $_api_current_rt
end

- (Void) load(name)

Load a script by name.

Parameters:

  • name (String)

    name of the file

Returns:

  • (Void)


188
189
190
# File 'main.rb', line 188

def load(name)
  Kernel.load name
end

- (void) move(dir)

This method returns an undefined value.

Sends a move command to client and waits for navigation message.

Examples:

Using move command in script.

move "n"
move "e"
move "go gate"

Parameters:

  • dir (String)

    command.



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'main.rb', line 134

def move(dir)
  puts "#{API::API_PUT_PREFIX}#{dir.to_s}#{API::API_CMD_SUFFIX}"
  case match_wait({ :room => [/^\{nav\}$/],
                    :stand => [/do that while (sitting|kneeling|lying)|must be standing|cannot manage to stand/],
                    :retreat => [/if you first retreat|You are engaged|do that while engaged/],
                    :wait => [/\.\.\.wait|you may only type ahead/] })
    when :wait
      pause 0.5
      move dir
    when :stand
      pause 0.5
      put "stand"
      move dir
    when :retreat
      put "retreat"
      put "retreat"
      move dir
  end
end

- (Void) pause(value = 1)

Pauses for given time.

Parameters:

  • value (Integer, Float) (defaults to: 1)

    sleep time in seconds, default value = 1

Returns:

  • (Void)


180
181
182
# File 'main.rb', line 180

def pause(value = 1)
  sleep value
end

- (void) pause_for_roundtime

Deprecated.

Please use #pause_rt instead

This method returns an undefined value.

Pauses during rt and accounts for interrupted time



213
214
215
# File 'main.rb', line 213

def pause_for_roundtime
  pause_rt
end

- (void) pause_rt

This method returns an undefined value.

Pauses during rt and accounts for any interrupted time



220
221
222
223
224
# File 'main.rb', line 220

def pause_rt
  if $_api_current_rt > 0
    API::sleep_rt $_api_current_rt + $rt_adjust
  end
end

- (void) put(value)

This method returns an undefined value.

Sends a command to server.

Parameters:

  • value (String)

    command.



158
159
160
161
162
163
# File 'main.rb', line 158

def put(value)
  $_api_gets_mutex.synchronize do
    $_api_queue.clear
    puts "#{API::API_PUT_PREFIX}#{value.to_s}#{API::API_CMD_SUFFIX}"
  end
end

- (Void) require(name)

Require a script by name. Only loads file once during the script execution.

Parameters:

  • name (String)

    name of the file

Returns:

  • (Void)


197
198
199
# File 'main.rb', line 197

def require(name)
  Kernel.require name
end