Module: Olib
- Defined in:
- lib/Olib/core/extender.rb,
lib/Olib.rb,
lib/Olib/go2.rb,
lib/Olib/shops.rb,
lib/Olib/bounty.rb,
lib/Olib/version.rb,
lib/Olib/core/item.rb,
lib/Olib/utils/cli.rb,
lib/Olib/utils/cli.rb,
lib/Olib/core/utils.rb,
lib/Olib/core/errors.rb,
lib/Olib/objects/box.rb,
lib/Olib/objects/jar.rb,
lib/Olib/objects/herb.rb,
lib/Olib/objects/wand.rb,
lib/Olib/objects/jewel.rb,
lib/Olib/core/container.rb,
lib/Olib/objects/scroll.rb,
lib/Olib/character/group.rb,
lib/Olib/combat/creature.rb,
lib/Olib/objects/jewelry.rb,
lib/Olib/objects/unknown.rb,
lib/Olib/utils/help_menu.rb,
lib/Olib/combat/creatures.rb,
lib/Olib/objects/clothing.rb,
lib/Olib/objects/uncommon.rb,
lib/Olib/utils/monsterbold.rb,
lib/Olib/character/inventory.rb,
lib/Olib/dictionary/dictionary.rb
Overview
a collection for managing all of the creatures in a room
Defined Under Namespace
Modules: Errors, Inventory, Shop
Classes: Bounty, Box, Clothing, Container, Creature, Creatures, Dictionary, Gameobj_Extender, Go2, Group, HelpMenu, Herb, Item, Jar, Jewel, Jewelry, Lootsack, ScriptVars, Scroll, Transport, Uncommon, Unknown, Wand
Constant Summary
collapse
- VERSION =
"0.1.0"
- @@debug =
false
- @@xml =
false
Class Method Summary
collapse
Class Method Details
.debug(msg) ⇒ Object
83
84
85
86
|
# File 'lib/Olib/core/utils.rb', line 83
def Olib.debug(msg)
return unless @@debug
echo "Olib.debug> #{msg}"
end
|
.do(action, re) ⇒ Object
37
38
39
|
# File 'lib/Olib.rb', line 37
def Olib.do(action, re)
dothistimeout action, 5, re
end
|
.Go2 ⇒ Object
138
139
140
|
# File 'lib/Olib/go2.rb', line 138
def Olib.Go2
Olib::Go2
end
|
.install(g, v = nil) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/Olib.rb', line 46
def Olib.install(g, v=nil)
if !which("gem") then
echo "Olib could not detect the `gem` executable in your $PATH"
echo "when you installed Ruby did you forget to click the `modify $PATH` box?"
raise Exception
end
begin
unless v.nil?
raise UpdateGemError if Gem.loaded_specs[g].version < Gem::Version.new(v)
gem g, v
end
Olib.reload g
rescue LoadError
echo "installing #{g}..."
version = "--version '#{v}'" unless v.nil?
worked = system("gem install #{g} #{version} --no-ri --no-rdoc")
unless worked then raise "Could not install #{g} gem" end
Olib.reload g
echo "... installed #{g}!"
rescue UpdateGemError
echo "updating #{g}@#{Gem.loaded_specs[g].version} => #{v}..."
version = "--version '#{v}'" unless v.nil?
worked = system("gem install #{g} #{version} --no-ri --no-rdoc")
unless worked then raise "Could not install #{g} gem" end
Olib.reload g
echo "... updated #{g} to #{v}!"
end
end
|
.Inventory ⇒ Object
77
78
79
|
# File 'lib/Olib/character/inventory.rb', line 77
def Olib.Inventory
Olib::Inventory
end
|
.Lootsack ⇒ Object
180
181
182
183
184
|
# File 'lib/Olib/core/container.rb', line 180
def Olib.Lootsack
return @@lootsack if @@lootsack
@@lootsack = Lootsack.new
@@lootsack
end
|
.methodize(str) ⇒ Object
20
21
22
|
# File 'lib/Olib.rb', line 20
def Olib.methodize(str)
str.downcase.strip.gsub(/-|\s+|'|"/, "_")
end
|
.monsterbold(str) ⇒ Object
2
3
4
|
# File 'lib/Olib/utils/monsterbold.rb', line 2
def Olib.monsterbold(str)
"<pushBold/>#{str}<popBold/>"
end
|
.run(script, *args) ⇒ Object
41
42
43
44
|
# File 'lib/Olib.rb', line 41
def Olib.run(script, *args)
start_script script, args
wait_while { running? script }
end
|
.script ⇒ Object
120
121
122
|
# File 'lib/Olib/core/utils.rb', line 120
def Olib.script
Script.current
end
|
.Shop ⇒ Object
174
175
176
|
# File 'lib/Olib/shops.rb', line 174
def Olib.Shop
Olib::Shop
end
|
.timeout(sec) ⇒ Object
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/Olib/core/utils.rb', line 88
def Olib.timeout(sec) return yield(sec) if sec == nil or sec.zero?
begin
current_thread = Thread.current
x = Thread.start{
begin
yield(sec)
rescue => e
current_thread.raise e
end
}
y = Thread.start {
begin
sleep sec
rescue => e
x.raise e
else
x.kill
current_thread.raise Olib::Errors::TimedOut
end
}
x.value
ensure
if y
y.kill
y.join end
end
end
|
.toggle_debug ⇒ Object
79
80
81
|
# File 'lib/Olib/core/utils.rb', line 79
def Olib.toggle_debug
@@debug = @@debug ? false : true
end
|
.turn_off_xml ⇒ Object
132
133
134
135
136
137
138
|
# File 'lib/Olib/core/utils.rb', line 132
def Olib.turn_off_xml
if @@xml
@@xml = false
Script.current.want_downstream_xml = @@xml
end
self
end
|
.turn_on_xml ⇒ Object
124
125
126
127
128
129
130
|
# File 'lib/Olib/core/utils.rb', line 124
def Olib.turn_on_xml
if not @@xml
@@xml = true
Script.current.want_downstream_xml = @@xml
end
self
end
|
.update_notifier ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/Olib.rb', line 6
def Olib.update_notifier
begin
response = JSON.parse Net::HTTP.get URI('https://rubygems.org/api/v1/gems/Olib.json')
if Gem.loaded_specs["Olib"].version < Gem::Version.new(response['version'])
puts "<pushBold/>You need to update the Olib gem with a `gem install Olib`<popBold/>"
end
rescue
echo $!
puts $!.backtrace[0..1]
end
end
|
.wrap(action = nil) ⇒ Object
.wrap_greedy(action) ⇒ Object
.wrap_stream(action = nil) ⇒ Object
.xml? ⇒ Boolean
140
141
142
|
# File 'lib/Olib/core/utils.rb', line 140
def Olib.xml?
@@xml
end
|