-
Notifications
You must be signed in to change notification settings - Fork 3
/
expandedview.lic
165 lines (132 loc) · 6.17 KB
/
expandedview.lic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
85
86
87
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
=begin
When looking in/on/under/behind containers, shows the full name of items rather than the shortened one.
Instead of: In the backpack you see an opalescent glass jar, an opalescent glass jar, ...
You will see: In the backpack you see an opalescent glass jar containing selanthian bloodjewels, ...
This may not work for all containers and is only usable (and only needed) if FLAG SORTEDVIEW is OFF.
author: LostRanger ([email protected])
game: Gemstone
tags: utility
required: Lich >= 4.6.0.
version: 0.3 (2019-07-02)
changelog:
version 0.3 (2019-07-02)
* Fix double articles.
version 0.2 (2019-07-02)
* Fix broken LOOKs in containers with items that do not have an article outside of the link.
version 0.1 (2019-07-02)
* Initial release
=end
module ExpandedView
VERSION = '0.3 (2019-07-02)'
VERSION_INT = 300000
HOOK_NAME = 'ExpandedViewHook'
# Matches the entire 'look in' pattern.
# 1=unchanged prefix/inv tags 2=location 3=look in results.
BASE_PATTERN = /(<clearContainer[^>]+><inv.*<\/inv>(\w+) the .*? you see )(.*)(\.s*)/
# Matches a single <inv> tag
# 1=specifies location 2=specifies item 3=exist id
INV_PATTERN = /<inv[^>]+>(?:(\w+).*?| (.*?<a exist="(\d+)".*?))<\/inv>/
# Matches a single item in the 'look in ' portion.
ITEM_PATTERN = /(?:(?:an |a |some |the ).*?)?<a exist="(\d+)"[^>]+>.*?<\/a>/
def self.send(what)
if $frontend != 'wizard'
return _respond(what)
end
unless what.is_a?(Array)
what = [what]
end
return _respond what.map{|line|
if line =~ /^\s*<\/?output[^>]*>$/
nil
else
line = line.gsub(/<preset.*?>(.*?)<\/preset>/, "\\1")
line.gsub!('<pushBold/>', monsterbold_start)
line.gsub!('<popBold/>', monsterbold_end)
line.gsub!(/<\/?d.*?>/, '')
line
end
}.keep_if{|x| x}
end
def self.show_changelog(prev)
prev ||= 0
GameSetting[:current_version] = VERSION_INT
# FIXME when a new version comes out.
changelog = {
300000 => [
"Version 0.3 changes:",
'',
" * Fix double articles.",
],
200000 => [
"Version 0.2 changes:",
'',
" * Fix broken LOOKs in containers with items that do not have an article outside of the link.",
],
}
if prev != VERSION_INT
msg = []
msg << "<preset id='speech'>--------------------</preset>"
msg << "<preset id='speech'>Welcome to #{$lich_char}#{@script.name}</preset> <preset id='whisper'>#{VERSION}</preset>"
msg << ''
changelog.each do |version, notes|
if version > prev or version == VERSION_INT
msg += notes
msg << ''
end
end
msg << "For a more detailed changelog: <d>#{$lich_char}repo info #{@script.name}</d>."
msg << "To enable automatic updates: <d>#{$lich_char}repo set-updatable #{@script.name}</d>`."
msg << "For details on new features: <d>#{$lich_char}#{@script.name} help</d>"
msg << "For more LostRanger scripts: https://bit.ly/lostranger-scripts"
msg << ''
msg << "This message will not be displayed again until a new version is downloaded."
msg << "<preset id='speech'>--------------------</preset>"
send msg
end
end
def self.cleanup
DownstreamHook.remove(HOOK_NAME)
end
def self.hook
before_dying { self.cleanup }
DownstreamHook.add(HOOK_NAME, proc {|xml|
xml.gsub(BASE_PATTERN){
prefix = $1
target_location = $2.downcase
items_xml = $3
suffix = $4
# FIXME: Does it make more sense to just capture *everything* rather than a specific location?
item_map = {}
capture = false
prefix.scan(INV_PATTERN){|loc, text, exist|
if loc
capture = (loc.downcase == target_location)
next
end
next unless capture
item_map[exist] = text
}
items_xml.gsub!(ITEM_PATTERN){|match| item_map[$1] or match}
"#{prefix}#{items_xml}#{suffix}"
}
})
if DownstreamHook.list.include?("inventory_boxes_off")
# Hackery to move the hook to the end of the list.
do_client("set inv on")
do_client("set inv off")
end
end
def self.run(script)
@script = script
script.want_downstream = false
hook
show_changelog(GameSetting[:current_version])
sleep
end
end
ExpandedView.run(script)
=begin
<resource picture="0"/><style id="roomName" />[<a exist="-10622535" noun="Meggiemae">Meggiemae</a>'s Home]
<style id=""/><style id="roomDesc"/>Walls of rough-hewn oak and a <a exist="3636382" noun="floor">dusty oak floor</a> covered by a <a exist="3636383" noun="rug">tasseled cotton rug</a> enclose this small room. In one corner lies a <a exist="3636389" noun="bed">polished oak four-poster bed</a>, and near the <a exist="3636389" noun="bed">bed</a> sits a <a exist="3636387" noun="table">sturdy oak table</a>. Above an <a exist="3636381" noun="fireplace">oak-mantled sandstone fireplace</a> hangs an <a exist="3636386" noun="plaque">Estate Holder plaque</a>. The room holds a mild scent of earthy loam.<compass></compass><style id=""/> You also see <pushBold/>a <a exist="3694975" noun="spirit">fluctuant spring spirit</a><popBold/>, <pushBold/>a <a exist="2185071" noun="snowcat">peak snowcat</a><popBold/>, the <a exist="3580220" noun="disk">Meggiemae disk</a>, the <a exist="2565920" noun="disk">Gylmour disk</a> and an <a exist="3636388" noun="door">iron-bound driftwood door</a>.
Also here: <a exist="-10622535" noun="Meggiemae">Meggiemae</a>, <a exist="-11140922" noun="Gylmour">Gylmour</a>.
=end