class Goby::NPC

A non-player character with whom the player can interact. Always activated with the 'talk' command.

Attributes

name[RW]

Public Class Methods

new(name: "NPC", mode: 0, visible: true) click to toggle source

@param [String] name the name. @param [Integer] mode convenient way for a NPC to have multiple actions. @param [Boolean] visible whether the NPC can be seen/activated.

Calls superclass method Goby::Event::new
# File lib/goby/event/npc.rb, line 12
def initialize(name: "NPC", mode: 0, visible: true)
  super(mode: mode, visible: visible)
  @name = name
  @command = "talk"
end

Public Instance Methods

run(player) click to toggle source

The function that runs when the player speaks to the NPC.

@param [Player] player the one speaking to the NPC.

# File lib/goby/event/npc.rb, line 21
def run(player)
  say "Hello!\n\n"
end
say(words) click to toggle source

Function that allows NPCs to output a string of words.

@param [String] words string of words for the NPC to speak.

# File lib/goby/event/npc.rb, line 28
def say(words)
  type "#{name}: #{words}"
end