Class: RuneRb::Game::Entity::Commands::To

Inherits:
RuneRb::Game::Entity::Command show all
Defined in:
app/game/entity/commands/to.rb

Overview

A command that teleports a player to a specific position.

Since:

  • 0.9.3

Instance Method Summary collapse

Methods inherited from RuneRb::Game::Entity::Command

#initialize

Methods included from System::Log

#class_name, #err, #err!, #log, #log!, #symbolize_file

Constructor Details

This class inherits a constructor from RuneRb::Game::Entity::Command

Instance Method Details

#executeObject

Since:

  • 0.9.3


5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/game/entity/commands/to.rb', line 5

def execute
  unless @assets[:command].size >= 2
    @assets[:context].session.write_message(:SystemTextMessage, message: "Not enough parameters for to command! Required: 2, Provided: #{@assets[:command].size}")
    return
  end
  position = RuneRb::Game::Map::Position.new(@assets[:command][0].to_i,
                                       @assets[:command][1].to_i,
                                       @assets[:command].length > 2 ? @assets[:command][2].to_i : 0)

  @assets[:context].session.write_message(:SystemTextMessage, message: "Moving to #{position.inspect}...")
  @assets[:context].teleport(position)
end