muby 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. data/LICENSE +339 -0
  2. data/bin/muby +37 -0
  3. data/contrib/aardmud.org_4000/README.txt +39 -0
  4. data/contrib/aardmud.org_4000/aard-config.rb +234 -0
  5. data/contrib/aardmud.org_4000/aard-helpers.rb +464 -0
  6. data/contrib/aardmud.org_4000/aliases/aard-aliases.rb +205 -0
  7. data/contrib/aardmud.org_4000/gags/aard-gags.rb +182 -0
  8. data/contrib/aardmud.org_4000/misc/aard-affects.rb +252 -0
  9. data/contrib/aardmud.org_4000/misc/aard-know.rb +147 -0
  10. data/contrib/aardmud.org_4000/misc/aard-poznai_sebia.rb +191 -0
  11. data/contrib/aardmud.org_4000/misc/aard-prompts.rb +65 -0
  12. data/contrib/aardmud.org_4000/misc/aard-status_toggling.rb +156 -0
  13. data/contrib/aardmud.org_4000/misc/aard_consider_substitutions.rb +319 -0
  14. data/contrib/aardmud.org_4000/speedwalks/aard-sw-areas-hero.rb +86 -0
  15. data/contrib/aardmud.org_4000/speedwalks/aard-sw-areas-newbie.rb +98 -0
  16. data/contrib/aardmud.org_4000/speedwalks/aard-sw-areas-noble.rb +170 -0
  17. data/contrib/aardmud.org_4000/speedwalks/aard-sw-areas-vidblain.rb +88 -0
  18. data/contrib/aardmud.org_4000/speedwalks/aard-sw-areas.rb +850 -0
  19. data/contrib/aardmud.org_4000/speedwalks/aard-sw-clans.rb +43 -0
  20. data/contrib/aardmud.org_4000/speedwalks/aard-sw-guilds.rb +13 -0
  21. data/contrib/aardmud.org_4000/speedwalks/aard-sw.rb +45 -0
  22. data/contrib/aardmud.org_4000/triggers/aard-triggers-items.rb +254 -0
  23. data/contrib/aardmud.org_4000/triggers/aard-triggers.rb +227 -0
  24. data/contrib/sy/cce.rb +120 -0
  25. data/lib/muby.rb +15 -0
  26. data/lib/muby/application.rb +66 -0
  27. data/lib/muby/completer.rb +62 -0
  28. data/lib/muby/configuration.rb +379 -0
  29. data/lib/muby/connection.rb +332 -0
  30. data/lib/muby/displayer.rb +60 -0
  31. data/lib/muby/help.rb +88 -0
  32. data/lib/muby/helper_methods.rb +46 -0
  33. data/lib/muby/inputwindow.rb +173 -0
  34. data/lib/muby/logger.rb +28 -0
  35. data/lib/muby/outputwindow.rb +189 -0
  36. data/lib/muby/style.rb +142 -0
  37. data/lib/muby/user_methods.rb +463 -0
  38. metadata +90 -0
