class Twisty::Command

Used to provide the descriptions, examples of and executable code of commands that the player can type.

Attributes

help1[R]

(String) An example of the command e.g. “take item”

help2[R]

(String) Short description of what the command actually does

Public Class Methods

new(help1, help2, func) click to toggle source

Initialiser. Use Engine.define_command() instead

help1

(String) An example of the command e.g. “take item”

help2

(String) Short description of what the command actually does

func

(Proc) Code that provides the commands effect(s). NOTE This must take exactly one argument of type Array[String]

# File lib/twisty/command.rb, line 30
def initialize(help1, help2, func)
        @help1 = help1
        @help2 = help2

        self.define_singleton_method(:exec, func)
end

Public Instance Methods

exec(args) click to toggle source

Executes this instance of command. This is redefined on a per-instance basis by Command.new().

args

(Array[String]) Words the player typed in

# File lib/twisty/command.rb, line 41
def exec(args)
        return
end

Protected Instance Methods

engine() click to toggle source

(Engine)

Convinience class so that each instances version of Command.exec() does not need to contain

engine = Engine.instance
# File lib/twisty/command.rb, line 51
def engine
        Twisty::Engine.instance()
end