mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-24 17:50:37 +01:00
Added dumpnodes mod
- Added dumpnodes mod, creating /dumpnodes command which can be used by admins to drop the nodenames and top tiles' images for every node on the server in the aim of beginning a process designed to generate automatically the colors.txt file needed by minetestmapper
This commit is contained in:
parent
2ffbab6556
commit
40c624c832
50
mods/dumpnodes/init.lua
Normal file
50
mods/dumpnodes/init.lua
Normal file
@ -0,0 +1,50 @@
|
||||
local function nd_get_tiles(nd)
|
||||
if nd.tiles then
|
||||
return nd.tiles
|
||||
elseif nd.tile_images then
|
||||
return nd.tile_images
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("dumpnodes", {
|
||||
params = "",
|
||||
description = "",
|
||||
privs = {server = true},
|
||||
func = function(plname, param)
|
||||
local n = 0
|
||||
local ntbl = {}
|
||||
for nn, nd in pairs(minetest.registered_nodes) do
|
||||
local prefix, name = nn:match('(.*):(.*)')
|
||||
if prefix == nil or name == nil or prefix == '' or name == '' then
|
||||
-- nothing
|
||||
else
|
||||
if ntbl[prefix] == nil then
|
||||
ntbl[prefix] = {}
|
||||
end
|
||||
ntbl[prefix][name] = nd
|
||||
end
|
||||
end
|
||||
local out, err = io.open('nodes.txt', 'wb')
|
||||
if not out then
|
||||
return minetest.chat_send_player(plname, 'io.open: ' .. err)
|
||||
end
|
||||
for prefix, i in pairs(ntbl) do
|
||||
out:write('# ' .. prefix .. '\n')
|
||||
for name, nd in pairs(i) do
|
||||
if nd.drawtype ~= 'airlike' and nd_get_tiles(nd) ~= nil then
|
||||
local tl = nd_get_tiles(nd)[1]
|
||||
if type(tl) == 'table' then
|
||||
tl = tl.name
|
||||
end
|
||||
tl = (tl .. '^'):match('(.-)^')
|
||||
out:write(prefix .. ':' .. name .. ' ' .. tl .. '\n')
|
||||
n = n + 1
|
||||
end
|
||||
end
|
||||
out:write('\n')
|
||||
end
|
||||
out:close()
|
||||
minetest.chat_send_player(plname, n .. " nodes dumped.")
|
||||
end,
|
||||
})
|
Loading…
Reference in New Issue
Block a user