mcl_devtest/node_gallery/init.lua

47 lines
1.1 KiB
Lua

local length = 50
local function generate_gallery(pos)
local i=1
for n,node in pairs(minetest.registered_nodes) do
minetest.set_node(vector.add(pos,vector.new(i % length,math.ceil(i / length),0)),{name=n})
i = i + 1
end
end
local function generate_gallery_cube(pos)
local i=1
local j=1
local x=1
local y=1
local z=1
local length=10
for n,node in pairs(minetest.registered_nodes) do
minetest.set_node(vector.add(pos,vector.new(x,y,z)),{name=n})
if x > length then
x = 1
z = z + 1
else
x = x + 1
end
if z > length then
y = y + 1
z = 1
end
end
end
minetest.register_chatcommand("gallery",{
description="Generates a wall of all registered nodes next to the player",
privs={debug=true},
func=function(name,p)
local pl=minetest.get_player_by_name(name)
generate_gallery(vector.add(pl:get_pos(),vector.new(0,0,5)))
end})
minetest.register_chatcommand("gallerycube",{
description="Generates a cube of all registered nodes next to the player",
privs={debug=true},
func=function(name,p)
local pl=minetest.get_player_by_name(name)
generate_gallery_cube(vector.add(pl:get_pos(),vector.new(0,0,5)))
end})