×

Langue

Fermer
Atelier 801
  • Forums
  • Dev Tracker
  • Connexion
    • English Français
      Português do Brasil Español
      Türkçe Polski
      Magyar Română
      العربية Skandinavisk
      Nederlands Deutsch
      Bahasa Indonesia Русский
      中文 Filipino
      Lietuvių kalba 日本語
      Suomi עברית
      Italiano Česky
      Hrvatski Slovensky
      Български Latviešu
      Estonian
  • Langue
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • [Script] MapAnalyzer
[Script] MapAnalyzer
Flora
« Citoyen »
1742427300000
    • Flora#9543
    • Profil
    • Derniers messages
    • Tribu
#1
  3
  • Introduction
  • Commands
  • Suggestions
  • Credits
  • Script

MapAnalyzer


Let me introduce one of my archived scripts that allows you to inspect the map using lua. This script is based on the !inspect command in shamousey/utility rooms.

https://i.imgur.com/G219TLq.png
It displays information about the map author, map code, map category (including both code and name), and various flags such as wind, gravity, and fall damage, among others. It also provides a list of coordinates where cheese and the hole are located on the map. Additionally, screenshot and preview map modes are supported. In screenshot mode, all players are killed from the map to allow for a clear screenshot. Preview mode is simply as finish the map without the assistance of other players.

Note: This is an old script that i've made in recently years and updated today. Keep in mind that i have used code from other people and these people will be credited in Credits section.
Note: You may need privilege access (be a module member) to use some of the commands.

Here are all the supported commands.

!np

This command is used to change the map. It takes one parameter, which can be either a map category or a map code. Map categories start with pXX, while map codes start with @xx.

Example:

!np p17 -> Loads a new racing map. (p17 is the map category for racing). You can check all map categories here.
!np @1882320 -> Loads the map @1882320.


!review

Loads the map in review mode. Everyone in the room will be killed except for you. Run the command again to exit review mode.


!xml

Get's the xml code from current map.


!ss

Loads the map in screenshot mode. Everyone in the room will be killed for taking a clear screenshot. Run the command again to exit screenshot mode.


!sha

Makes you a shaman in the current map. Run the command again to remove your shaman ability.


!sy

Makes you the room synchronizer. (Privileged function).


!lsmap

Displays the log of the last 20 loaded maps.


!stop

Stops the script


REJECTED : Adds a flag for antleve maps.
ACCEPTED: Multiple script administrators in the same room.

As I mentioned before, not everything in the script was made by me. I have used code from other mice.

Credits:
Mikuhl#0000 -> [Script] Script for testing and map review. (Plus a handy screenshot feature.)
Itchyboy#0000 -> [Script] GetXML
Shamousey#0095 -> Module #utility

Code 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
local currentMap = "@5829292" -- The map to load at beginning.
local usePrint = true -- False if using tfm.exec.chatMessage
local scriptAdmins = {
["Flora#9543"] = true
}

-- Do not change these.
local mapInfoTextAreaId, mapListTextAreaId, closeMapListTextAreaId, openMapGroundInfoTextAreaId = 1002, 1003, 1004, 1005
local screenshot, reviewing = false, false
local players, mapInfo = {}, {}
local savedMaps = {}

local mapCategories = {
[0] = "Standard",
[1] = "Protected",
[2] = "Prime",
[3] = "Prime Bootcamp",
[4] = "Shaman",
[5] = "Art",
[6] = "Mechanism",
[7] = "No Shaman",
[8] = "Dual Shaman",
[9] = "Misc",
[10] = "Survivor",
[11] = "Vamp Survivor",
[12] = "Old Farming Style",
[13] = "Bootcamp",
[17] = "Racing",
[18] = "Defilante",
[19] = "Music",
[20] = "Survivor Test",
[21] = "Vamp Survivor Test",
[22] = "Tribe House",
[23] = "Bootcamp Test",
[24] = "Dual Shaman Survivor",
[32] = "Dual Shaman Test",
[34] = "Dual Shaman Survivor Test",
[38] = "Racing Test",
[40] = "",
[41] = "Module",
[42] = "No Shaman Test",
[43] = "Inappropriate",
[44] = "Deleted",
[66] = "Thematic",
[87] = "Vanilla",
[88] = "Vanilla Test"
}

