added creative priv
This commit is contained in:
parent
f0f35ef72d
commit
8edc4b4cf1
@ -7,6 +7,11 @@ crafting_guide.form_items = "size[8,7]"..default.gui_colors..default.gui_bg.."bu
|
|||||||
|
|
||||||
crafting_guide.pages = {}
|
crafting_guide.pages = {}
|
||||||
|
|
||||||
|
minetest.register_privilege("creative", {
|
||||||
|
description = "",
|
||||||
|
give_to_singleplayer = false,
|
||||||
|
})
|
||||||
|
|
||||||
function crafting_guide.get_formspec(crafts,back_button)
|
function crafting_guide.get_formspec(crafts,back_button)
|
||||||
local str = crafting_guide.form
|
local str = crafting_guide.form
|
||||||
if back_button then
|
if back_button then
|
||||||
@ -36,9 +41,10 @@ function crafting_guide.get_formspec(crafts,back_button)
|
|||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
|
||||||
function crafting_guide.get_item_formspec(page)
|
function crafting_guide.get_item_formspec(page, player)
|
||||||
page = page or 0
|
page = page or 0
|
||||||
local str = crafting_guide.form_items
|
local str = crafting_guide.form_items
|
||||||
|
local creative_priv = minetest.get_player_privs(player:get_player_name()).creative
|
||||||
|
|
||||||
if page > -1 then
|
if page > -1 then
|
||||||
local i = 0
|
local i = 0
|
||||||
@ -47,13 +53,16 @@ function crafting_guide.get_item_formspec(page)
|
|||||||
|
|
||||||
local items = {}
|
local items = {}
|
||||||
for name,def in pairs(minetest.registered_items) do
|
for name,def in pairs(minetest.registered_items) do
|
||||||
table.insert(items,name)
|
if not(def.groups.not_in_creative_inventory) then
|
||||||
|
table.insert(items,name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
table.sort(items)
|
table.sort(items)
|
||||||
|
|
||||||
for _,name in ipairs(items) do
|
for _,name in ipairs(items) do
|
||||||
if minetest.get_all_craft_recipes(name) and i < (8*6)*(page+1) then
|
if (minetest.get_all_craft_recipes(name) or creative_priv) and
|
||||||
|
i < (8*6)*(page+1) then
|
||||||
if i > (8*6)*(page)-1 then
|
if i > (8*6)*(page)-1 then
|
||||||
str = str .. "item_image_button["..x..","..y..";1,1;"..name..";"..name..";]"
|
str = str .. "item_image_button["..x..","..y..";1,1;"..name..";"..name..";]"
|
||||||
x = x + 1
|
x = x + 1
|
||||||
@ -78,7 +87,7 @@ function crafting_guide.get_item_formspec(page)
|
|||||||
str = str .. "label[0,2;Weapons :]"
|
str = str .. "label[0,2;Weapons :]"
|
||||||
str = str .. "item_image_button[0,2.5;1,1;skills:spear_lvl_1;skills:spear_lvl_1;]"
|
str = str .. "item_image_button[0,2.5;1,1;skills:spear_lvl_1;skills:spear_lvl_1;]"
|
||||||
str = str .. "item_image_button[1,2.5;1,1;skills:sword_lvl_20;skills:sword_lvl_20;]"
|
str = str .. "item_image_button[1,2.5;1,1;skills:sword_lvl_20;skills:sword_lvl_20;]"
|
||||||
str = str .. "item_image_button[2,2.5;1,1;skills:bow;skills:bow_lvl_1;]"
|
str = str .. "item_image_button[2,2.5;1,1;skills:bow_lvl_1;skills:bow_lvl_1;]"
|
||||||
|
|
||||||
str = str .. "label[0,4;Furnace :]"
|
str = str .. "label[0,4;Furnace :]"
|
||||||
str = str .. "item_image_button[0,4.5;1,1;furnace:furnace;furnace:furnace;]"
|
str = str .. "item_image_button[0,4.5;1,1;furnace:furnace;furnace:furnace;]"
|
||||||
@ -129,7 +138,7 @@ end
|
|||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if formname == "crafting_guide:book" then
|
if formname == "crafting_guide:book" then
|
||||||
if fields.btn_back then
|
if fields.btn_back then
|
||||||
minetest.show_formspec(player:get_player_name(), "crafting_guide:book_items", crafting_guide.get_item_formspec(crafting_guide.pages[player:get_player_name()]))
|
minetest.show_formspec(player:get_player_name(), "crafting_guide:book_items", crafting_guide.get_item_formspec(crafting_guide.pages[player:get_player_name()], player))
|
||||||
elseif fields.quit then
|
elseif fields.quit then
|
||||||
crafting_guide.pages[player:get_player_name()] = nil
|
crafting_guide.pages[player:get_player_name()] = nil
|
||||||
else
|
else
|
||||||
@ -144,10 +153,10 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
if formname == "crafting_guide:book_items" then
|
if formname == "crafting_guide:book_items" then
|
||||||
if fields.btn_left then
|
if fields.btn_left then
|
||||||
crafting_guide.pages[player:get_player_name()] = crafting_guide.pages[player:get_player_name()] -1
|
crafting_guide.pages[player:get_player_name()] = crafting_guide.pages[player:get_player_name()] -1
|
||||||
minetest.show_formspec(player:get_player_name(), "crafting_guide:book_items", crafting_guide.get_item_formspec(crafting_guide.pages[player:get_player_name()]))
|
minetest.show_formspec(player:get_player_name(), "crafting_guide:book_items", crafting_guide.get_item_formspec(crafting_guide.pages[player:get_player_name()], player))
|
||||||
elseif fields.btn_right then
|
elseif fields.btn_right then
|
||||||
crafting_guide.pages[player:get_player_name()] = crafting_guide.pages[player:get_player_name()] +1
|
crafting_guide.pages[player:get_player_name()] = crafting_guide.pages[player:get_player_name()] +1
|
||||||
minetest.show_formspec(player:get_player_name(), "crafting_guide:book_items", crafting_guide.get_item_formspec(crafting_guide.pages[player:get_player_name()]))
|
minetest.show_formspec(player:get_player_name(), "crafting_guide:book_items", crafting_guide.get_item_formspec(crafting_guide.pages[player:get_player_name()], player))
|
||||||
elseif fields.btn_quests then
|
elseif fields.btn_quests then
|
||||||
minetest.show_formspec(player:get_player_name(), "quests:show_quests", quests.get_formspec(player:get_player_name()))
|
minetest.show_formspec(player:get_player_name(), "quests:show_quests", quests.get_formspec(player:get_player_name()))
|
||||||
elseif fields.quit then
|
elseif fields.quit then
|
||||||
@ -155,8 +164,14 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
else
|
else
|
||||||
for i,j in pairs(fields) do
|
for i,j in pairs(fields) do
|
||||||
local crafts = minetest.get_all_craft_recipes(i)
|
local crafts = minetest.get_all_craft_recipes(i)
|
||||||
if crafts then
|
local has_creative_priv = minetest.get_player_privs(player:get_player_name()).creative
|
||||||
minetest.show_formspec(player:get_player_name(), "crafting_guide:book", crafting_guide.get_formspec(crafts,true))
|
if crafts or has_creative_priv then
|
||||||
|
if has_creative_priv then
|
||||||
|
player:get_inventory():add_item("main", i .. " 99")
|
||||||
|
print("[crafting_guide] give " .. player:get_player_name() .. " " .. i .. " 99")
|
||||||
|
else
|
||||||
|
minetest.show_formspec(player:get_player_name(), "crafting_guide:book", crafting_guide.get_formspec(crafts,true))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -185,6 +200,6 @@ minetest.register_craftitem("crafting_guide:book", {
|
|||||||
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
crafting_guide.pages[user:get_player_name()] = 0
|
crafting_guide.pages[user:get_player_name()] = 0
|
||||||
minetest.show_formspec(user:get_player_name(), "crafting_guide:book_items", crafting_guide.get_item_formspec(0))
|
minetest.show_formspec(user:get_player_name(), "crafting_guide:book_items", crafting_guide.get_item_formspec(0, user))
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -350,6 +350,8 @@ minetest.register_node("default:log", {
|
|||||||
tiles = {"default_log_top.png","default_log_top.png","default_log.png"},
|
tiles = {"default_log_top.png","default_log_top.png","default_log.png"},
|
||||||
groups = {choppy = 3},
|
groups = {choppy = 3},
|
||||||
sounds = default.sounds.wood(),
|
sounds = default.sounds.wood(),
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
on_place = minetest.rotate_and_place,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("default:log_1", {
|
minetest.register_node("default:log_1", {
|
||||||
@ -362,10 +364,12 @@ minetest.register_node("default:log_1", {
|
|||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.4, -0.5, -0.4, 0.4, 0.5, 0.4},
|
{-6/16, -0.5, -6/16, 6/16, 0.5, 6/16},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sounds = default.sounds.wood(),
|
sounds = default.sounds.wood(),
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
on_place = minetest.rotate_and_place,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("default:log_2", {
|
minetest.register_node("default:log_2", {
|
||||||
@ -378,10 +382,12 @@ minetest.register_node("default:log_2", {
|
|||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.3, -0.5, -0.3, 0.3, 0.5, 0.3},
|
{-4/16, -0.5, -4/16, 4/16, 0.5, 4/16},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sounds = default.sounds.wood(),
|
sounds = default.sounds.wood(),
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
on_place = minetest.rotate_and_place,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("default:log_3", {
|
minetest.register_node("default:log_3", {
|
||||||
@ -394,10 +400,12 @@ minetest.register_node("default:log_3", {
|
|||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.2, -0.5, -0.2, 0.2, 0.5, 0.2},
|
{-2/16, -0.5, -2/16, 2/16, 0.5, 2/16},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sounds = default.sounds.wood(),
|
sounds = default.sounds.wood(),
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
on_place = minetest.rotate_and_place,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("default:jungle_tree", {
|
minetest.register_node("default:jungle_tree", {
|
||||||
@ -405,6 +413,8 @@ minetest.register_node("default:jungle_tree", {
|
|||||||
tiles = {"default_jungle_tree_top.png", "default_jungle_tree_top.png", "default_jungle_tree.png"},
|
tiles = {"default_jungle_tree_top.png", "default_jungle_tree_top.png", "default_jungle_tree.png"},
|
||||||
groups = {choppy = 3},
|
groups = {choppy = 3},
|
||||||
sounds = default.sounds.wood(),
|
sounds = default.sounds.wood(),
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
on_place = minetest.rotate_and_place,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- plants
|
-- plants
|
||||||
@ -888,7 +898,7 @@ minetest.register_node("default:rail", {
|
|||||||
wield_image = "default_rail.png",
|
wield_image = "default_rail.png",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
walkable = false,
|
walkable = false,
|
||||||
groups = {choppy = 1, attached_node = 1},
|
groups = {choppy = 1, cracky= 1, attached_node = 1},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- fences
|
-- fences
|
||||||
|
Loading…
x
Reference in New Issue
Block a user