From 8fed69703f40eb837fa23106de3dfdde6e6fbfc3 Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 25 Mar 2022 23:31:49 +0100 Subject: [PATCH] gallery: add cube option /gallerycube --- node_gallery/init.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/node_gallery/init.lua b/node_gallery/init.lua index e8acefb..afc67f3 100644 --- a/node_gallery/init.lua +++ b/node_gallery/init.lua @@ -7,6 +7,27 @@ local function generate_gallery(pos) 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", @@ -15,3 +36,11 @@ minetest.register_chatcommand("gallery",{ 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})