local groundList = {
[0] = "Wood",
[1] = "Ice",
[2] = "Trampoline",
[3] = "Lava",
[4] = "Chocolate",
[5] = "Earth",
[6] = "Grass",
[7] = "Sand",
[8] = "Cloud",
[9] = "Water",
[10] = "Stone",
[11] = "Snow",
[12] = "Rectangle",
[13] = "Circle",
[14] = "Invisible",
[15] = "Cobweb",
[16] = "",
[17] = "Yellow grass",
[18] = "Pink grass",
[19] = "Acid"
}

---- TFM EVENTS
eventChatCommand = function(playerName, command)
if not players[playerName].isPrivileged then
PrintText("<J>[MapAnalyzer]</J> You don't have permission to use this command.", playerName)
return
end

local args = {}
for arg in command:gmatch("%S+") do
table.insert(args, arg)
end

local commands = {
["np"] = function()
local mapArg = args[2]
if not mapArg then
return PrintText("<J>[MapAnalyzer]</J> You need more arguments to use this command.", playerName)
end

if screenshot or reviewing then
return
end

local firstChar = mapArg:sub(1, 1)
if firstChar == "@" then
tfm.exec.newGame(mapArg)
elseif firstChar == "p" then
tfm.exec.newGame("#" .. mapArg:sub(2))
else
PrintText("<J>[MapAnalyzer]</J> The supplied argument is neither a valid map code or a category.", playerName)
end
end,
["review"] = function()
reviewing = not reviewing
PrintText("<J>[MapAnalyzer]</J> Review mode " .. (reviewing and "enabled" or "disabled") .. ".", playerName)
tfm.exec.disableAutoTimeLeft(not reviewing)
tfm.exec.newGame(tfm.get.room.currentMap)
SetMapInfo()
end,
["xml"] = function()
local xml = tfm.get.room.xmlMapInfo and tfm.get.room.xmlMapInfo.xml
if xml then
for i = 0, math.ceil(#xml / 2000) - 1 do
PrintText("<b><font color='white' size='10'>" .. xml:sub(#xml * (i / math.ceil(#xml / 2000)) + 1, #xml * ((i + 1) / math.ceil(#xml / 2000))):gsub("<", "&lt;") .. "</font></b>", player)
end
else
PrintText("<J>[MapAnalyzer]</J> No XML data available.", playerName)
end
end,
["ss"] = function()
if not reviewing then
screenshot = not screenshot
PrintText("<J>[MapAnalyzer]</J> Screenshot mode " .. (screenshot and "enabled" or "disabled") .. ".", playerName)
for name in pairs(tfm.get.room.playerList) do
if screenshot then
tfm.exec.killPlayer(name, false)
else
tfm.exec.respawnPlayer(name)
end
end
SetMapInfo()
if screenshot then
ui.removeTextArea(mapInfoTextAreaId)
end
end
end,
["sha"] = function()
players[playerName].isShaman = not players[playerName].isShaman
tfm.exec.setShaman(playerName, players[playerName].isShaman)
end,
["sy"] = function()
tfm.exec.setPlayerSync(playerName)
end,
["lsmap"] = function()
if #savedMaps == 0 then
PrintText("<J>[MapAnalyzer]</J> No maps saved yet.", playerName)
return
end

players[playerName].isOpenMapHistory = not players[playerName].isOpenMapHistory
if players[playerName].isOpenMapHistory then
local text = "<J><b>History:</b></J><br>"
text = text .. table.concat(savedMaps, "\n")
ui.addTextArea(mapListTextAreaId, text, nil, 650, 30, 140, 180, 0x1A1A1A, 0x000000, 0.8, true)
ui.addTextArea(closeMapListTextAreaId, "<a href='event:close_maplist'>X</a>", nil, 770, 30, 20, 20, 0xFF0000, 0x000000, 1, true)
end
end,
["stop"] = function()
PrintText("<J>[MapAnalyzer]</J> Stopping the script.", playerName)
system.exit()
end
}

if commands[args[1]] then
commands[args[1]]()
end
end

eventKeyboard = function(playerName, keyCode, down, x, y)
if keyCode == 16 then -- SHIFT
players[playerName].isPressedShift = down
elseif keyCode == 17 then -- CTRL
players[playerName].isPressedCtrl = down
elseif keyCode == 46 then -- DEL
players[playerName].isPressedDel = down
end
end

eventMouse = function(playerName, x, y)
if not reviewing then
if players[playerName].isPressedDel then
tfm.exec.killPlayer(playerName)
players[playerName].isPressedDel = false
elseif players[playerName].isPressedCtrl then
tfm.exec.movePlayer(playerName, x, y)
players[playerName].isPressedCtrl = false
elseif players[playerName].isPressedShift then
ui.removeTextArea(openMapGroundInfoTextAreaId, playerName)
for i = #mapInfo.mapGrounds, 1, -1 do
local ground = mapInfo.mapGrounds[i]
local theta = math.rad(ground.rotation or 0)
local c, s = math.cos(-theta), math.sin(-theta)
local cx = ground.x + c * (x - ground.x) - s * (y - ground.y)
local cy = ground.y + s * (x - ground.x) + c * (y - ground.y)
if (ground.type == 13 and ((ground.x - x) * (ground.x - x) + (ground.y - y) * (ground.y - y) < (ground.length / 2) * (ground.length / 2))) or (math.abs(cx - ground.x) < ground.length / 2 and math.abs(cy - ground.y) < ground.height / 2) then
local properties = {"type", "id", "x", "y", "height", "length", "friction", "restitution", "rotation", "dynamic", "mass", "color"}
local info = {}
for _, property in ipairs(properties) do
local value = ground[property]
if value then
if property == "color" then
value = string.format("<font color='#%s'>#%s</font>", value, value)
elseif property == "dynamic" then
value = value == 0 and "False" or "True"
elseif property == "type" then
value = groundList[value]
end
table.insert(info, string.format("<N>%s: <VP>%s</VP></N>", property:gsub("^%l", string.upper), value))
end
end

local w, h = mapInfo.mapLength, mapInfo.mapHeight
local posX = (x + 150 <= w and x) or (x < 0 and 0) or (w - 150)
local posY = (y + 180 <= h and y > 20 and y) or (y < 20 and 25) or (h - 180)
ui.addTextArea(openMapGroundInfoTextAreaId, "<font size='12'>" .. table.concat(info, "\n") .. "</font>", playerName, posX, posY, nil, nil, 0x1A1A1A, 0x000000, 0.8, false)
players[playerName].isPressedShift = false
return
end
end
end
end
end

eventNewGame = function()
ui.removeTextArea(openMapGroundInfoTextAreaId, nil)
PrintText("<J>[MapAnalyzer]</J> Loaded map: <V>" .. tfm.get.room.currentMap .. "</V>")
ExtractMapInfo()
SetMapInfo()
end

eventNewPlayer = function(playerName)
local player = {
name = playerName,
isOpenMapHistory = false,
isPressedCtrl = false,
isPressedShift = false,
isPressedDel = false,
isShaman = false,
isPrivileged = scriptAdmins[playerName] ~= nil
}

players[playerName] = player
if players[playerName].isPrivileged then
system.bindMouse(playerName, true)
system.bindKeyboard(playerName, 16, true, true)
system.bindKeyboard(playerName, 17, true, true)
system.bindKeyboard(playerName, 46, true, true)
end

if screenshot or reviewing then
tfm.exec.killPlayer(playerName, false)
return
end
end

eventPlayerDied = function(playerName)
if not screenshot then
tfm.exec.respawnPlayer(playerName)
end
end

eventPlayerWon = function(playerName, timeElapsed, timeElapsedSinceRespawn)
if reviewing then
local tim = (timeElapsedSinceRespawn or timeElapsed) / 100
PrintText("<J>[MapAnalyzer]</J> The map: <V>" .. tfm.get.room.currentMap .. "</V> is playable. (<ROSE>".. tim .."s</ROSE>)")
reviewing = false
tfm.exec.newGame(tfm.get.room.currentMap)
end
tfm.exec.respawnPlayer(playerName)
end

eventTextAreaCallback = function(id, playerName, callback)
if not players[playerName].isPrivileged then
return
end

if callback == "close_maplist" then
ui.removeTextArea(mapListTextAreaId, playerName)
ui.removeTextArea(closeMapListTextAreaId, playerName)
end
end

-- LIBRARY
function string.split(str, s)
if not str then
return nil
end
local res = {}
for part in string.gmatch(str, "[^" .. s .. "]+") do
table.insert(res, part)
end
return res
end

-- UTILS
function GetXMLValue(str,attribute)
return tonumber(str:match(('%s="([^"]+)"'):format(attribute))) or str:match(('%s="([^"]+)"'):format(attribute)) or str:match(('%s=""'):format(attribute))
end

function ExtractMapInfo()
mapInfo.mapSettings = {}
mapInfo.mapGrounds = {}
mapInfo.holes = {}
mapInfo.cheeses = {}

local xml = tfm.get.room.xmlMapInfo.xml
local wind, gravity = xml:match('<P[^/]+G="([^"]+),([^"]+)"[^/]+/>')

-- Wind
if wind and wind ~= "0" then
table.insert(mapInfo.mapSettings, "Wind: <G>" .. wind .. "</G>")
end

-- Gravity
if gravity and gravity ~= "10" then
table.insert(mapInfo.mapSettings, "Gravity: <G>" .. gravity .. "</G>")
end

-- Flags
mapInfo.mapHeight = tonumber(xml:match('<P[^>]+ H="(%d+)"')) or 400
mapInfo.mapLength = tonumber(xml:match('<P[^>]+ L="(%d+)"')) or 800
for flag, label in pairs({N = "Nightmode", C = "Collision", A = "Soulmate", P = "Portals", aie = "Fall damage", conj = "Conjuration", defilante = "Defilante Mode"}) do
if xml:match('<P[^/]+(' .. flag .. '="")[^/]+/>') then
table.insert(mapInfo.mapSettings, label)
end
end

-- Holes
for x, y in xml:gmatch('<T X="(%d+)" Y="(%d+)" />') do
table.insert(mapInfo.holes, "(X: " .. x .. ", Y: " .. y .. ")")
end

-- Holes
for x, y in xml:gmatch('<T Y="(%d+)" X="(%d+)" />') do
table.insert(mapInfo.holes, "(X: " .. x .. ", Y: " .. y .. ")")
end

-- Cheeses
for x, y in xml:gmatch('<F X="(%d+)" Y="(%d+)" />') do
table.insert(mapInfo.cheeses, "(X: " .. x .. ", Y: " .. y .. ")")
end

-- Cheeses
for x, y in xml:gmatch('<F Y="(%d+)" X="(%d+)" />') do
table.insert(mapInfo.cheeses, "(X: " .. x .. ", Y: " .. y .. ")")
end

-- Map grounds
for ground in xml:gmatch("<S [^/]+/>") do
local P = string.split(GetXMLValue(ground, "P"), ",")
table.insert(mapInfo.mapGrounds, {
id = #mapInfo.mapGrounds+1,
x = GetXMLValue(ground,"X"),
y = GetXMLValue(ground,"Y"),
height = GetXMLValue(ground,"H"),
length = GetXMLValue(ground,"L"),
type = GetXMLValue(ground,"T"),
color = GetXMLValue(ground,"o"),
dynamic = tonumber(P[1]),
mass = tonumber(P[2]),
friction = tonumber(P[3]),
restitution = tonumber(P[4]),
rotation = tonumber(P[5]),
})
end
end

function SetMapInfo()
local author, mapCode, permCode = tfm.get.room.xmlMapInfo.author, tfm.get.room.xmlMapInfo.mapCode, tfm.get.room.xmlMapInfo.permCode
local category = mapCategories[tonumber(permCode)] or "Unknown"

local text = string.format(
"<J><b>Map:</b></J> <V>@%s</V><br>" ..
"<J><b>Author:</b></J> <V>%s</V><br>" ..
"<J><b>Category:</b></J> <V>P%s</V> <G>(%s)</G><br>" ..
"<J><b>Height:</b></J> <V>%s</V><br>" ..
"<J><b>Length:</b></J> <V>%s</V><br>",
mapCode, author, permCode, category, mapInfo.mapHeight, mapInfo.mapLength
)

if #mapInfo.mapSettings > 0 then
text = text .. string.format("<J><b>Flags:</b></J><br>- %s", table.concat(mapInfo.mapSettings, "<br>- "))
end

if #mapInfo.holes > 0 then
text = text .. "<br><J><b>" .. (#mapInfo.holes == 1 and "Hole:" or "Holes:") .. "</b></J> <G>" .. table.concat(mapInfo.holes, " ∨ ") .. "</G>"
end

if #mapInfo.cheeses > 0 then
text = text .. "<br><J><b>" .. (#mapInfo.cheeses == 1 and "Cheese:" or "Cheeses:") .. "</b></J> <G>" .. table.concat(mapInfo.cheeses, " ∨ ") .. "</G>"
end

if reviewing then
text = text .. "<br><J><b>Mode:</b></J> <ROSE>Reviewing Mode</ROSE>"
else
if #savedMaps >= 25 then
table.remove(savedMaps, 1)
end
table.insert(savedMaps, "<N>@" .. mapCode .. "</N> <G>(" .. category .. ")</G>")
end

for admin in pairs(scriptAdmins) do
ui.addTextArea(mapInfoTextAreaId, text, admin, 5, 30, 200, string.len(text) / 2, 0x1A1A1A, 0x000000, 0.8, true)
if players[admin].isOpenMapHistory then
local text = "<J><b>History:</b></J><br>"
text = text .. table.concat(savedMaps, "\n")
ui.updateTextArea(mapListTextAreaId, text, admin)
ui.updateTextArea(closeMapListTextAreaId, "<a href='event:close_maplist'>X</a>", admin)
end
end
end

function PrintText(message, player)
if usePrint then
print(message)
else
tfm.exec.chatMessage(message, player)
end
end

---- MAIN
function Main()
for _, cmd in pairs({"np", "review", "xml", "ss", "sha", "sy", "lsmap", "stop"}) do
system.disableChatCommandDisplay(cmd, true)
end

tfm.exec.disableAfkDeath(true)
tfm.exec.disableAutoNewGame(true)
tfm.exec.disableAllShamanSkills(true)
tfm.exec.disableAutoTimeLeft(true)
tfm.exec.disableAutoShaman(true)
tfm.exec.disablePhysicalConsumables(true)
tfm.exec.disablePrespawnPreview(true)
tfm.exec.disableWatchCommand(true)
tfm.exec.disableMortCommand(true)
tfm.exec.newGame(currentMap)
for name in pairs(tfm.get.room.playerList) do
eventNewPlayer(name)
end
end

Main()

Dernière modification le 1742739720000
Syrius
« Consul »
1742667120000
    • Syrius#8114
    • Profil
    • Derniers messages
    • Tribu
#2
  0
Amazing, would've enjoyed something like this years ago when I was still doing stuff with maps.

I do want to note, however, that your map category list is in need of improvement, there are more categories that you haven't listed - at the top of my head, P32, P43 and P63. Could be more.
Flora
« Citoyen »
1742739780000
    • Flora#9543
    • Profil
    • Derniers messages
    • Tribu
#3
  0
I have no idea what P32 and P63 could be.
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • [Script] MapAnalyzer
© Atelier801 2018

Equipe Conditions Générales d'Utilisation Politique de Confidentialité Contact

Version 1.27