-
Notifications
You must be signed in to change notification settings - Fork 16
/
Materia_Magica_Mapper.xml
1603 lines (1240 loc) · 39.7 KB
/
Materia_Magica_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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient [
<!ENTITY show_vnums "true" >
<!ENTITY show_timing "false" >
<!ENTITY show_completed "false" >
<!ENTITY show_database_mods "true" >
<!ENTITY show_other_areas "false" >
<!ENTITY show_area_exits "false" >
<!ENTITY show_up_down "true" >
<!ENTITY speedwalk_prefix "" >
]>
<muclient>
<plugin
name="Materia_Magica_Mapper"
author="Nick Gammon"
id="1c17ac2c83b2b66c402c80c6"
language="Lua"
purpose="Mapper for Materia Magica"
save_state="y"
date_written="2010-10-12"
date_modified="2010-10-18 07:05"
requires="4.61"
version="1.5"
>
<description trim="y">
<![CDATA[
AUTOMATIC MAPPER ... by Nick Gammon
The window can be dragged to a new location by dragging the room name.
Your current room is always in the center with a bolder border.
LH-click on a room to speed-walk to it. RH-click on a room for options.
LH-click on the "*" button on the bottom-left corner to configure it.
** WHY DOES THE MAP CHANGE? **
The mapper draws from your room outwards - that is, it draws your room's exits
first, then the rooms leading from those rooms, and so on.
Eventually it finds an overlap, and draws a short "stub" line to indicate there
is a room there which there isn't space to draw. If you get closer to that
room the stub will disappear and the room(s) in question will be drawn.
ACTIONS
mapper help --> this help (or click the "?" button on the bottom right)
mapper zoom out --> zoom out
mapper zoom in --> zoom in
mapper hide --> hide map
mapper show --> show map
FINDING THINGS
mapper bookmarks --> show nearby rooms that you bookmarked
mapper find <text> --> full-text search (eg. shop OR baker)
mapper shop --> show nearby shops/banks etc.
mapper train --> show nearby trainers
mapper where <room> --> show directions to a room
MOVING
mapper goto <room> --> walk to a room by its room number (partial)
mapper stop --> cancel any current speedwalk
mapper resume --> resume last speedwalk or hyperlinked speedwalk
]]>
</description>
</plugin>
<!-- Triggers -->
<triggers>
<trigger
back_colour="8"
bold="y"
enabled="y"
match="[Shop] *"
match_back_colour="y"
match_bold="y"
match_inverse="y"
match_italic="y"
match_text_colour="y"
name="Shop_Line"
script="Shop_Line"
sequence="200"
text_colour="11"
>
</trigger>
<trigger
back_colour="8"
bold="y"
enabled="y"
match="[Train] *"
match_back_colour="y"
match_bold="y"
match_inverse="y"
match_italic="y"
match_text_colour="y"
name="Train_Line"
script="Train_Line"
sequence="200"
text_colour="11"
>
</trigger>
<trigger
back_colour="8"
bold="y"
enabled="y"
match="*"
match_back_colour="y"
match_bold="y"
match_inverse="y"
match_italic="y"
match_text_colour="y"
name="Name_Line"
script="Name_Line"
sequence="100"
text_colour="11"
keep_evaluating="y"
>
</trigger>
<trigger
back_colour="8"
bold="y"
enabled="n"
match="(-------------------------------------------------)*"
match_back_colour="y"
match_bold="y"
match_inverse="y"
match_italic="y"
match_text_colour="y"
name="Hyphen_Line"
script="Hyphen_Line"
sequence="100"
text_colour="12"
>
</trigger>
<trigger
back_colour="8"
enabled="n"
match="*"
match_back_colour="y"
match_bold="y"
match_inverse="y"
match_italic="y"
match_text_colour="y"
name="Map_Line"
script="Map_Line"
sequence="100"
text_colour="15"
>
</trigger>
<trigger
enabled="n"
match="*"
name="Other_Line"
script="Other_Line"
sequence="110"
keep_evaluating="y"
>
</trigger>
<trigger
enabled="n"
match=" Visible Exits: *"
name="Exits_Line"
script="Exits_Line"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="^The (door|gate) is closed\.$"
regexp="y"
name="Door_Closed"
script="Door_Closed"
sequence="100"
>
</trigger>
<!-- various messages that cancel speedwalks -->
<trigger
enabled="y"
match="You are too exhausted. Better rest for a bit."
regexp="y"
script="mapper.cancel_speedwalk"
sequence="100"
>
</trigger>
</triggers>
<aliases>
<!-- zooming aliases -->
<alias
match="mapper zoom out"
enabled="y"
sequence="100"
omit_from_command_history="y"
omit_from_output="y"
script="mapper.zoom_out"
>
</alias>
<alias
match="mapper zoom in"
enabled="y"
sequence="100"
omit_from_command_history="y"
omit_from_output="y"
script="mapper.zoom_in"
>
</alias>
<alias
match="mapper goto *"
enabled="y"
sequence="100"
script="map_goto"
>
</alias>
<!-- finding aliases -->
<alias
match="^mapper find ([\w* %d/"]+)$"
enabled="y"
sequence="100"
script="map_find"
regexp="y"
>
</alias>
<alias
match="^mapper book\w*$"
regexp="y"
enabled="y"
sequence="100"
script="map_bookmarks"
>
</alias>
<alias
match="mapper where *"
enabled="y"
sequence="100"
script="map_where"
>
</alias>
<alias
match="^mapper shops?$"
regexp="y"
enabled="y"
sequence="100"
script="map_shops"
>
</alias>
<alias
match="^mapper train\w*$"
regexp="y"
enabled="y"
sequence="100"
script="map_trainers"
>
</alias>
<alias
match="mapper resume"
enabled="y"
sequence="100"
script="map_resume"
>
</alias>
<alias
script="OnHelp"
match="mapper help"
enabled="y"
>
</alias>
<!-- cancel speedwalking -->
<alias
match="mapper stop"
enabled="y"
sequence="100"
script="mapper.cancel_speedwalk"
>
</alias>
<!-- show/hide mapper -->
<alias
match="mapper hide"
enabled="y"
sequence="100"
script="mapper.hide"
>
</alias>
<alias
match="mapper show"
enabled="y"
sequence="100"
script="mapper.show"
>
</alias>
</aliases>
<!-- Script -->
<script>
local show_vnums = &show_vnums;
local show_timing = &show_timing;
local show_completed = &show_completed;
local show_database_mods = &show_database_mods;
local show_other_areas = &show_other_areas;
local show_up_down = &show_up_down;
local show_area_exits = &show_area_exits;
local speedwalk_prefix = "&speedwalk_prefix;"
<![CDATA[
require "mapper"
require "serialize"
require "copytable"
rooms = {}
areas = {}
valid_direction = {
n = "n",
s = "s",
e = "e",
w = "w",
u = "u",
d = "d",
ne = "ne",
sw = "sw",
nw = "nw",
se = "se",
north = "n",
south = "s",
east = "e",
west = "w",
up = "u",
down = "d",
northeast = "ne",
northwest = "nw",
southeast = "se",
southwest = "sw",
['in'] = "in",
out = "out",
} -- end of valid_direction
-- -----------------------------------------------------------------
-- 1. Here on yellow line - room name
-- -----------------------------------------------------------------
function Name_Line (name, line, wildcards, styles)
if string.match (line, "^%[") then
return
end -- if chat line
got_hyphens = false
roomname = Trim (styles [1].text:sub (1, 50))
roomdesc = ""
exits = {}
exits_str = ""
map_str = ""
got_exits = false
EnableTrigger ("Hyphen_Line", true)
EnableTrigger ("Other_Line", true)
EnableTrigger ("Name_Line", false)
end -- Name_Line
-- -----------------------------------------------------------------
-- 2. Here on: (-------------------------------------------------)
-- -----------------------------------------------------------------
function Hyphen_Line (name, line, wildcards)
got_hyphens = true
EnableTrigger ("Map_Line", true)
EnableTrigger ("Hyphen_Line", false)
EnableTrigger ("Other_Line", false)
end -- Hyphen_Line
-- -----------------------------------------------------------------
-- 3. Here on third line (rest of compass)
-- -----------------------------------------------------------------
function Map_Line (name, line, wildcards)
EnableTrigger ("Map_Line", false)
EnableTrigger ("Other_Line", true)
EnableTrigger ("Exits_Line", true)
end -- Map_Line
-- -----------------------------------------------------------------
-- 4. Here on exits line
-- -----------------------------------------------------------------
function Exits_Line (name, line, wildcards)
exits_str = string.gsub (wildcards [1]:lower (), "[()]", "")
EnableTrigger ("Exits_Line", false)
got_exits = true
end -- Exits_Line
-- -----------------------------------------------------------------
-- 5. Here on description, or line *after* the description
-- -----------------------------------------------------------------
function Other_Line (name, line, wildcards, styles)
EnableTrigger ("Exits_Line", false)
-- if totally spaces, (and no description yet) skip it
if #line == 0 or not string.match (line, "%S") then
if roomdesc == "" and map_str == "" then
return
end -- if
end -- if
-- see if a world map line
local char_count = 0
local letter_count = 0
for ch in string.gmatch (line, "[^A-HJ-Za-z]") do -- allow "I"
char_count = char_count + 1
end -- for
for ch in string.gmatch (line, "%a") do
letter_count = letter_count + 1
end -- for
-- if mainly dots and stuff, assume world map line
if char_count >= 12 and letter_count < char_count / 2 then
map_str = map_str .. line
return
end -- if
if #styles == 1 and map_str == "" then
if styles [1].textcolour == GetNormalColour (8) and
styles [1].backcolour == GetNormalColour (1) then
-- description lines do not start with spaces, except the first one
if roomdesc == "" or string.match (line, "^%S") then
roomdesc = roomdesc .. " " .. line
return
end -- if not start with spaces
end -- if right colours
end -- if a description line
-- ready for next time
EnableTrigger ("Other_Line", false)
EnableTrigger ("Name_Line", true)
if not got_hyphens then
return
end -- no hyphens line
-- generate a "room ID" by hashing the room name, description and exits
uid = utils.tohex (utils.md5 (roomname .. roomdesc .. exits_str .. map_str))
uid = uid:sub (1, 10) -- more manageable length
-- save so we know current room later on
current_room = uid
-- ColourNote ("rosybrown", "", roomdesc)
-- ColourNote ("olive", "", uid)
local room = rooms [current_room]
-- not cached - see if in database
if not room then
-- print ("Loading room", current_room, "from database")
room = load_room_from_database (current_room)
end -- not in cache
if not got_exits then
ColourNote ("palevioletred", "", [[
WARNING: I did not see a "Visible Exits:" line.
The mapper will not connect rooms to other rooms without it.
Please turn on the exits by typing:
]])
ColourNote ("yellow", "", [[
set show-exits
]])
end -- if
if not room then
-- print ("Added room", uid) -- debugging
-- print ("Name", roomname)
-- ColourNote ("rosybrown", "", roomdesc)
db:exec ("BEGIN TRANSACTION;")
save_room_to_database (current_room, roomname, Trim (roomdesc))
save_exits_to_database (current_room, exits_str)
db:exec ("COMMIT;")
-- get it back now
room = load_room_from_database (current_room)
end -- if room not there
-- call mapper to draw this rom
mapper.draw (current_room) -- redraw room with name
-- try to work out where previous room's exit led
if expected_exit ~= uid and from_room then
fix_up_exit ()
end -- exit was wrong
end -- Other_Line
function Shop_Line (name, line, wildcards)
-- location not known?
if not current_room then
return
end -- if
if rooms [current_room].shop then
return
end -- already a shop
-- mark as shop
rooms [current_room].shop = true
-- update database
dbcheck (db:execute (string.format (
"UPDATE rooms SET shop = %i WHERE uid = %s;",
fixbool (rooms [current_room].shop),
fixsql (current_room)
)))
-- note it
mapper.mapprint ("Room", current_room, "marked as a shop")
-- redraw
mapper.draw (current_room)
end -- Shop_Line
function Train_Line (name, line, wildcards)
-- location not known?
if not current_room then
return
end -- if
if rooms [current_room].train then
return
end -- already a train
-- mark as train
rooms [current_room].train = true
-- update database
dbcheck (db:execute (string.format (
"UPDATE rooms SET train = %i WHERE uid = %s;",
fixbool (rooms [current_room].train),
fixsql (current_room)
)))
-- note it
mapper.mapprint ("Room", current_room, "marked as a training room")
-- redraw
mapper.draw (current_room)
end -- Train_Line
-- -----------------------------------------------------------------
-- mapper 'get_room' callback - it wants to know about room uid
-- -----------------------------------------------------------------
function get_room (uid)
-- check we got room at all
if not uid then
-- return nil
end -- if
-- look it up
local ourroom = rooms [uid]
-- not cached - see if in database
if not ourroom then
ourroom = load_room_from_database (uid)
rooms [uid] = ourroom -- cache for later
end -- not in cache
if not ourroom then
return nil
end -- if
local room = copytable.deep (ourroom)
room.area = "Materia Magica"
if uid == current_room then
current_area = room.area
end -- if
-- build hover message
local shop = ""
if room.shop then
shop = "\nRoom is shop"
end -- if shop
local train = ""
if room.train then
train = "\nRoom has trainer"
end -- if train
local notes = ""
if room.notes then
notes = "\nBookmark: " .. room.notes
end -- if notes
local texits = {}
for dir in pairs (room.exits) do
table.insert (texits, dir)
end -- for
table.sort (texits)
room.hovermessage = string.format (
"%s\tExits: %s\nRoom: %s%s%s%s",
room.name,
table.concat (texits, ", "),
uid,
shop,
train,
notes
-- depth,
-- table.concat (path, ",")
)
room.bordercolour = config.ROOM_COLOUR.colour
room.borderpen = 0 -- solid
room.borderpenwidth = 1
room.fillcolour = 0xff0000
room.fillbrush = 1 -- no fill
-- special room fill colours
if room.shop then
room.fillcolour = config.SHOP_FILL_COLOUR.colour
room.fillbrush = 8
end -- if
if room.train then
room.fillcolour = config.TRAINER_FILL_COLOUR.colour
room.fillbrush = 8
end -- if
if uid == current_room then
room.bordercolour = config.OUR_ROOM_COLOUR.colour
room.borderpenwidth = 2
elseif room.area ~= current_area then
room.bordercolour = config.DIFFERENT_AREA_COLOUR.colour
end -- not in this area
return room
end -- get_room
-- -----------------------------------------------------------------
-- We have changed rooms - work out where the previous room led to
-- -----------------------------------------------------------------
function fix_up_exit ()
-- where we were before
local room = rooms [from_room]
-- print ("Moved from", from_room, "to", current_room, "in direction", last_direction_moved)
-- leads to here
if from_room ~= current_room then
dbcheck (db:execute (string.format ([[
UPDATE exits SET touid = %s WHERE fromuid = %s AND dir = %s;
]],
fixsql (current_room), -- destination room
fixsql (from_room), -- from previous room
fixsql (last_direction_moved) -- direction (eg. "n")
)))
if show_database_mods then
mapper.mapprint ("Fixed exit", last_direction_moved, "from room", from_room, "to be to", current_room)
end -- if
room.exits [last_direction_moved] = current_room
end -- if
-- clear for next time
last_direction_moved = nil
from_room = nil
end -- fix_up_exit
-- -----------------------------------------------------------------
-- try to detect when we send a movement command
-- -----------------------------------------------------------------
function OnPluginSent (sText)
if valid_direction [sText] then
last_direction_moved = valid_direction [sText]
-- print ("Just moved", last_direction_moved)
if current_room and rooms [current_room] then
expected_exit = rooms [current_room].exits [last_direction_moved]
if expected_exit then
from_room = current_room
end -- if
-- print ("expected exit for this direction is to room", expected_exit)
end -- if
end -- if
end -- function
default_config = {
-- assorted colours
BACKGROUND_COLOUR = { name = "Background", colour = ColourNameToRGB "lightseagreen", },
ROOM_COLOUR = { name = "Room", colour = ColourNameToRGB "cyan", },
EXIT_COLOUR = { name = "Exit", colour = ColourNameToRGB "darkgreen", },
EXIT_COLOUR_UP_DOWN = { name = "Exit up/down", colour = ColourNameToRGB "darkmagenta", },
EXIT_COLOUR_IN_OUT = { name = "Exit in/out", colour = ColourNameToRGB "#3775E8", },
OUR_ROOM_COLOUR = { name = "Our room", colour = ColourNameToRGB "black", },
UNKNOWN_ROOM_COLOUR = { name = "Unknown room", colour = ColourNameToRGB "#00CACA", },
DIFFERENT_AREA_COLOUR = { name = "Another area", colour = ColourNameToRGB "#009393", },
SHOP_FILL_COLOUR = { name = "Shop", colour = ColourNameToRGB "darkolivegreen", },
POSTOFFICE_FILL_COLOUR = { name = "Post Office", colour = ColourNameToRGB "yellowgreen", },
BANK_FILL_COLOUR = { name = "Bank", colour = ColourNameToRGB "gold", },
NEWSROOM_FILL_COLOUR = { name = "Newsroom", colour = ColourNameToRGB "lightblue", },
TRAINER_FILL_COLOUR = { name = "Trainer", colour = ColourNameToRGB "lightgreen" },
ROOM_NAME_TEXT = { name = "Room name text", colour = ColourNameToRGB "#BEF3F1", },
ROOM_NAME_FILL = { name = "Room name fill", colour = ColourNameToRGB "#105653", },
ROOM_NAME_BORDER = { name = "Room name box", colour = ColourNameToRGB "black", },
AREA_NAME_TEXT = { name = "Area name text", colour = ColourNameToRGB "#BEF3F1",},
AREA_NAME_FILL = { name = "Area name fill", colour = ColourNameToRGB "#105653", },
AREA_NAME_BORDER = { name = "Area name box", colour = ColourNameToRGB "black", },
FONT = { name = get_preferred_font {"Dina", "Lucida Console", "Fixedsys", "Courier", "Sylfaen",} ,
size = 8
} ,
-- size of map window
WINDOW = { width = 400, height = 400 },
-- how far from where we are standing to draw (rooms)
SCAN = { depth = 30 },
-- speedwalk delay
DELAY = { time = 0.3 },
-- how many seconds to show "recent visit" lines (default 3 minutes)
LAST_VISIT_TIME = { time = 60 * 3 },
}
-- -----------------------------------------------------------------
-- Plugin Install
-- -----------------------------------------------------------------
function OnPluginInstall ()
config = {} -- in case not found
-- get saved configuration
assert (loadstring (GetVariable ("config") or "")) ()
-- allow for additions to config
for k, v in pairs (default_config) do
config [k] = config [k] or v
end -- for
-- initialize mapper
mapper.init { config = config,
get_room = get_room,
show_help = OnHelp, -- to show help
room_click = room_click, -- called on RH click on room square
timing = show_timing, -- want to see timing
show_completed = show_completed, -- want to see "Speedwalk completed." message
show_other_areas = show_other_areas, -- want to see areas other than the current one?
show_up_down = show_up_down, -- want to follow up/down exits?
show_area_exits = show_area_exits, -- want to see area exits?
speedwalk_prefix = speedwalk_prefix, -- how to speedwalk
}
mapper.mapprint (string.format ("MUSHclient mapper installed, version %0.1f", mapper.VERSION))
-- open databases on disk
db = assert (sqlite3.open(GetInfo (66) .. Trim (WorldAddress ()) .. "_" .. WorldPort () .. ".db"))
create_tables () -- create database structure if necessary
end -- OnPluginInstall
-- -----------------------------------------------------------------
-- Plugin Save State
-- -----------------------------------------------------------------
function OnPluginSaveState ()
mapper.save_state ()
SetVariable ("config", "config = " .. serialize.save_simple (config))
end -- OnPluginSaveState
function map_resume (name, line, wildcards)
local wanted = mapper.last_hyperlink_uid or mapper.last_speedwalk_uid
if not wanted then
mapper.print "No outstanding speedwalks or hyperlinks."
return
end -- if nothing to do
-- find desired room
mapper.find (
function (uid)
return uid == wanted, uid == wanted
end, -- function
show_vnums, -- show vnum?
1, -- how many to expect
true -- just walk there
)
end -- map_resume
function map_goto (name, line, wildcards)
local wanted = wildcards [1]
-- check valid string
if string.match (wanted, "%X") then
mapper.maperror ("Room number must be hex string (0-9, A-F), you entered: " .. wanted)
return
end -- if
-- internally rooms are upper-case hex
wanted = wanted:upper ()
-- see if already there
if current_room and string.match (current_room, "^" .. wanted) then
mapper.mapprint ("You are already in that room.")
return
end -- if
-- find desired room
mapper.find (
function (uid)
local found = string.match (uid, "^" .. wanted)
return found, found
end, -- function
show_vnums, -- show vnum?
1, -- how many to expect
true -- just walk there
)
end -- map_goto
function map_where (name, line, wildcards)
if not mapper.check_we_can_find () then
return
end -- if
local wanted = wildcards [1]
if current_room and wanted == current_room then
mapper.mapprint ("You are already in that room.")
return
end -- if
local paths = mapper.find_paths (current_room,
function (uid)
return uid == wanted, -- wanted room?
uid == wanted -- stop searching?
end)
local uid, item = next (paths, nil) -- extract first (only) path
-- nothing? room not found
if not item then
mapper.mapprint (string.format ("Room %s not found", wanted))
return
end -- if
-- turn into speedwalk
local path = mapper.build_speedwalk (item.path)
-- display it
mapper.mapprint (string.format ("Path to %s is: %s", wanted, path))
end -- map_where
function OnHelp ()
mapper.mapprint (string.format ("[MUSHclient mapper, version %0.1f]", mapper.VERSION))
mapper.mapprint (world.GetPluginInfo (world.GetPluginID (), 3))
end
room_not_in_database = {}
room_in_database = {}
function dbcheck (code)
if code ~= sqlite3.OK and -- no error
code ~= sqlite3.ROW and -- completed OK with another row of data
code ~= sqlite3.DONE then -- completed OK, no more rows
local err = db:errmsg () -- the rollback will change the error message
db:exec ("ROLLBACK") -- rollback any transaction to unlock the database
error (err, 2) -- show error in caller's context
end -- if
end -- dbcheck
function fixsql (s)
if s then
return "'" .. (string.gsub (s, "'", "''")) .. "'" -- replace single quotes with two lots of single quotes
else
return "NULL"
end -- if
end -- fixsql
function fixbool (b)
if b then
return 1
else
return 0
end -- if
end -- fixbool
function load_room_from_database (uid)
local room
assert (uid, "No UID supplied to load_room_from_database")
-- if not in database, don't look again
if room_not_in_database [uid] then
return nil
end -- no point looking