Module: NWN

Included in:
Gff::Scripting::Sandbox
Defined in:
lib/nwn/erf.rb,
lib/nwn/gff.rb,
lib/nwn/res.rb,
lib/nwn/tlk.rb,
lib/nwn/twoda.rb,
lib/nwn/settings.rb

Defined Under Namespace

Modules: Erf, Gff, Resources, Tlk, TwoDA

Constant Summary collapse

YAML_DOMAIN =

See www.taguri.org/ for the exact meaning of this.

"nwn-lib.elv.es,2008-12"

Class Method Summary collapse

Class Method Details

.log_debug(msg) ⇒ Object

This writes a internal warnings and debug messages to stderr.

Leaving this on is recommended, since it usually points to (fixable) errors in your resource files. You can turn this off anyways by setting the environment variable NWN_LIB_DEBUG to “0” or “off”.

Will return true when printed, false otherwise.



11
12
13
14
15
16
17
18
19
# File 'lib/nwn/settings.rb', line 11

def self.log_debug msg
  # Do not print debug messages if explicitly turned off
  return false if [false, "off"].index(setting(:debug))

  pa = caller[0].to_s
  pa = pa[(pa.size - 36) .. -1] if pa.size > 36
  $stderr.puts "(nwn-lib) %s: %s" % [pa, msg]
  true
end

.setting(sym, value = :_invalid_) ⇒ Object

Get or set a ENV var setting. Returns false for “0” values. Returns the old value for new assignments.



24
25
26
27
28
29
30
31
32
33
# File 'lib/nwn/settings.rb', line 24

def self.setting sym, value = :_invalid_
  name = "NWN_LIB_#{sym.to_s.upcase}"
  if value != :_invalid_
    ret = ENV[name] == "0" ? false : ENV[name]
    ENV[name] = value.to_s if value != :_invalid_
    ret
  else
    ENV[name] == "0" ? false : ENV[name]
  end
end