@@ -0,0 +1,147 @@
1
+ #
2
+ # Knowledge-aid
3
+ #
4
+
5
+ # know <filename> display the contents of the @file
6
+ # know <filename> -1 delete the last line
7
+ # know <filename> -2 delete the last two lines
8
+ # know <filename> <string> append <string> to the @file
9
+ # From the commandline, double-quotes aren't needed and are in fact ignored.
10
+
11
+
12
+ # TODO: Allow double-quotes from the commandline. Somehow. =/
13
+ # FIXME: This assumes read/write permissions on the directory and @files.
14
+
15
+ conf.local_triggers[/^know(.*)$/] = Proc.new do |inwin, outwin, match| know match[1..-1] ; false end
16
+ def know (string)
17
+ string = string.join(' ').lstrip
18
+ string = string.gsub("\"", "")
19
+ string = string.split(' ')
20
+ # pprint string.inspect
21
+
22
+ # Get to the right working directory:
23
+ begin
24
+ Dir.chdir(ENV["HOME"] + "/mubyrc.d/aardwolf/knowledge/")
25
+ # If the chdir fails (the directory does not exist), then make the chain of directories.
26
+ rescue Errno::ENOENT
27
+ if not File.exists?(ENV["HOME"] + "/mubyrc.d/aardwolf/knowledge/") then
28
+ if not File.exists?(ENV["HOME"] + "/mubyrc.d/aardwolf/") then
29
+ if not File.exists?(ENV["HOME"] + "/mubyrc.d/") then
30
+ if not File.exists?(ENV["HOME"]) then
31
+ pprint "ERROR: #{ENV["HOME"]} does not exist!"
32
+ return false
33
+ end
34
+ Dir.mkdir(ENV["HOME"] + "/mubyrc.d/")
35
+ end
36
+ Dir.mkdir(ENV["HOME"] + "/mubyrc.d/aardwolf/")
37
+ end
38
+ Dir.mkdir(ENV["HOME"] + "/mubyrc.d/aardwolf/knowledge/")
39
+ end
40
+ end
41
+
42
+ if string[0] == nil then
43
+ # The non-portable version:: pprint `ls -al --sort=time --reverse ./`
44
+ # Set up an empty hash:
45
+ directory = {}
46
+ Dir.glob("*.txt").each { |file|
47
+ directory.merge!({file, File.stat(file).mtime})
48
+ } ; nil
49
+ directory = directory.sort {|a,b| a[1]<=>b[1]} ; nil
50
+ directory.each_index { |i|
51
+ pprint "#{directory[i][1]} \t #{directory[i][0]}"
52
+ } ; nil
53
+ return false
54
+ end
55
+
56
+ # Do I need the full working path?
57
+ @file = File.join(Dir.pwd, string[0].downcase + ".txt")
58
+ # @file = string[0] + ".txt"
59
+ # pprint @file.inspect
60
+
61
+ def make_output
62
+ @output = []
63
+ File.open(@file, 'r+').each { |line|
64
+ @output << line.chomp
65
+ }
66
+ end
67
+
68
+ # pprint string[1].inspect
69
+ case string[1]
70
+ when nil then
71
+ # The non-portable version:: pprint `more #{@file}`
72
+ pprint "Displaying #{@file}"
73
+ File.open(@file, 'r+').each { |line|
74
+ pprint line.chomp
75
+ }
76
+ return false
77
+ when "-1" then
78
+ # non-portable version:
79
+ # `sed '$d' "#{@file}" > temporary`
80
+ # `mv -f temporary #{@file}`
81
+ make_output
82
+ pprint "Removing the last line from #{@file}"
83
+ if @output.length <= 1 then
84
+ pprint "#{@file} has only one line. Deleting it."
85
+ File.delete(@file)
86
+ return false
87
+ end
88
+ File.open(@file, 'w') { |f| # prepare @file for appending content
89
+ # All of the output, from the first line to the second-last line.
90
+ f.print(@output[0..-2].join("\n"))
91
+ f.print("\n")
92
+ } # @file is automatically closed
93
+ when "-2" then
94
+ # non-portable version:
95
+ # `sed 'N;$!P;$!D;$d' "#{@file}" > temporary`
96
+ # `mv -f temporary #{@file}`
97
+ make_output
98
+ pprint "Removing the last two lines from #{@file}"
99
+ if @output.length <= 2 then
100
+ pprint "#{@file} has one or two lines. Deleting it."
101
+ File.delete(@file)
102
+ return false
103
+ end
104
+ File.open(@file, 'w') { |f| # prepare @file for appending content
105
+ # All of the output, from the first line to the third-last line.
106
+ f.print(@output[0..-3].join("\n"))
107
+ f.print("\n")
108
+ } # @file is automatically closed
109
+ else
110
+ # If @file doesn't exist, make an empty one:
111
+ if File.exists?(@file) == false then
112
+ File.open(@file, 'w+') do |f| # open @file for update
113
+ f.print "" # write out nothing
114
+ end
115
+ end
116
+ pprint "Appending to #{@file}"
117
+ # The non-portable version:: pprint `echo #{Time.now} #{string[1..-1].join(' ')} >> #{@file}`
118
+ File.open(@file, 'a') do |f| # prepare @file for appending content
119
+ f.print(
120
+ # the string without the first word:
121
+ "#{Time.now} \t #{string[1..-1].join(" ")} \n"
122
+ ) # insert the string
123
+ end # @file is automatically closed
124
+ end
125
+
126
+ # Display (some of) the contents of @file:
127
+ # The non-portable version :: pprint `tail #{@file}`
128
+ make_output
129
+ if @output.length > 9 then
130
+ # If I have a big @file, just output the last 10 lines in it.
131
+ @output[-10..-1].each { |i|
132
+ pprint i
133
+ }
134
+ else
135
+ # If I have a small @file, output it all
136
+ @output.each { |i|
137
+ pprint i
138
+ }
139
+ end
140
+
141
+ if File.zero?(@file) == true then
142
+ pprint "#{@file} is empty, deleting it."
143
+ File.delete(@file)
144
+ end
145
+ # So that the alias does not spit the text out to the server:
146
+ return false
147
+ end
@@ -0,0 +1,191 @@
1
+ #
2
+ # Learn from the score
3
+ #
4
+ # conf.local_triggers[/^score$/] = :score
5
+
6
+ def score
7
+ conf.remote_triggers[/^\| Strength : \[(.+)\/(.+)\] \| Race : (.+)\| Practices : \[(.+)\] \|$/] = Proc.new do |inwin, outwin, match|
8
+ $str_now = match[1].lstrip.to_i
9
+ $str_max = match[2].rstrip.to_i
10
+ $race = match[3].rstrip
11
+ $pracs = match[4].lstrip.rstrip.to_i
12
+ end
13
+ conf.remote_triggers[/^\| Intelligence : \[(.+)\/(.+)\] \| Class: (.+)\| Trains : \[(.+)\] \|$/] = Proc.new do |inwin, outwin, match|
14
+ $int_now = match[1].lstrip.to_i
15
+ $int_max = match[2].rstrip.to_i
16
+ $class = match[3].rstrip
17
+ $trains = match[4].lstrip.rstrip.to_i
18
+ end
19
+ conf.remote_triggers[/^\| Wisdom : \[(.+)\/(.+)\] \| Sex : (Male|Female).+\| Trivia : \[(.+)\] \|$/] = Proc.new do |inwin, outwin, match|
20
+ $wis_now = match[1].lstrip.to_i
21
+ $wis_max = match[2].rstrip.to_i
22
+ $sex = match[3]
23
+ $trivia = match[4].lstrip.rstrip.to_i
24
+ end
25
+ conf.remote_triggers[/^\| Dexterity : \[(.+)\/(.+)\] \| Level: (.+) \| Quest points : \[(.+)\] \|$/] = Proc.new do |inwin, outwin, match|
26
+ $dex_now = match[1].lstrip.to_i
27
+ $dex_max = match[2].rstrip.to_i
28
+ # If my level has changed, then reload
29
+ # TODO: Don't print this warning on startup..
30
+ if match[3].rstrip.to_i + ($tier * 10) != $level then pprint " # Warning: Your level has changed. Consider running /_reload" end
31
+ $level = match[3].rstrip.to_i + ($tier * 10)
32
+ $qps = match[4].lstrip.rstrip.to_i
33
+ end
34
+ conf.remote_triggers[/^\| Constitution : \[(.+)\/(.+)\] \| \| Quest time : \[(.+)\] \|$/] = Proc.new do |inwin, outwin, match|
35
+ $con_now = match[1].lstrip.to_i
36
+ $con_max = match[2].rstrip.to_i
37
+ # $qtimer is also learned through the prompt/bprompt:
38
+ $qtimer = match[3].lstrip.rstrip.to_i
39
+ end
40
+ conf.remote_triggers[/^\| Luck : \[(.+)\/(.+)\] \| \| \|$/] = Proc.new do |inwin, outwin, match|
41
+ $luc_now = match[1].lstrip.to_i
42
+ $luc_max = match[2].rstrip.to_i
43
+ end
44
+ conf.remote_triggers[/^\| Hit : \[(.+)\/(.+)\] \| Hitroll : \[(.+)\] \| Weight :(.+)of(.+)\|$/] = Proc.new do |inwin, outwin, match|
45
+ $hit_now = match[1].lstrip.to_i
46
+ $hit_max = match[2].rstrip.to_i
47
+ $hitroll = match[3].lstrip.rstrip.to_i
48
+ $weight_now = match[4].lstrip.rstrip.to_i
49
+ $weight_max = match[5].lstrip.rstrip.to_i
50
+ end
51
+ conf.remote_triggers[/^\| Mana : \[(.+)\/(.+)\] \| Damroll : \[(.+)\] \| Items :(.+)of(.+)\|$/] = Proc.new do |inwin, outwin, match|
52
+ $mana_now = match[1].lstrip.to_i
53
+ $mana_max = match[2].rstrip.to_i
54
+ $damroll = match[3].lstrip.rstrip.to_i
55
+ $items_now = match[4].lstrip.rstrip.to_i
56
+ $items_max = match[5].lstrip.rstrip.to_i
57
+ end
58
+ conf.remote_triggers[/^\| Moves : \[(.+)\/(.+)\] \| Wimpy : \[(.+)\] \| Pos : (.+)\|$/] = Proc.new do |inwin, outwin, match|
59
+ $mv_now = match[1].lstrip.to_i
60
+ $mv_max = match[2].rstrip.to_i
61
+ $wimpy = match[3].lstrip.rstrip.to_i
62
+ $position = match[4].lstrip.rstrip
63
+ if $position == "Sleeping" then $asleep = 1 end
64
+ if $position == "Standing" then $asleep = 0 end
65
+ end
66
+ conf.remote_triggers[/^\| Gold : \[(.+)\] \| Saves : \[(.+) \] \| Align : (.+)\s+(\w+)\s+\|$/] = Proc.new do |inwin, outwin, match|
67
+ $gold = match[1].lstrip.rstrip.to_i
68
+ $sv = match[2].rstrip.to_i
69
+ $align = match[3].lstrip.rstrip.to_i
70
+ $alignment = match[4].lstrip.rstrip
71
+ end
72
+ conf.remote_triggers[/^\| Exp : \[(.+)\] \| Age : \[(.+)\] \| Hunger :(.+)\/(.+)\((\w+)\)\s*\|$/] = Proc.new do |inwin, outwin, match|
73
+ $exp = match[1].lstrip.rstrip.to_i
74
+ $age = match[2].lstrip.rstrip.to_i
75
+ $hunger = match[3].lstrip.rstrip.to_i
76
+ $hunger_max = match[4].lstrip.rstrip.to_i
77
+ $hunger_status = match[5]
78
+ end
79
+ conf.remote_triggers[/^\| To Lvl : \[(.+) \] \| Hours : \[(.+)\] \| Thirst : (\d+)\s+\((\w+)\)\s+\|$/] = Proc.new do |inwin, outwin, match|
80
+ $tnl = match[1].lstrip.rstrip.to_i
81
+ $hours = match[2].lstrip.rstrip.to_i
82
+ $thirst = match[3].lstrip.rstrip.to_i
83
+ $thirst_status = match[4]
84
+ end
85
+ conf.remote_triggers[/^\| Pierce : (.+) \((.+)\) \[.+\]\|$/] = Proc.new do |inwin, outwin, match|
86
+ $ac_pierce = match[1].lstrip.rstrip.to_i
87
+ $ac_pierce_status = match[2].lstrip.rstrip
88
+ end
89
+ conf.remote_triggers[/^\| Bash : (.+) \((.+)\) \[.+\]\|$/] = Proc.new do |inwin, outwin, match|
90
+ $ac_bash = match[1].lstrip.rstrip.to_i
91
+ $ac_bash_status = match[2].lstrip.rstrip
92
+ end
93
+ conf.remote_triggers[/^\| Slash : (.+) \((.+)\) \[.+\]\|$/] = Proc.new do |inwin, outwin, match|
94
+ $ac_slash = match[1].lstrip.rstrip.to_i
95
+ $ac_slash_status = match[2].lstrip.rstrip
96
+ end
97
+ conf.remote_triggers[/^\| Exotic : (.+) \((.+)\) \[.+\]\|$/] = Proc.new do |inwin, outwin, match|
98
+ $ac_exotic = match[1].lstrip.rstrip.to_i
99
+ $ac_exotic_status = match[2].lstrip.rstrip
100
+ end
101
+
102
+
103
+
104
+ @tmp = 1
105
+ conf.remote_triggers[/^\+-------------------------------------------------------------------------\+$/] = Proc.new do
106
+ conf.gags << '.*'
107
+ # All of this should fire off on the bottom border of 'score':
108
+ if @tmp == 2 then
109
+ # pprint $str_now.inspect
110
+ # pprint $str_max.inspect
111
+ # pprint $race.inspect
112
+ # pprint $pracs.inspect
113
+ # pprint $int_now.inspect
114
+ # pprint $int_max.inspect
115
+ # pprint $class.inspect
116
+ # pprint $trains.inspect
117
+ # pprint $wis_now.inspect
118
+ # pprint $wis_max.inspect
119
+ # pprint $sex.inspect
120
+ # pprint $trivia.inspect
121
+ # pprint $dex_now.inspect
122
+ # pprint $dex_max.inspect
123
+ # pprint $level.inspect
124
+ # pprint $qps.inspect
125
+ # pprint $con_now.inspect
126
+ # pprint $con_max.inspect
127
+ # pprint $qtimer.inspect
128
+ # pprint $luc_now.inspect
129
+ # pprint $luc_max.inspect
130
+ # pprint $hit_now.inspect
131
+ # pprint $hit_max.inspect
132
+ # pprint $hitroll.inspect
133
+ # pprint $weight_now.inspect
134
+ # pprint $weight_max.inspect
135
+ # pprint $mana_now.inspect
136
+ # pprint $mana_max.inspect
137
+ # pprint $damroll.inspect
138
+ # pprint $items_now.inspect
139
+ # pprint $items_max.inspect
140
+ # pprint $mv_now.inspect
141
+ # pprint $mv_max.inspect
142
+ # pprint $wimpy.inspect
143
+ # pprint $position.inspect
144
+ # pprint $gold.inspect
145
+ # pprint $sv.inspect
146
+ # pprint $align.inspect
147
+ # pprint $alignment.inspect
148
+ # pprint $exp.inspect
149
+ # pprint $age.inspect
150
+ # pprint $hunger.inspect
151
+ # pprint $hunger_max.inspect
152
+ # pprint $hunger_status.inspect
153
+ # pprint $tnl.inspect
154
+ # pprint $hours.inspect
155
+ # pprint $thirst.inspect
156
+ # pprint $thirst_status.inspect
157
+ # pprint $ac_pierce.inspect
158
+ # pprint $ac_pierce_status.inspect
159
+ # pprint $ac_bash.inspect
160
+ # pprint $ac_bash_status.inspect
161
+ # pprint $ac_slash.inspect
162
+ # pprint $ac_slash_status.inspect
163
+ # pprint $ac_exotic.inspect
164
+ # pprint $ac_exotic_status.inspect
165
+
166
+ conf.remote_triggers.delete(/^\| Strength : \[(.+)\/(.+)\] \| Race : (.+)\| Practices : \[(.+)\] \|$/)
167
+ conf.remote_triggers.delete(/^\| Intelligence : \[(.+)\/(.+)\] \| Class: (.+)\| Trains : \[(.+)\] \|$/)
168
+ conf.remote_triggers.delete(/^\| Wisdom : \[(.+)\/(.+)\] \| Sex : (Male|Female).+\| Trivia : \[(.+)\] \|$/)
169
+ conf.remote_triggers.delete(/^\| Dexterity : \[(.+)\/(.+)\] \| Level: (.+) \| Quest points : \[(.+)\] \|$/)
170
+ conf.remote_triggers.delete(/^\| Constitution : \[(.+)\/(.+)\] \| \| Quest time : \[(.+)\] \|$/)
171
+ conf.remote_triggers.delete(/^\| Luck : \[(.+)\/(.+)\] \| \| \|$/)
172
+ conf.remote_triggers.delete(/^\| Hit : \[(.+)\/(.+)\] \| Hitroll : \[(.+)\] \| Weight :(.+)of(.+)\|$/)
173
+ conf.remote_triggers.delete(/^\| Mana : \[(.+)\/(.+)\] \| Damroll : \[(.+)\] \| Items :(.+)of(.+)\|$/)
174
+ conf.remote_triggers.delete(/^\| Moves : \[(.+)\/(.+)\] \| Wimpy : \[(.+)\] \| Pos : (.+)\|$/)
175
+ conf.remote_triggers.delete(/^\| Gold : \[(.+)\] \| Saves : \[(.+) \] \| Align : (.+)\s+(\w+)\s+\|$/)
176
+ conf.remote_triggers.delete(/^\| Exp : \[(.+)\] \| Age : \[(.+)\] \| Hunger :(.+)\/(.+)\((\w+)\)\s*\|$/)
177
+ conf.remote_triggers.delete(/^\| To Lvl : \[(.+) \] \| Hours : \[(.+)\] \| Thirst : (\d+)\s+\((\w+)\)\s+\|$/)
178
+ conf.remote_triggers.delete(/^\| Pierce : (.+) \((.+)\) \[.+\]\|$/)
179
+ conf.remote_triggers.delete(/^\| Bash : (.+) \((.+)\) \[.+\]\|$/)
180
+ conf.remote_triggers.delete(/^\| Slash : (.+) \((.+)\) \[.+\]\|$/)
181
+ conf.remote_triggers.delete(/^\| Exotic : (.+) \((.+)\) \[.+\]\|$/)
182
+ conf.gags.delete('.*')
183
+ conf.remote_triggers.delete(/^\+-------------------------------------------------------------------------\+$/)
184
+ end
185
+ @tmp += 1
186
+ end
187
+
188
+ write "score"
189
+ false
190
+ end
191
+
@@ -0,0 +1,65 @@
1
+
2
+ # Put the prompts above and below the text area.
3
+ # TODO: What about double?
4
+ # TODO: List statuses, like afk/invis/regen.
5
+ # in combat, qmob, highlighting
6
+ # TODO: colour the directions: north = blue, east = green, south = red, west = yellow, up = white, down = grey
7
+ # TODO: colour the alignment, hp/mp/vp
8
+ # NOTE: The downside of all of this is that your scrollback buffer does not have the gags anymore.
9
+ # If all of this is too cpu-intensive, then it can be very easily simplified.
10
+ $spinner = "|"
11
+ $doublexp = 0
12
+ $leader_hp = 0
13
+ def update_statuses
14
+ # Affix the compasspoints in a specific place in the direction-field.
15
+ directions = " "
16
+ if $directions =~ /N/ then directions[0] = "N" end
17
+ if $directions =~ /E/ then directions[1] = "E" end
18
+ if $directions =~ /S/ then directions[2] = "S" end
19
+ if $directions =~ /W/ then directions[3] = "W" end
20
+ if $directions =~ /U/ then directions[4] = "U" end
21
+ if $directions =~ /D/ then directions[5] = "D" end
22
+ alignment = $alignment[0..0] # Just the first char.
23
+ align = (
24
+ " " * ( 5 - $align.to_s.size) + $align.to_s
25
+ )
26
+ tnl = " " * ( 4 - $tnl.to_s.size) + $tnl.to_s
27
+ qtimer = " " * ( 2 - $qtimer.to_s.size) + $qtimer.to_s
28
+ hp_now = " " * ($hp_max.size - $hp_now.size) + $hp_now.to_s
29
+ mp_now = " " * ($mp_max.size - $mp_now.size) + $mp_now.to_s
30
+ vp_now = " " * ($vp_max.size - $vp_now.size) + $vp_now.to_s
31
+ doublexp = (
32
+ if $doublexp > 0 then ">> Double: #{$doublexp} "
33
+ else ""
34
+ end
35
+ )
36
+ leader_hp = (
37
+ if $leader_hp > 0 then ">> Leader: #{$leader_hp} hp "
38
+ else ""
39
+ end
40
+ )
41
+ enemy_hp = (
42
+ if $enemy_hp > 0 then ">> Enemy: #{$enemy_hp}% "
43
+ else ""
44
+ end
45
+ )
46
+ $spinner = (
47
+ case $spinner
48
+ when "|" : "/"
49
+ when "\\" : "|"
50
+ when "-" : "\\"
51
+ when "/" : "-"
52
+ end
53
+ )
54
+
55
+ Muby::InputWindow.get_instance.set_status_line("#{$spinner}[#{directions}]#{align} (#{alignment}) / #{tnl}tnl / #{qtimer} quest / #{$tells} tells #{doublexp}")
56
+ Muby::InputWindow.get_instance.set_message_line(" #{hp_now} / #{$hp_max} hp, #{mp_now} / #{$mp_max}m, #{vp_now} / #{$vp_max}v #{leader_hp}#{enemy_hp}")
57
+ Muby::InputWindow.get_instance.update
58
+ # This guarantees that the prompt will never reappear:
59
+ if $gag_prompts == 0 then
60
+ gag_prompts 1
61
+ $gag_prompts += 1
62
+ else
63
+ $gag_prompts += 1
64
+ end
65
+ end
@@ -0,0 +1,156 @@
1
+ conf.local_triggers[/^afk(.*)/] = Proc.new do |inqin, outwin, match| afk match[1..-1] ; false end
2
+
3
+ def afk(string)
4
+ # Remove the space at the beginning of the string.
5
+ string = ensure_s(string)
6
+ case string
7
+ when "" then
8
+ # TODO: spit out a random tagline. =)
9
+ if $afk == 0 then
10
+ write "afk #{$afk_message}"
11
+ $afk = 1
12
+ else # $afk != 0
13
+ # go unafk
14
+ write "afk"
15
+ end
16
+ when "0", 0 then
17
+ if $afk == 1 then write "afk" end
18
+ $afk = 0
19
+ when "1", 1 then
20
+ if $afk == 0 then write "afk" end
21
+ $afk = 1
22
+ # # IDEA: This can be enhanced to have shortcuts like this:
23
+ # when "sleeping" then
24
+ # if $afk == 1 then write "afk" end
25
+ # write "afk I am sleeping.."
26
+ # $afk = 1
27
+ else
28
+ # If already in afk, then exit afk mode to be able to change the message cleanly
29
+ if $afk == 1 then write "afk" end
30
+ # Toggle AFK mode. This will either go afk with an optional message, or go unafk.
31
+ write "afk #{string}"
32
+ # toggle afk:
33
+ if $afk == 1 then $afk = 0 else $afk = 1 end
34
+ end
35
+ end
36
+
37
+
38
+
39
+ #
40
+ # autotick
41
+ #
42
+ # Auto-heal:
43
+ conf.remote_triggers[/^You will be informed when the mud 'ticks'\.$/] = Proc.new do $autotick = 1 end
44
+ conf.remote_triggers[/^You will be not informed when the mud 'ticks'\.$/] = Proc.new do $autotick = 0 end
45
+ conf.remote_triggers[/^--> TICK <--$/] = Proc.new do
46
+ if $autotick == 0
47
+ then
48
+ $autotick = 1
49
+ autotick 0
50
+ end
51
+ end
52
+
53
+ conf.local_triggers[/^autotick (.*)\n$/m] = Proc.new do |inwin, outwin, match| autotick match[1] ; false end
54
+
55
+ def autotick(c)
56
+ c = ensure_c(c)
57
+ case c
58
+ when "0", 0 then
59
+ if $autotick == 1
60
+ write "autotick"
61
+ end
62
+ $autotick = 0
63
+ when "1", 1 then
64
+ if $autotick == 0
65
+ write "autotick"
66
+ end
67
+ $autotick = 1
68
+ else
69
+ pprint "parameters other than 0 or 1 simply toggle the state"
70
+ if c == "1" or c == 1 then
71
+ autotick 0
72
+ else
73
+ autotick 1
74
+ end
75
+ end
76
+ end
77
+
78
+
79
+ #
80
+ # Sleep modification, to regenerate faster.
81
+ #
82
+ # Remember that 'sleep' is a Ruby command to pause for a certain length of time.
83
+ # it might be cool to automatically go invisible when I go to sleep, but then I'd have to take into account lfinger.
84
+ # add in: if no argument alongside this, then drop a bed if I have one.
85
+ # boots don't change regeneration rate anymore. haste/lightspeed probably don't either.
86
+ # TODO: make a sleep alias that will set $asleep, maybe modify the prompt. Maybe remove the "You go to sleep." comment the mud sends.
87
+ # deal with being woken up because of a fight? because of poison?
88
+ def wake ; asleep 0 ; false end
89
+ conf.remote_triggers[/^You go to sleep\.$/] = Proc.new do $asleep = 1 end
90
+ conf.remote_triggers[/^You go to sleep on .*\.$/] = Proc.new do $asleep = 1 end
91
+ conf.remote_triggers[/^You cannot sleep on .*\.$/] = Proc.new do $asleep = 1 ; wake end
92
+ conf.remote_triggers[/^You wake and stand up\.$/] = Proc.new do $asleep = 0 end
93
+ # Furniture
94
+ conf.remote_triggers[/^You wake up from .* and stand up\.$/] = Proc.new do $asleep = 0 end
95
+ conf.remote_triggers[/^You are already standing\.$/] = Proc.new do $asleep = 0 end
96
+
97
+ conf.local_triggers[/^sleep(.*)$/] = Proc.new do |inwin, outwin, match| asleep match[1..-1] ; false end
98
+ conf.local_triggers[/^wake$|^stand$/] = :wake
99
+
100
+ def _sleep_prep
101
+ autotick 1
102
+ end
103
+ def _sleep_wake
104
+ invis 0
105
+ autotick 0
106
+ end
107
+
108
+ def asleep(string)
109
+ string = ensure_s(string)
110
+ if $afk == 1 then afk 0 end
111
+
112
+ case string
113
+ when "0", 0
114
+ if $asleep == 1 then
115
+ if $furniture == "" then
116
+ write "wake"
117
+ else
118
+ write "wake;get #{$furniture};put #{$furniture} #{$bag}"
119
+ end
120
+ _sleep_wake
121
+ else
122
+ # pprint "already awake"
123
+ # p
124
+ end
125
+ $asleep = 0
126
+ when "1", 1
127
+ if $asleep == 0 then
128
+ _sleep_prep
129
+ if $furniture != "" then
130
+ write "get #{$furniture} #{$bag};drop #{$furniture};sleep #{$furniture}"
131
+ else
132
+ write "sleep"
133
+ end
134
+ $asleep = 1
135
+ else
136
+ # pprint "already sleeping"
137
+ # p
138
+ end
139
+ else
140
+ if $asleep == 0 then
141
+ if string != "" then
142
+ _sleep_prep
143
+ # if a parameter other than 0 or 1 is passed, try to sleep on that object:
144
+ write "sleep #{string}"
145
+ # Set this, because the auto-heal cannot catch sleep failure.
146
+ $asleep = 1
147
+ else
148
+ # if no parameter is passed, just sleep:
149
+ asleep 1
150
+ end
151
+ else
152
+ # pprint "already sleeping"
153
+ # p
154
+ end
155
+ end
156
+ end