class NWN::Tlk::TlkSet

A TlkSet wraps a set of File objects, each pointing to the respective tlk file, making retrieval easier.

Attributes

cf[R]

The custom female Tlk, if specified (cm if no female custom tlk has been specified, nil if none).

cm[R]

The custom male Tlk, or nil.

df[R]

The default female Tlk, (or the default male).

dm[R]

The default male Tlk.

Public Class Methods

new(tlk, tlkf = nil, custom = nil, customf = nil) click to toggle source
# File lib/nwn/tlk.rb, line 154
def initialize tlk, tlkf = nil, custom = nil, customf = nil
  @dm = Tlk.new(tlk)
  @df = tlkf ? Tlk.new(tlkf) : @dm
  @cm = custom ? Tlk.new(custom) : nil
  @cf = customf ? Tlk.new(customf) : @cm
end

Public Instance Methods

[](id, gender = :male) click to toggle source
# File lib/nwn/tlk.rb, line 161
def [](id, gender = :male)
  raise ArgumentError, "Invalid Tlk ID: #{id.inspect}" if id > 0xffffffff
  (if id < 0x01000000
    gender == :female && @df ? @df : @dm
  else
    raise ArgumentError, "Wanted a custom ID, but no custom talk table has been specified." unless @cm
    id -= 0x01000000
    gender == :female && @cf ? @cf : @cm
  end)[id]
end