-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinit.lua
1332 lines (1205 loc) · 31.8 KB
/
init.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
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
-- a mod for displaying Minetest maps
-- David Mckenzie 2014
-- License: WTFPL v2
--
-- updateInterval for automatic regeneration of maps can be changed on line 53 (updateInterval = x)
local mapitFormspecBasic = ""
local mapitFormspecTP = ""
local mapitFormspecMouse = ""
local mapitPlayerName = ""
local mapitMapState = ""
local mapitwFormFu = 0
local curLine = 0
local mapitMapState = ""
local butX=0
local butZ=0
local worldStepWuX = 0
local worldStepWuZ = 0
local pngMinWuX = 0
local pngMaxWuZ = 0
local inv_mod = nil
function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
function file_copy(source, target)
local infile = io.open(source, "r")
local instr = infile:read("*a")
infile:close()
local outfile = io.open(target, "w")
outfile:write(instr)
outfile:close()
end
local updateMap = function(forceUpdate)
if forceUpdate == nil then forceUpdate = false end
-- GET NAMES AND PATHS TO ENSURE CORRECT MAP IS USED
local worldPath = minetest.get_worldpath()
local worldName = string.gsub(worldPath, "(.*worlds.)(.*)", "%2")
local worldsqlName = worldPath.. "/map.sqlite"
if not file_exists(worldsqlName) then return 0 end
local curModPath = minetest.get_modpath('mapit')
local texPath = curModPath.. "/textures/"
local dummyFilePName = texPath.. "mapit.png"
local mapFileName = worldName:gsub("%s+", "_").. ".png"
local thumbFileName = worldName:gsub("%s+", "_").. "_thumb.png"
local mapFilePName = texPath.. mapFileName
local thumbFilePName = texPath.. thumbFileName
local mapitHistoryPName = texPath.. "mapitHistory.txt"
--this should never be required
--os.execute("mkdir \"" .. texPath "\"") --create directory if it does not already exist
-- if there's a failure of the python script, at least there'll be a dummy file
if not file_exists(mapFilePName) then file_copy(dummyFilePName, mapFilePName) end
if not file_exists(thumbFilePName) then file_copy(dummyFilePName, thumbFilePName) end
local updateInterval = 7*24*60*60 -- number of seconds between updates
-- update the history to save the generation date
local lastUpdateTime = 0
local fh = io.open(mapitHistoryPName, "r")
local fileStr = ""
while true do
curLine = fh.read(fh)
if not curLine then break end
local cWN, lUT = curLine:match("(%w+)%s=%s(%d+)")
-- if cWN == nil then cWN = ""
-- if lUT == nil then lUT = 0
-- print(cWN)
-- print(lUT)
if cWN == (worldName) then
lastUpdateTime = tonumber(lUT)
else
fileStr = fileStr.. curLine
end
-- print (line)
end
-- get last modified time direct from the file
--for this to work, you will need to have installed luaFileSystem
--sudo luarocks install luafilesystem
--sudo apt-get install luarocks
-- local lfsExists, lfs = pcall(function () require "lfs" end)
local lfsExists, lfs = pcall(require, "lfs")
if lfsExists then
-- local lfs = require "lfs"
local lastUpdateTime = lfs.attributes( mapFilePName ).modification
end
if (lastUpdateTime < os.time()-updateInterval) or forceUpdate then
fileStr = fileStr.. worldName.. " = ".. os.time().. "\r\n"
fh:close()
-- run the python script to generate the map (could be run in background by appending an '&' to the string, but texture might be corrupted or out of date for current load)
local osx = "python \"".. curModPath.. "/".. "minetestmapper-numpy.py\" --pixelspernode 1 --drawscale \"".. worldPath.. "\" \"".. mapFilePName.. "\""
os.execute(osx)
print("mapit: Updated map for ".. worldName)
fh = io.open(mapitHistoryPName, "w")
fh:write(fileStr)
else
print("mapit: Map update not required for ".. worldName)
end
fh:close()
-- print (fileStr)
return
end
updateMap()
minetest.register_node('mapit:mapblock', {
-- ideally would have an automatic way of creating a face for the block which was correctly dimensions and aspect ratio
-- currently using a large .png introduces sig delay due to time drawing the faces
description = "Map Block",
tiles = { string.gsub(string.gsub(minetest.get_worldpath(), "(.*worlds.)(.*)", "%2"),"%s+", "_").."_thumb.png",
string.gsub(string.gsub(minetest.get_worldpath(), "(.*worlds.)(.*)", "%2"),"%s+", "_").."_thumb.png",
string.gsub(string.gsub(minetest.get_worldpath(), "(.*worlds.)(.*)", "%2"),"%s+", "_").."_thumb.png",
string.gsub(string.gsub(minetest.get_worldpath(), "(.*worlds.)(.*)", "%2"),"%s+", "_").."_thumb.png",
string.gsub(string.gsub(minetest.get_worldpath(), "(.*worlds.)(.*)", "%2"),"%s+", "_").."_thumb.png",
string.gsub(string.gsub(minetest.get_worldpath(), "(.*worlds.)(.*)", "%2"),"%s+", "_").."_thumb.png",
},
sunlight_propagates = false,
paramtype = "light",
walkable = true,
groups = {cracky=3},
})
minetest.register_node('mapit:teleportWaypoint', {
description = "Teleport Point",
drawtype = "plantlike",
inventory_image = "apophysisFlame.png",
wield_image = "apophysisFlame.png",
tiles = { "apophysisFlame.png" },
sunlight_propagates = false,
paramtype = "light",
walkable = true,
-- sounds = default.node_sound_leaves_defaults(),
groups = {cracky=3},
})
minetest.register_tool("mapit:maptool", {
description = "Map Tool",
inventory_image = string.gsub(string.gsub(minetest.get_worldpath(), "(.*worlds.)(.*)", "%2"),"%s+", "_")..".png",
on_use = function(itemstack, user, pointed_thing)
map_handler_maptool(itemstack,user,pointed_thing)
end,
})
function map_handler_maptool (itemstack, user, pointed_thing)
mapitPlayerName=user:get_player_name()
generateMapStrings(mapitPlayerName)
minetest.show_formspec(mapitPlayerName, "mapit:maptool", mapitFormspecBasic)
end
function generateMapStrings()
-- suffixes: Fu = form units; Wu = world units; Pp = porportion; Px = pixels
print(name)
local player = minetest.get_player_by_name(mapitPlayerName)
print(mapitPlayerName)
print(player)
local posWu = player:getpos()
local map
local yaw
local rotate = 0
local facing = "Not set" -- direction player is facing (NSEW)
local wFormFu
local hFormFu
local width, height
-- globals
mapitMapState = ""
butX=-1
butZ=-1
local wPNGPx, hPNGPx, pngRegionWu, borderPx, pixPerNodePx
-- posWu.y = posWu.y + 1
yaw = player:get_look_yaw()
if yaw ~= nil then
-- Find angle player facing to enable rotation of position arrow based on yaw.
yaw = math.deg(yaw)
yaw = math.fmod (yaw, 360)
if yaw<0 then yaw = 360 + yaw end
if yaw>360 then yaw = yaw - 360 end
if yaw < 90 then
rotate = 90
elseif yaw < 180 then
rotate = 180
elseif yaw < 270 then
rotate = 270
else
rotate = 0
end
if yaw>315 or yaw<=45 then
facing="East"
elseif yaw>45 and yaw<=135 then
facing="South"
elseif yaw>135 and yaw<=225 then
facing="West"
elseif yaw>225 and yaw<=315 then
facing="North"
end
yaw = math.fmod(yaw, 90)
yaw = math.floor(yaw / 10) * 10
end
-- Bizarrely yaw seems to vary with world, so direction is incorrect (and the pos values are listed anyway so unnecessary).
-- minetest.chat_send_player(mapitPlayerName, "mapit: Current Loc: X: ".. math.floor(posWu.x).. ", Y:".. math.floor(posWu.y).. ", Z:".. math.floor(posWu.z).. ", Facing:".. facing, false)
-- GET NAMES AND PATHS TO ENSURE CORRECT MAP IS USED
local worldPath = minetest.get_worldpath()
local worldName = string.gsub(worldPath, "(.*worlds.)(.*)", "%2")
local curModPath = minetest.get_modpath('mapit')
local mapFileName = curModPath.. "/textures/".. worldName:gsub("%s+", "_").. ".png"
-- PARSE THE PNG TO EXTRACT MAP LOCATIONS
wPNGPx, hPNGPx, pngRegionWu, pngMinWuX, pngMaxWuZ, borderPx, pixPerNodePx = parse_png (mapFileName)
-- CALCULATE WORLD AND FORM DIMENSIONS AND PROPORTIONS
local wWorldWu=(wPNGPx-borderPx)/pixPerNodePx
local hWorldWu=(hPNGPx-borderPx)/pixPerNodePx
local wWorldUnitPp= pixPerNodePx/wPNGPx
local hWorldUnitPp= pixPerNodePx/hPNGPx
local lBorderPp = borderPx/(wPNGPx-borderPx)
local tBorderPp = borderPx/(hPNGPx-borderPx)
-- determine required form width to maintain PNG aspect ratio (known z/height)
local aspectRatio = wPNGPx/hPNGPx
-- print(aspectRatio)
if aspectRatio > 1.35 then
wFormFu = 16
hFormFu = (wFormFu-1)/aspectRatio
else
hFormFu = 11 -- height of the form
wFormFu = hFormFu*aspectRatio +1
end
local wMapFu = hFormFu*aspectRatio
local hMapFu = hFormFu
local lBorderFu =wMapFu * lBorderPp
local tBorderFu = hMapFu * tBorderPp
-- SCALE AND LOCATE ARROW
local arrowSizeFuZ=0.4
local arrowSizeFuX=0.4 --*aspectRatio
-- Distance from world location at PNG origin to player current location (in WORLD UNITS)
local pngOriginToPlayerWuX = posWu.x - pngMinWuX -- x axis is more POSITIVE away from origin
local pngOriginToPlayerWuZ = pngMaxWuZ - posWu.z -- z axis is more NEGATIVE away from origin
-- Distance from world location at PNG origin to player current location (in PIXELS)
local playerLocFuX = wMapFu*pngOriginToPlayerWuX*wWorldUnitPp -- location for middle of arrow icon (in pixels)
local playerLocFuZ = hMapFu*pngOriginToPlayerWuZ*hWorldUnitPp -- location for middle of arrow icon (in pixels)
-- location of arrow (in form units)
local ArrowLocFuX = playerLocFuX + lBorderFu - arrowSizeFuX/2
local ArrowLocFuZ = playerLocFuZ + tBorderFu
-- generate the appropriate string for the arrow (to ensure rotation is correct)
local imstr
if rotate ~= 0 then
imstr = "image["..ArrowLocFuX..","..ArrowLocFuZ..";"..arrowSizeFuX..","..arrowSizeFuZ..";d" .. yaw .. ".png^[transformFYR".. rotate .."]"
else
imstr = "image["..ArrowLocFuX..","..ArrowLocFuZ..";"..arrowSizeFuX..","..arrowSizeFuZ..";d" .. yaw .. ".png^[transformFY]"
end
-- button[X,Y;W,H;name;label]
local buttons = ""
buttons = buttons.."button["..(wFormFu-0.8)..",0;0.8,0.8;zoomIn;z+]"
buttons = buttons.."button["..(wFormFu-0.8)..",1;0.8,0.8;zoomOut;z-]"
buttons = buttons.."button["..(wFormFu-0.8)..",2;0.8,0.8;updateMap;reMap]"
buttons = buttons.."image_button["..(wFormFu-0.8)..",3;0.8,0.8;logo.png;teleport;T]"
if minetest.get_modpath("travelpoints") then
buttons = buttons.."image_button["..(wFormFu-0.8)..",4;0.8,0.8;teleport.png;TP;TP]"
end
local mapMouseButtons = ""
worldStepWuX = wWorldWu/10
worldStepWuZ = hWorldWu/10
-- CREATE LIST OF BUTTONS TO OVERLAY MAP (FOR MOUSE CLICKS)
for iy = 0,9 do
for ix = 0,9 do
mapMouseButtons = mapMouseButtons.."image_button["..((wMapFu-lBorderFu)/10*ix+lBorderFu)..","..((hMapFu-tBorderFu)/10*iy+tBorderFu)..";"..((wMapFu-lBorderFu)/8)..","..((hMapFu-tBorderFu)/8)..";blank.png;map"..ix..iy..";;true;false]"
--"..true..";"..true.."]"
end
end
-- print(minetest.get_modpath("mapit"))
-- print(minetest.get_modpath("travelpoints"))
if minetest.get_modpath("travelpoints") then
-- CREATE LIST OF TRAVELPOINT LOCATIONS TO OVERLAY ON MAP
-- This code largely taken from travelpoints functions.lua
-- Get travelpoints_array.
local travelpoints_table = travelpoints.get_travelpoints_table(mapitPlayerName)
local travelpoints_array = travelpoints.get_travelpoints_array(mapitPlayerName)
-- print(dump(travelpoints_array))
-- print("+++")
-- print(dump(travelpoints_table))
-- Get travelpoint count.
local tp_count = #travelpoints_array - 1
local mapitTPButtons = ""
-- Check if player has any travelpoints.
if tp_count > 0 then
-- Step through travelpoints_array.
for index, value in ipairs(travelpoints_array) do
-- Omit first index (used for travelpoints:transporter_pad/_active's formspec)
if index > 1 and index <= 50 then
-- Extract title from value: "<title> (<x>, <y>, <z>)"
local title = string.match(value, "^([^ ]+)%s+")
-- Output lines.
-- <n>. <title> (<x>, <y>, <z>). Saved on <date> at <time>. Descripton: <desc>
tPPos = travelpoints_table[title].pos
-- SCALE AND LOCATE TRAVEL POINT
local tPSizeFuZ=0.4
local tPSizeFuX=0.4 --*aspectRatio
-- Distance from world location at PNG origin to player current location (in WORLD UNITS)
local pngOriginToTPWuX = travelpoints_table[title].pos.x - pngMinWuX -- x axis is more POSITIVE away from origin
local pngOriginToTPWuZ = pngMaxWuZ - travelpoints_table[title].pos.z -- z axis is more NEGATIVE away from origin
-- Distance from world location at PNG origin to player current location (in PIXELS)
local tPLocFuX = wMapFu*pngOriginToTPWuX*wWorldUnitPp -- location for middle of arrow icon (in pixels)
local tPLocFuZ = hMapFu*pngOriginToTPWuZ*hWorldUnitPp -- location for middle of arrow icon (in pixels)
-- location of arrow (in form units)
local tPLocFuX = tPLocFuX + lBorderFu - tPSizeFuX/2
local tPLocFuZ = tPLocFuZ + tBorderFu
-- generate the appropriate string for the travelpoint
mapitTPButtons = mapitTPButtons.. "image_button[".. tPLocFuX.. ",".. tPLocFuZ.. ";".. tPSizeFuX.. ",".. tPSizeFuZ.. ";teleport.png;TP".. (index-2).. ";".. (index-2).. ";true;false]"
mapitTPButtons = mapitTPButtons.. "button[".. wFormFu.. ",".. ((index-2)/2).. ";3,".. tPSizeFuZ.. ";TP".. (index-2).. ";".. (index-2).. " ".. title.. "]"
elseif index > 50 then
minetest.chat_send_player(mapitPlayerName, "Sorry: mapit can only fit 50 travelpoints on the map", false)
break
end
end
else
-- minetest.chat_send_player(mapitPlayerName, "You have no saved travelpoints.", false)
end
-- GENERATE THE STRING FOR TRAVELPOINTS FORM
mapitwFormFu = wFormFu + 3
mapitFormspecTP = "size["..mapitwFormFu..","..hFormFu.."]"..
imstr..
"background[0,0;"..wMapFu..","..hMapFu..";"..worldName:gsub("%s+", "_")..".png]"..
buttons..
mapitTPButtons
end
-- GENERATE THE FORM AND DISPLAY IT
mapitFormspecBasic = "size["..wFormFu..","..hFormFu.."]"..
imstr..
"background[0,0;"..wMapFu..","..hMapFu..";"..worldName:gsub("%s+", "_")..".png]"..
buttons
-- print(mapitFormspecBasic)
-- generate the string for the mousebuttons form
mapitFormspecMouse = mapitFormspecBasic.. mapMouseButtons
print (mapitFormspecBasic)
return mapitFormspecBasic
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
mapitPlayerName=player:get_player_name()
butX=-1
-- print()
-- print("basic:".. mapitFormspecBasic)
-- print()
-- print("with multibutton:".. mapitFormspecMouse)
-- print()
-- print("--------")
-- print("map state:".. mapitMapState)
if fields.uI then
generateMapStrings()
minetest.show_formspec(mapitPlayerName, "mapit:maptool", mapitFormspecBasic)
mapitMapState = ""
end
if fields.zoomIn then
minetest.chat_send_player(mapitPlayerName, "Zoom In not implemented", false)
if mapitMapState == "+" then
mapitMapState=""
minetest.show_formspec(mapitPlayerName, "mapit:maptool", mapitFormspecBasic)
else
mapitMapState="+"
minetest.show_formspec(mapitPlayerName, "mapit:maptool", mapitFormspecMouse)
end
end
if fields.zoomOut then
minetest.chat_send_player(mapitPlayerName, "Zoom Out not implemented", false)
if mapitMapState == "-" then
mapitMapState=""
minetest.show_formspec(mapitPlayerName, "mapit:maptool", mapitFormspecBasic)
else
mapitMapState="-"
minetest.show_formspec(mapitPlayerName, "mapit:maptool", mapitFormspecMouse)
end
end
if fields.updateMap then
minetest.chat_send_player(mapitPlayerName, "Updating Map, please be patient...", false)
updateMap()
minetest.chat_send_player(mapitPlayerName, "Map Updated. Please exit and re-enter world to reload the texture", false)
end
if fields.teleport then
if mapitMapState == "t" then
mapitMapState=""
minetest.show_formspec(mapitPlayerName, "mapit:maptool", mapitFormspecBasic)
else
mapitMapState="t"
minetest.show_formspec(mapitPlayerName, "mapit:maptool", mapitFormspecMouse)
end
end
if minetest.get_modpath("travelpoints") then
local travelpoints_table = travelpoints.get_travelpoints_table(mapitPlayerName)
local travelpoints_array = travelpoints.get_travelpoints_array(mapitPlayerName)
local tPIndex = -1
if fields.TP then
if mapitMapState == "tp" then
mapitMapState=""
minetest.show_formspec(mapitPlayerName, "mapit:maptool", mapitFormspecBasic)
else
-- Only display the form if there is at least one travelpoint
local travelpoints_table = travelpoints.get_travelpoints_table(mapitPlayerName)
local travelpoints_array = travelpoints.get_travelpoints_array(mapitPlayerName)
local tp_count = #travelpoints_array - 1
if tp_count > 0 then
mapitMapState="tp"
minetest.show_formspec(mapitPlayerName, "mapit:maptool", mapitFormspecTP)
else
minetest.chat_send_player(mapitPlayerName, "You have no saved travelpoints.", false)
end
end
end
if fields.TP0 then
tPIndex = 2
end
if fields.TP1 then
tPIndex = 3
end
if fields.TP2 then
tPIndex = 4
end
if fields.TP3 then
tPIndex =5
end
if fields.TP4 then
tPIndex =6
end
if fields.TP5 then
tPIndex =7
end
if fields.TP6 then
tPIndex =8
end
if fields.TP7 then
tPIndex =9
end
if fields.TP8 then
tPIndex =10
end
if fields.TP9 then
tPIndex =11
end
if fields.TP10 then
tPIndex =12
end
if fields.TP11 then
tPIndex =13
end
if fields.TP12 then
tPIndex =14
end
if fields.TP13 then
tPIndex =15
end
if fields.TP14 then
tPIndex =16
end
if fields.TP15 then
tPIndex =17
end
if fields.TP16 then
tPIndex =18
end
if fields.TP17 then
tPIndex =19
end
if fields.TP18 then
tPIndex =20
end
if fields.TP19 then
tPIndex =21
end
if fields.TP20 then
tPIndex =22
end
if fields.TP21 then
tPIndex =23
end
if fields.TP22 then
tPIndex =24
end
if fields.TP23 then
tPIndex =25
end
if fields.TP24 then
tPIndex =26
end
if fields.TP25 then
tPIndex =27
end
if fields.TP26 then
tPIndex =28
end
if fields.TP27 then
tPIndex =29
end
if fields.TP28 then
tPIndex =30
end
if fields.TP29 then
tPIndex =31
end
if fields.TP30 then
tPIndex =32
end
if fields.TP31 then
tPIndex =33
end
if fields.TP32 then
tPIndex =34
end
if fields.TP33 then
tPIndex =35
end
if fields.TP34 then
tPIndex =36
end
if fields.TP35 then
tPIndex =37
end
if fields.TP36 then
tPIndex =38
end
if fields.TP37 then
tPIndex =39
end
if fields.TP38 then
tPIndex =40
end
if fields.TP39 then
tPIndex =41
end
if fields.TP40 then
tPIndex =42
end
if fields.TP41 then
tPIndex =43
end
if fields.TP42 then
tPIndex =44
end
if fields.TP43 then
tPIndex =45
end
if fields.TP44 then
tPIndex =46
end
if fields.TP45 then
tPIndex =47
end
if fields.TP46 then
tPIndex =48
end
if fields.TP47 then
tPIndex =49
end
if fields.TP48 then
tPIndex =50
end
if fields.TP49 then
tPIndex =51
end
if fields.TP50 then
tPIndex =52
end
if tPIndex >=0 then
for index, value in ipairs(travelpoints_array) do
-- Omit first index (used for travelpoints:transporter_pad/_active's formspec)
if index == tPIndex then
-- Extract title from value: "<title> (<x>, <y>, <z>)"
local title = string.match(value, "^([^ ]+)%s+")
player:setpos(travelpoints_table[title].pos)
end
end
generateMapStrings()
minetest.show_formspec(mapitPlayerName, "mapit:maptool", mapitFormspecTP)
mapitMapState = "tp"
end
end
-- There seems to be no way to hook the mouse click directly, so make a 10x10 grid of transparent buttons and use these to approximate location
if fields.map00 then
butX=0
butZ=0
end
if fields.map01 then
butX=0
butZ=1
end
if fields.map02 then
butX=0
butZ=2
end
if fields.map03 then
butX=0
butZ=3
end
if fields.map04 then
butX=0
butZ=4
end
if fields.map05 then
butX=0
butZ=5
end
if fields.map06 then
butX=0
butZ=6
end
if fields.map07 then
butX=0
butZ=7
end
if fields.map08 then
butX=0
butZ=8
end
if fields.map09 then
butX=0
butZ=9
end
if fields.map10 then
butX=1
butZ=0
end
if fields.map11 then
butX=1
butZ=1
end
if fields.map12 then
butX=1
butZ=2
end
if fields.map13 then
butX=1
butZ=3
end
if fields.map14 then
butX=1
butZ=4
end
if fields.map15 then
butX=1
butZ=5
end
if fields.map16 then
butX=1
butZ=6
end
if fields.map17 then
butX=1
butZ=7
end
if fields.map18 then
butX=1
butZ=8
end
if fields.map19 then
butX=1
butZ=9
end
if fields.map20 then
butX=2
butZ=0
end
if fields.map21 then
butX=2
butZ=1
end
if fields.map22 then
butX=2
butZ=2
end
if fields.map23 then
butX=2
butZ=3
end
if fields.map24 then
butX=2
butZ=4
end
if fields.map25 then
butX=2
butZ=5
end
if fields.map26 then
butX=2
butZ=6
end
if fields.map27 then
butX=2
butZ=7
end
if fields.map28 then
butX=2
butZ=8
end
if fields.map29 then
butX=2
butZ=9
end
if fields.map30 then
butX=3
butZ=0
end
if fields.map31 then
butX=3
butZ=1
end
if fields.map32 then
butX=3
butZ=2
end
if fields.map33 then
butX=3
butZ=3
end
if fields.map34 then
butX=3
butZ=4
end
if fields.map35 then
butX=3
butZ=5
end
if fields.map36 then
butX=3
butZ=6
end
if fields.map37 then
butX=3
butZ=7
end
if fields.map38 then
butX=3
butZ=8
end
if fields.map39 then
butX=3
butZ=9
end
if fields.map40 then
butX=4
butZ=0
end
if fields.map41 then
butX=4
butZ=1
end
if fields.map42 then
butX=4
butZ=2
end
if fields.map43 then
butX=4
butZ=3
end
if fields.map44 then
butX=4
butZ=4
end
if fields.map45 then
butX=4
butZ=5
end
if fields.map46 then
butX=4
butZ=6
end
if fields.map47 then
butX=4
butZ=7
end
if fields.map48 then
butX=4
butZ=8
end
if fields.map49 then
butX=4
butZ=9
end
if fields.map50 then
butX=5
butZ=0
end
if fields.map51 then
butX=5
butZ=1
end
if fields.map52 then
butX=5
butZ=2
end
if fields.map53 then
butX=5
butZ=3
end
if fields.map54 then
butX=5
butZ=4
end
if fields.map55 then
butX=5
butZ=5
end
if fields.map56 then
butX=5
butZ=6
end
if fields.map57 then
butX=5
butZ=7
end
if fields.map58 then
butX=5
butZ=8
end
if fields.map59 then
butX=5
butZ=9
end
if fields.map60 then
butX=6
butZ=0
end
if fields.map61 then
butX=6
butZ=1
end
if fields.map62 then
butX=6
butZ=2
end
if fields.map63 then
butX=6
butZ=3
end
if fields.map64 then
butX=6
butZ=4
end
if fields.map65 then
butX=6
butZ=5
end
if fields.map66 then
butX=6
butZ=6
end
if fields.map67 then
butX=6
butZ=7
end
if fields.map68 then
butX=6
butZ=8
end
if fields.map69 then
butX=6
butZ=9
end
if fields.map70 then
butX=7
butZ=0
end
if fields.map71 then
butX=7
butZ=1
end
if fields.map72 then
butX=7
butZ=2
end
if fields.map73 then
butX=7
butZ=3
end
if fields.map74 then
butX=7
butZ=4
end
if fields.map75 then
butX=7
butZ=5
end
if fields.map76 then
butX=7
butZ=6
end
if fields.map77 then
butX=7
butZ=7
end
if fields.map78 then
butX=7
butZ=8
end
if fields.map79 then
butX=7
butZ=9
end
if fields.map80 then
butX=8
butZ=0
end
if fields.map81 then
butX=8
butZ=1
end
if fields.map82 then
butX=8
butZ=2
end
if fields.map83 then
butX=8
butZ=3
end
if fields.map84 then
butX=8
butZ=4
end
if fields.map85 then
butX=8
butZ=5
end
if fields.map86 then
butX=8
butZ=6
end
if fields.map87 then
butX=8
butZ=7
end
if fields.map88 then
butX=8
butZ=8
end
if fields.map89 then
butX=8
butZ=9
end
if fields.map90 then
butX=9
butZ=0
end
if fields.map91 then
butX=9
butZ=1
end
if fields.map92 then
butX=9
butZ=2
end
if fields.map93 then