-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathConvertShopPrices.xml
180 lines (159 loc) · 5.16 KB
/
ConvertShopPrices.xml
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, February 22, 2019, 1:13 AM -->
<!-- MuClient version 5.04 -->
<!-- Plugin "ConvertShopPrices" generated by Plugin Wizard -->
<muclient>
<plugin
name="ConvertShopPrices"
author="Ruhsbaar"
id="a3d0068ddae76a2c1e113ffc"
language="Lua"
purpose="Convert shop prices to $A"
save_state="y"
date_written="2019-02-22 01:12:18"
requires="5.04"
version="1.0"
>
</plugin>
<!-- Get our standard constants -->
<include name="constants.lua"/>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
match="^ (\w{1,2}): (.*) for (.*) \(([\w-]+) left\)\.$"
regexp="y"
omit_from_output="y"
send_to="12"
sequence="100"
name="convertshopprice"
>
<send>
-- ###############################
-- #### Configuration ####
-- ###############################
-- # Set price and colours here ##
-- ###############################
price_high = 100.00
price_medium = 50.00
price_color_high = "babyblue"
price_color_medium = "yellow"
-- ###############################
-- #### DONT CHANGE PAST HERE ####
-- ###############################
function w2am(data)
return string.format("%.2f", (data / 400))
end
function parse_price(data)
local total = 0
-- Determine what kind of currency we're dealing with
if string.find(data, 'L') ~= nil then
-- Lancre
if string.find(data, 'Lp') then
local pe = string.match(data, 'Lp (%d+)') * 12
total = w2am(pe)
elseif string.find(data, 'Ls') then
local sh,pe = string.match(data, 'Ls (%d+)|(%d+)')
total = w2am((sh * 144)+(pe * 12))
elseif string.find(data, 'LC') then
local cr,sh,pe = string.match(data, 'LC (%d+)|([%d-]+)|([%d-]+)')
sh = tonumber(sh) or 0
pe = tonumber(pe) or 0
total = w2am((cr * 1728)+(sh * 144)+(pe * 12))
elseif string.find(data, 'LSov') then
local so,cr,sh,pe = string.match(data, 'LSov (%d+)|([%d-]+)|([%d-]+)|([%d-]+)')
print(so, cr, sh, pe)
cr = tonumber(cr) or 0
sh = tonumber(sh) or 0
pe = tonumber(pe) or 0
total = w2am((so * 20736)+(cr * 1728)+(sh * 144)+(pe * 12))
elseif string.find(data, 'LH') then
local he,so,cr,sh,pe = string.match(data, 'LH (%d)|([%d-])|([%d-])|([%d-])|([%d-])')
so = tonumber(so) or 0 -- deal with "-"
cr = tonumber(cr) or 0
sh = tonumber(sh) or 0
pe = tonumber(pe) or 0
total = w2am((he * 248832)+(so * 20736)+(cr * 1728)+(sh * 144)+(pe * 12))
end
elseif string.find(data, 'G') ~= nil then
-- Genua
if string.find(data, 'Gl') then
local li,ce = string.match(data, "(%d+),(%d+)Gl")
li = tonumber(li) or 0
ce = tonumber(ce) or 0
total = w2am((li * 300)+(ce * 3))
elseif string.find(data, 'Gf') then
local fo,li,ce = string.match(data, "(%d+),(%d+),(%d+)Gf")
total = w2am((fo * 3000)+(li * 300)+(ce * 3))
elseif string.find(data, 'Gd') then
local du,fo,li,ce = string.match(data, "(%d+),(%d+),(%d+),(%d+)Gd")
fo = tonumber(fo) or 0
li = tonumber(li) or 0
ce = tonumber(ce) or 0
total = w2am((du * 30000)+(fo * 3000)+(li * 300)+(ce * 3))
elseif string.find(data, 'Gc') then
local ce = string.match(data, "(%d+)Gc")
ce = tonumber(ce) or 0
total = w2am(ce * 3)
end
elseif string.find(data, 'de') ~= nil or string.find(data, 'S') ~= nil or string.find(data, 'M') ~= nil then
-- Ephebe
local de = (string.match(data, "(%d+)de") or 0) * 2
local s = (string.match(data, "S(%d+)") or 0) * 192
local m = (string.match(data, "(%d+)M") or 0) * 9600
total = w2am(m+s+de)
elseif string.find(data, 'DjToon') ~= nil then
-- Djelibeybi
local pt = (string.match(data, "DjToon %d+%.(%d+)") or 0) * 2
local tn = (string.match(data, "DjToon (%d+)%.%d+") or 0) * 200
total = w2am(pt+tn)
elseif string.find(data, 's') ~= nil or string.find(data, 'Rh') ~= nil then
-- Bes Pelargic
local sr = (string.match(data, "(%d+)s") or 0) * 4
local rh = (string.match(data, "(%d+)Rh") or 0) * 480
total = w2am(sr+rh)
end
return total
end
local amc = parse_price("%3")
if amc ~= 0 then
if tonumber(amc) > price_high then
ColourNote("white", "", " %1: %2 for %3 (%4 left). [", price_color_high, "", "A$" .. amc, "white", "", "]")
elseif tonumber(amc) > price_medium then
ColourNote("white", "", " %1: %2 for %3 (%4 left). [", price_color_medium, "", "A$" .. amc, "white", "", "]")
else
ColourNote("white", "", " %1: %2 for %3 (%4 left). [A$" .. parse_price("%3") .. "]")
end
else
ColourNote("white", "", " %1: %2 for %3 (%4 left).")
end
</send>
</trigger>
</triggers>
<!-- Aliases -->
<aliases>
<alias
match="convertprices on"
enabled="y"
send_to="12"
sequence="100"
>
<send>EnableTrigger("convertshopprice", true)
Note("Will now display converted shop prices.")</send>
</alias>
<alias
match="convertprices off"
enabled="y"
send_to="12"
sequence="100"
>
<send>EnableTrigger("convertshopprice", false)
Note("Will no longer show converted prices.")</send>
</alias>
</aliases>
<!-- Variables -->
<variables>
<variable name="ConvertShopPrices">1</variable>
</variables>
</muclient>