forked from tdk1069/Mudlet-Stuff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapper.xml
265 lines (247 loc) · 7.07 KB
/
Mapper.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MudletPackage>
<MudletPackage version="1.001">
<ScriptPackage>
<Script isActive="yes" isFolder="no">
<name>EleMapper</name>
<packageName></packageName>
<script>-------------------------------------------------
-- Put your Lua functions here. --
-- --
-- Note that you can also use external Scripts --
-------------------------------------------------
mudlet = mudlet or {}; mudlet.mapper_script = true
--EleMap = Geyser.Mapper:new({
-- name = "EleMap",
-- x = "70%", y = 0,
-- width = "30%",
-- height = "50%",
--})
eleMap = eleMap or {}
-- Start a new Map if nothing found/loaded
function count_rooms()
local count = 0
for dir, id in pairs(getRooms()) do
count = count +1
end
cecho("<cyan>[ MAP ]<reset> Total Rooms: "..count.."\n")
end
function add_room_neighbours(roomId,exits)
local x,y,z = getRoomCoordinates(gmcp.Room.Id)
for dir, id in pairs(exits) do
local newx,newy,newz = calculate_Coordinates(x,y,z,dir)
if not roomExists(id) then
addRoom(id)
setRoomCoordinates(id,newx,newy,newz)
setRoomArea(id,getRoomArea(roomId))
end
if not getRoomExits(roomId)[dir] then
if is_standard_exit(dir) then
setExit(roomId,id,dir)
setExit(id,roomId,reversemap[dir])
else
addSpecialExit(roomId,id,dir)
end
cecho("<cyan>[ MAP ]<reset> Adding ["..dir.."] => "..id.."\n")
end
updateMap()
end
end
function is_standard_exit(dir)
if dir == "north" then
return true
elseif dir == "northeast" then
return true
elseif dir == "east" then
return true
elseif dir == "southeast" then
return true
elseif dir == "south" then
return true
elseif dir == "southwest" then
return true
elseif dir == "west" then
return true
elseif dir == "northwest" then
return true
elseif dir == "up" then
return true
elseif dir == "down" then
return true
elseif dir == "in" then
return true
elseif dir == "out" then
return true
else
return false
end
end
function calculate_Coordinates(x,y,z,dir)
if dir == "north" then
y = y + 2
elseif dir == "northeast" then
x = x + 2
y = y + 2
elseif dir == "east" then
x = x + 2
elseif dir == "southeast" then
x = x + 2
y = y - 2
elseif dir == "south" then
y = y - 2
elseif dir == "southwest" then
x = x - 2
y = y - 2
elseif dir == "west" then
x = x - 2
elseif dir == "northwest" then
x = x - 2
y = y + 2
elseif dir == "up" then
z = z + 2
elseif dir == "down" then
z = z - 2
else
x = x + 1
y = y + 1
end
return x,y,z
end
function find_room()
--print(string.sub(gmcp.Room.Id, 1, 3))
eleMap.lastRoom = eleMap.currentRoom or gmcp.Room.Id
eleMap.lastX,eleMap.lastY,eleMap.lastZ = getRoomCoordinates(eleMap.lastRoom) or {}
eleMap.currentRoom = gmcp.Room.Id
if roomExists(eleMap.currentRoom) then
centerview(eleMap.currentRoom)
-- getRoomName = tempRegexTrigger("(.+)", [[setRoomName(eleMap.currentRoom,matches[1]);killTrigger(getRoomName)]])
<<<<<<< HEAD
-- getRoomName = tempColorTrigger(0,0, [[setRoomName(eleMap.currentRoom,matches[1]);killTrigger(getRoomName)]])
=======
getRoomName = tempColorTrigger(0,0, [[setRoomName(eleMap.currentRoom,matches[1]);killTrigger(getRoomName)]])
>>>>>>> 4910826effcda4202c12862ea2d6b64b7627274d
else
cecho("<cyan>[ MAP ]<reset> No Room found for <red>"..gmcp.Room.Id.."<reset>\n")
end
end
function add_exits()
if roomExists(eleMap.currentRoom) then
add_room_neighbours(gmcp.Room.Id,gmcp.Room.Exits)
else
find_link(gmcp.Room.Exits)
end
end
function find_link(exits)
for dir, id in pairs(exits) do
if roomExists(id) then
cecho("<cyan>[ MAP ]<reset> Found adjoining room =><red>"..id.."<reset> "..exitmap[reversemap[dir]].."\n")
local x,y,z = getRoomCoordinates(id)
local newx,newy,newz = calculate_Coordinates(x,y,z,exitmap[reversemap[dir]])
add_room(eleMap.currentRoom,newx,newy,newz,getRoomArea(eleMap.lastRoom))
break
end
end
if not roomExists(gmcp.Room.Id) then
local x,y,z = getRoomCoordinates(eleMap.lastRoom)
add_room(eleMap.currentRoom,x,y,z,getRoomArea(eleMap.lastRoom))
cecho("<cyan>[ MAP ]<reset> I didn't know where to put this room! ["..gmcp.Room.Id.."] please move it manually (New Zone?)\n")
end
end
function add_room(id,x,y,z,area)
addRoom(id)
setRoomCoordinates(id,x,y,z)
setRoomArea(id,area)
centerview(id)
add_room_neighbours(id,gmcp.Room.Exits)
end
function purge_map()
for id, room in pairs(getRooms()) do
deleteRoom(id)
print("<cyan>[ MAP ]<reset> Deleting => "..id.."\n")
end
end
reversemap = {
n = 6,
north = 6,
ne = 8,
northeast = 8,
nw = 7,
northwest = 7,
e = 5,
east = 5,
w = 4,
west = 4,
s = 1,
south = 1,
se = 3,
southeast = 3,
sw = 2,
southwest = 2,
u = 10,
up = 10,
d = 9,
down = 9,
["in"] = 12,
out = 11}
exitmap = {
n = 1,
north = 1,
ne = 2,
northeast = 2,
nw = 3,
northwest = 3,
e = 4,
east = 4,
w = 5,
west = 5,
s = 6,
south = 6,
se = 7,
southeast = 7,
sw = 8,
southwest = 8,
u = 9,
up = 9,
d = 10,
down = 10,
["in"] = 11,
out = 12,
[1] = "north",
[2] = "northeast",
[3] = "northwest",
[4] = "east",
[5] = "west",
[6] = "south",
[7] = "southeast",
[8] = "southwest",
[9] = "up",
[10] = "down",
[11] = "in",
[12] = "out",
}
function mapper_Installed()
cecho("<cyan>[ MAP ]<reset> EleMap Installed\n")
if next(getRooms()) == nil then
cecho("<cyan>[ MAP ]<reset> NEW MAP STARTED\n")
cecho("<cyan<[ MAP ]<reset> Adding first room "..gmcp.Room.Id.."\n")
setAreaName(1,"Elephant")
addRoom(gmcp.Room.Id)
setRoomCoordinates(gmcp.Room.Id,0,0,0)
setRoomArea(gmcp.Room.Id,1)
centerview(gmcp.Room.Id)
add_room_neighbours(gmcp.Room.Id,gmcp.Room.Exits)
updateMap()
end
end
function doSpeedWalk()
-- we can do a lot here, this fires when a room is double clicked on, and is intended to speedwalk to it
print("Path to " .. getRoomName(speedWalkPath[#speedWalkPath]) .. ": " .. table.concat(speedWalkDir, ", "))
end
registerAnonymousEventHandler("gmcp.Room.Id", "find_room")
registerAnonymousEventHandler("gmcp.Room.Exits", "add_exits")
registerAnonymousEventHandler("sysInstall", "mapper_Installed")
</script>
<eventHandlerList/>
</Script>
</ScriptPackage>
</MudletPackage>