-
Notifications
You must be signed in to change notification settings - Fork 0
/
raw-svo.priestreport.lua
96 lines (79 loc) · 3.36 KB
/
raw-svo.priestreport.lua
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
-- Svof (c) 2011-2015 by Vadim Peretokin
-- Svof is licensed under a
-- Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
-- You should have received a copy of the license along with this
-- work. If not, see <http://creativecommons.org/licenses/by-nc-sa/4.0/>.
-- initialise to something so there's a value
local oldroom = ""
conf.reportdelay = 2
conf.bettertrace = true
local function announce_between_two_rooms(roomname1, roomname2)
-- get the area the room the person ended up in, if possible
local exactarealastroom
if mmp.getexactarea then
exactarealastroom = mmp.getexactarea(roomname2)
if exactarealastroom then exactarealastroom = mmp.cleanAreaName(exactarealastroom) end
end
-- if moved between just two rooms: get lists of IDs for both of them
local rid1, rid2 = mmp.searchRoomExact(roomname1), mmp.searchRoomExact(roomname2)
-- if we have more than one ID for either - just announce where we ended up
if not (table.size(rid1) == 1 and table.size(rid2) == 1) then
cc("%s moved one room to %s%s", tracing, roomname2, (exactarealastroom and " in "..exactarealastroom))
-- if exactly one ID for start and end, then work out the directory
else
rid1 = next(rid1)
rid2 = next(rid2)
local found
for exit, roomid in pairs(getRoomExits(rid1)) do
if roomid == rid2 then
cc("%s moved %s to %s%s", tracing, exit, roomname2, (exactarealastroom and " in "..exactarealastroom)); found = true; break
end
end
if not found then cc("%s moved one room to %s%s", tracing, roomname2, (exactarealastroom and " in "..exactarealastroom)) end
end
end
trace = function()
recently_announced = nil
if rooms_to_announce and #rooms_to_announce == 2 then
announce_between_two_rooms(rooms_to_announce[1], rooms_to_announce[2])
-- if they've moved a bunch of rooms
elseif rooms_to_announce and #rooms_to_announce > 2 then
-- get the area the room the person ended up in, if possible
local exactarealastroom
if mmp.getexactarea then
exactarealastroom = mmp.getexactarea(rooms_to_announce[#rooms_to_announce])
if exactarealastroom then exactarealastroom = mmp.cleanAreaName(exactarealastroom) end
end
cc("%s moved %d room%s to %s%s", tracing, #rooms_to_announce-1, (rooms_to_announce == 2 and "" or "s"), rooms_to_announce[#rooms_to_announce], (exactarealastroom and " in "..exactarealastroom))
-- else just one room in the table - then it is the same room, so ignore
end
rooms_to_announce = nil
end
function angel_trace(name, newroom)
if defc.dragonform then return end
if not (tracing and name == tracing) then return end
local exactarea
if mmp.getexactarea then exactarea = mmp.getexactarea(newroom) end
local function oldannounce()
if exactarea then
cc("%s entered %s in %s", name, newroom, mmp.cleanAreaName(exactarea))
else
cc("%s entered %s", name, newroom)
end
end
if not conf.bettertrace then
oldannounce()
else
if not recently_announced then
announce_between_two_rooms(oldroom, newroom)
-- keep track for slow movement
oldroom = newroom
-- separately keep track for speedwalking
rooms_to_announce = { newroom }
recently_announced = tempTimer(conf.reportdelay, trace)
else
rooms_to_announce = rooms_to_announce or {}
rooms_to_announce[#rooms_to_announce+1] = newroom
end
end
end