2017-01-05 23:37:40 +01:00
|
|
|
crafting = {}
|
|
|
|
crafting.creative_inventory_size = 0
|
|
|
|
|
2017-01-24 21:18:42 +01:00
|
|
|
-- Prepare player info table
|
|
|
|
local players = {}
|
|
|
|
|
|
|
|
minetest.register_on_joinplayer(function(player)
|
|
|
|
local name = player:get_player_name()
|
|
|
|
if not players[name] then
|
|
|
|
players[name] = {}
|
|
|
|
players[name].page = "nix"
|
|
|
|
players[name].filter = ""
|
|
|
|
players[name].start_i = 0
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2017-01-24 02:31:49 +01:00
|
|
|
local function set_inv(filter, player)
|
2017-01-05 23:37:40 +01:00
|
|
|
local inv = minetest.get_inventory({type="detached", name="creative"})
|
|
|
|
inv:set_size("main", 0)
|
|
|
|
local creative_list = {}
|
|
|
|
for name,def in pairs(minetest.registered_items) do
|
|
|
|
if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0) and def.description and def.description ~= "" then
|
|
|
|
if filter ~= "" then
|
2017-01-20 04:54:09 +01:00
|
|
|
local is_redstone = function(def)
|
|
|
|
return def.mesecons or def.groups.mesecon or def.groups.mesecon_conductor_craftable or def.groups.mesecon_effecor_off
|
|
|
|
end
|
|
|
|
local is_tool = function(def)
|
|
|
|
return def.groups.tool or (def.tool_capabilities ~= nil and def.tool_capabilities.damage_groups == nil)
|
|
|
|
end
|
|
|
|
local is_weapon = function(def)
|
|
|
|
return def.groups.weapon or def.groups.weapon_ranged or def.groups.ammo or def.groups.armor_head or def.groups.armor_torso or def.groups.armor_legs or def.groups.armor_feet
|
|
|
|
end
|
2017-01-24 21:22:23 +01:00
|
|
|
if filter == "\0blocks" then
|
2017-01-20 04:54:09 +01:00
|
|
|
if def.groups.building_block then
|
2017-01-05 23:37:40 +01:00
|
|
|
table.insert(creative_list, name)
|
|
|
|
end
|
2017-01-24 21:22:23 +01:00
|
|
|
elseif filter == "\0deco" then
|
2017-01-20 04:54:09 +01:00
|
|
|
if def.groups.deco_block then
|
2017-01-05 23:37:40 +01:00
|
|
|
table.insert(creative_list, name)
|
|
|
|
end
|
2017-01-24 21:22:23 +01:00
|
|
|
elseif filter == "\0redstone" then
|
2017-01-20 04:54:09 +01:00
|
|
|
if is_redstone(def) then
|
2017-01-05 23:37:40 +01:00
|
|
|
table.insert(creative_list, name)
|
|
|
|
end
|
2017-01-24 21:22:23 +01:00
|
|
|
elseif filter == "\0rail" then
|
2017-01-20 04:54:09 +01:00
|
|
|
if def.groups.transport then
|
2017-01-05 23:37:40 +01:00
|
|
|
table.insert(creative_list, name)
|
|
|
|
end
|
2017-01-24 21:22:23 +01:00
|
|
|
elseif filter == "\0food" then
|
2017-01-16 14:29:41 +01:00
|
|
|
if def.groups.food or def.groups.eatable then
|
2017-01-05 23:37:40 +01:00
|
|
|
table.insert(creative_list, name)
|
|
|
|
end
|
2017-01-24 21:22:23 +01:00
|
|
|
elseif filter == "\0tools" then
|
2017-01-20 04:54:09 +01:00
|
|
|
if is_tool(def) then
|
2017-01-05 23:37:40 +01:00
|
|
|
table.insert(creative_list, name)
|
|
|
|
end
|
2017-01-24 21:22:23 +01:00
|
|
|
elseif filter == "\0combat" then
|
2017-01-20 04:54:09 +01:00
|
|
|
if is_weapon(def) then
|
2017-01-05 23:37:40 +01:00
|
|
|
table.insert(creative_list, name)
|
|
|
|
end
|
2017-01-24 21:22:23 +01:00
|
|
|
elseif filter == "\0brew" then
|
2017-01-23 00:02:58 +01:00
|
|
|
if def.groups.brewitem then
|
|
|
|
table.insert(creative_list, name)
|
|
|
|
end
|
2017-01-24 21:22:23 +01:00
|
|
|
elseif filter == "\0matr" then
|
2017-01-23 00:02:58 +01:00
|
|
|
if def.groups.craftitem then
|
2017-01-20 04:54:09 +01:00
|
|
|
table.insert(creative_list, name)
|
|
|
|
end
|
2017-01-24 21:22:23 +01:00
|
|
|
elseif filter == "\0misc" then
|
2017-01-20 04:54:09 +01:00
|
|
|
if not def.groups.building_block and not def.groups.deco_block and not is_redstone(def) and not def.groups.transport and not def.groups.food and not def.groups.eatable and not is_tool(def) and not is_weapon(def) and not def.groups.craftitem and not def.groups.brewitem then
|
|
|
|
|
2017-01-05 23:37:40 +01:00
|
|
|
table.insert(creative_list, name)
|
|
|
|
end
|
2017-01-24 21:22:23 +01:00
|
|
|
elseif filter == "\0all" then
|
2017-01-05 23:37:40 +01:00
|
|
|
table.insert(creative_list, name)
|
|
|
|
else --for all other
|
|
|
|
if string.find(string.lower(def.name), filter) or string.find(string.lower(def.description), filter) then
|
|
|
|
table.insert(creative_list, name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
table.sort(creative_list)
|
|
|
|
inv:set_size("main", #creative_list)
|
|
|
|
for _,itemstring in ipairs(creative_list) do
|
|
|
|
inv:add_item("main", ItemStack(itemstring))
|
|
|
|
end
|
|
|
|
crafting.creative_inventory_size = #creative_list
|
|
|
|
--print("creative inventory size: "..dump(crafting.creative_inventory_size))
|
|
|
|
end
|
|
|
|
|
2017-01-24 02:31:49 +01:00
|
|
|
local function init()
|
|
|
|
local inv = minetest.create_detached_inventory("creative", {
|
|
|
|
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
|
|
|
if minetest.setting_getbool("creative_mode") then
|
|
|
|
return count
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
allow_put = function(inv, listname, index, stack, player)
|
|
|
|
return 0
|
|
|
|
end,
|
|
|
|
allow_take = function(inv, listname, index, stack, player)
|
|
|
|
if minetest.setting_getbool("creative_mode") then
|
|
|
|
return -1
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
on_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
|
|
|
end,
|
|
|
|
on_put = function(inv, listname, index, stack, player)
|
|
|
|
end,
|
|
|
|
on_take = function(inv, listname, index, stack, player)
|
|
|
|
print(player:get_player_name().." takes item from creative inventory; listname="..dump(listname)..", index="..dump(index)..", stack="..dump(stack))
|
|
|
|
if stack then
|
|
|
|
print("stack:get_name()="..dump(stack:get_name())..", stack:get_count()="..dump(stack:get_count()))
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
2017-01-24 21:22:23 +01:00
|
|
|
set_inv("\0all")
|
2017-01-24 02:31:49 +01:00
|
|
|
end
|
|
|
|
|
2017-01-05 23:37:40 +01:00
|
|
|
-- Create the trash field
|
|
|
|
local trash = minetest.create_detached_inventory("creative_trash", {
|
|
|
|
allow_put = function(inv, listname, index, stack, player)
|
|
|
|
if minetest.setting_getbool("creative_mode") then
|
|
|
|
return stack:get_count()
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
on_put = function(inv, listname, index, stack, player)
|
|
|
|
inv:set_stack(listname, index, "")
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
trash:set_size("main", 1)
|
|
|
|
|
|
|
|
|
|
|
|
-- Create detached creative inventory after loading all mods
|
|
|
|
minetest.after(0, init)
|
|
|
|
|
2017-01-24 12:45:37 +01:00
|
|
|
local noffset = {} -- numeric tab offset
|
|
|
|
local offset = {} -- string offset:
|
|
|
|
local boffset = {} --
|
2017-01-05 23:37:40 +01:00
|
|
|
local hoch = {}
|
|
|
|
local bg = {}
|
2017-01-24 12:45:37 +01:00
|
|
|
|
|
|
|
noffset["blocks"] = {-0.29,-0.25}
|
|
|
|
noffset["deco"] = {0.98,-0.25}
|
|
|
|
noffset["redstone"] = {2.23,-0.25}
|
|
|
|
noffset["rail"] = {3.495,-0.25}
|
|
|
|
noffset["misc"] = {4.75,-0.25}
|
|
|
|
noffset["nix"] = {8.99,-0.25}
|
|
|
|
noffset["food"] = {-0.29,8.12}
|
|
|
|
noffset["tools"] = {0.98,8.12}
|
|
|
|
noffset["combat"] = {2.23,8.12}
|
|
|
|
noffset["brew"] = {3.495,8.12}
|
|
|
|
noffset["matr"] = {4.74,8.12}
|
|
|
|
noffset["inv"] = {8.99,8.12}
|
|
|
|
|
|
|
|
for k,v in pairs(noffset) do
|
|
|
|
offset[k] = tostring(v[1]) .. "," .. tostring(v[2])
|
|
|
|
boffset[k] = tostring(v[1]+0.19) .. "," .. tostring(v[2]+0.25)
|
|
|
|
end
|
2017-01-05 23:37:40 +01:00
|
|
|
|
|
|
|
hoch["blocks"] = ""
|
|
|
|
hoch["deco"] = ""
|
2017-01-09 13:54:02 +01:00
|
|
|
hoch["redstone"] = ""
|
2017-01-05 23:37:40 +01:00
|
|
|
hoch["rail"] = ""
|
|
|
|
hoch["misc"] = ""
|
|
|
|
hoch["nix"] = ""
|
2017-01-22 23:56:10 +01:00
|
|
|
hoch["default"] = ""
|
2017-01-05 23:37:40 +01:00
|
|
|
hoch["food"] = "^[transformfy"
|
|
|
|
hoch["tools"] = "^[transformfy"
|
|
|
|
hoch["combat"] = "^[transformfy"
|
|
|
|
hoch["brew"] = "^[transformfy"
|
|
|
|
hoch["matr"] = "^[transformfy"
|
|
|
|
hoch["inv"] = "^[transformfy"
|
|
|
|
|
|
|
|
local dark_bg = "crafting_creative_bg_dark.png"
|
|
|
|
|
|
|
|
local function reset_menu_item_bg()
|
|
|
|
bg["blocks"] = dark_bg
|
|
|
|
bg["deco"] = dark_bg
|
2017-01-09 13:54:02 +01:00
|
|
|
bg["redstone"] = dark_bg
|
2017-01-05 23:37:40 +01:00
|
|
|
bg["rail"] = dark_bg
|
|
|
|
bg["misc"] = dark_bg
|
|
|
|
bg["nix"] = dark_bg
|
|
|
|
bg["food"] = dark_bg
|
|
|
|
bg["tools"] = dark_bg
|
|
|
|
bg["combat"] = dark_bg
|
|
|
|
bg["brew"] = dark_bg
|
|
|
|
bg["matr"] = dark_bg
|
|
|
|
bg["inv"] = dark_bg
|
2017-01-22 23:56:10 +01:00
|
|
|
bg["default"] = dark_bg
|
2017-01-05 23:37:40 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2017-01-23 00:33:01 +01:00
|
|
|
crafting.set_creative_formspec = function(player, start_i, pagenum, show, page, filter)
|
2017-01-05 23:37:40 +01:00
|
|
|
reset_menu_item_bg()
|
|
|
|
pagenum = math.floor(pagenum) or 1
|
|
|
|
local pagemax = math.floor((crafting.creative_inventory_size-1) / (9*5) + 1)
|
2017-01-24 22:19:42 +01:00
|
|
|
local slider_height
|
|
|
|
if pagemax == 1 then
|
|
|
|
slider_height = 4.525
|
|
|
|
else
|
|
|
|
slider_height = 4/pagemax
|
|
|
|
end
|
|
|
|
local slider_pos = slider_height*(pagenum-1)+2.20
|
2017-01-05 23:37:40 +01:00
|
|
|
local name = "nix"
|
|
|
|
local formspec = ""
|
2017-01-24 08:50:31 +01:00
|
|
|
local main_list
|
2017-01-06 01:31:04 +01:00
|
|
|
local listrings = "listring[detached:creative;main]"..
|
|
|
|
"listring[current_player;main]"..
|
|
|
|
"listring[detached:creative_trash;main]"
|
|
|
|
|
2017-01-05 23:37:40 +01:00
|
|
|
if page ~= nil then name = page end
|
|
|
|
bg[name] = "crafting_creative_bg.png"
|
2017-01-24 08:58:52 +01:00
|
|
|
local inv_bg = "crafting_inventory_creative.png"
|
2017-01-05 23:37:40 +01:00
|
|
|
if name == "inv" then
|
2017-01-24 08:50:31 +01:00
|
|
|
-- Survival inventory slots
|
2017-01-05 23:37:40 +01:00
|
|
|
main_list = "image[-0.2,1.7;11.35,2.33;crafting_creative_bg.png]"..
|
|
|
|
"list[current_player;main;0,3.75;9,3;9]"
|
2017-01-24 08:50:31 +01:00
|
|
|
else
|
2017-01-24 08:58:52 +01:00
|
|
|
inv_bg = inv_bg .. "^crafting_inventory_creative_scroll.png"
|
2017-01-24 08:50:31 +01:00
|
|
|
-- Creative inventory slots
|
|
|
|
main_list = "list[detached:creative;main;0,1.75;9,5;"..tostring(start_i).."]" ..
|
|
|
|
-- ... and scroll bar
|
|
|
|
"image_button[9.03,1.74;0.85,0.6;crafting_creative_up.png;creative_prev;]"..
|
|
|
|
"image[9.04," .. tostring(slider_pos) .. ";0.75,"..tostring(slider_height) .. ";crafting_slider.png]"..
|
|
|
|
"image_button[9.03,6.15;0.85,0.6;crafting_creative_down.png;creative_next;]"
|
2017-01-05 23:37:40 +01:00
|
|
|
end
|
2017-01-22 23:56:10 +01:00
|
|
|
local function tab(current, check)
|
|
|
|
local img
|
|
|
|
if current == check then
|
|
|
|
img = "crafting_creative_active.png"
|
|
|
|
else
|
|
|
|
img = "crafting_creative_inactive.png"
|
|
|
|
end
|
2017-01-24 12:45:37 +01:00
|
|
|
return "image[" .. offset[check] .. ";1.5,1.44;" .. img .. hoch[check].. "]" ..
|
|
|
|
"image[" .. boffset[check] .. ";1,1;crafting_creative_marker.png]"
|
2017-01-22 23:56:10 +01:00
|
|
|
end
|
2017-01-05 23:37:40 +01:00
|
|
|
formspec = "size[10,9.3]"..
|
2017-01-06 01:32:38 +01:00
|
|
|
default.inventory_header..
|
2017-01-24 08:58:52 +01:00
|
|
|
"background[-0.19,-0.25;10.5,9.87;"..inv_bg.."]"..
|
2017-01-05 23:37:40 +01:00
|
|
|
"label[-5,-5;"..name.."]"..
|
2017-01-22 23:56:10 +01:00
|
|
|
"item_image_button[-0.1,0;1,1;default:brick;blocks;]".. --build blocks
|
|
|
|
tab(name, "blocks") ..
|
|
|
|
"tooltip[blocks;Building Blocks]"..
|
2017-01-22 17:42:41 +01:00
|
|
|
"item_image_button[1.15,0;1,1;flowers:peony;deco;]".. --decoration blocks
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "deco") ..
|
2017-01-22 17:42:41 +01:00
|
|
|
"tooltip[deco;Decoration Blocks]"..
|
|
|
|
"item_image_button[2.415,0;1,1;mesecons:redstone;redstone;]".. --redstone
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "redstone") ..
|
2017-01-22 17:42:41 +01:00
|
|
|
"tooltip[redstone;Redstone]"..
|
|
|
|
"item_image_button[3.693,0;1,1;mcl_minecarts:golden_rail;rail;]".. --transportation
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "rail") ..
|
2017-01-22 17:42:41 +01:00
|
|
|
"tooltip[rail;Transportation]"..
|
|
|
|
"item_image_button[4.93,0;1,1;bucket:bucket_lava;misc;]".. --miscellaneous
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "misc") ..
|
2017-01-22 17:42:41 +01:00
|
|
|
"tooltip[misc;Miscellaneous]"..
|
2017-01-22 23:56:10 +01:00
|
|
|
"item_image_button[9.19,0;1,1;mcl_compass:compass;nix;]".. --search
|
|
|
|
tab(name, "nix") ..
|
|
|
|
"tooltip[nix;Search Items]"..
|
2017-01-05 23:37:40 +01:00
|
|
|
"image[0,1;5,0.75;fnt_"..name..".png]"..
|
|
|
|
"list[current_player;main;0,7;9,1;]"..
|
|
|
|
main_list..
|
2017-01-24 12:45:37 +01:00
|
|
|
"item_image_button[-0.1,8.37;1,1;default:apple;food;]".. --foodstuff
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "food") ..
|
2017-01-22 17:42:41 +01:00
|
|
|
"tooltip[food;Foodstuffs]"..
|
2017-01-24 12:45:37 +01:00
|
|
|
"item_image_button[1.15,8.37;1,1;default:axe_steel;tools;]".. --tools
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "tools") ..
|
2017-01-22 17:42:41 +01:00
|
|
|
"tooltip[tools;Tools]"..
|
2017-01-24 12:45:37 +01:00
|
|
|
"item_image_button[2.415,8.37;1,1;default:sword_gold;combat;]".. --combat
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "combat") ..
|
2017-01-22 17:42:41 +01:00
|
|
|
"tooltip[combat;Combat]"..
|
2017-01-24 12:45:37 +01:00
|
|
|
"item_image_button[3.693,8.37;1,1;mcl_potions:glass_bottle;brew;]".. --brewing
|
2017-01-23 00:02:58 +01:00
|
|
|
tab(name, "brew") ..
|
|
|
|
"tooltip[brew;Brewing]"..
|
2017-01-24 12:45:37 +01:00
|
|
|
"item_image_button[4.938,8.37;1,1;default:stick;matr;]".. --materials
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "matr") ..
|
2017-01-22 17:42:41 +01:00
|
|
|
"tooltip[matr;Materials]"..
|
2017-01-24 12:45:37 +01:00
|
|
|
"item_image_button[9.19,8.37;1,1;default:chest;inv;]".. --inventory
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "inv") ..
|
2017-01-22 17:42:41 +01:00
|
|
|
"tooltip[inv;Survival Inventory]"..
|
2017-01-05 23:37:40 +01:00
|
|
|
"list[detached:creative_trash;main;9,7;1,1;]"..
|
2017-01-06 01:31:04 +01:00
|
|
|
"image[9,7;1,1;crafting_creative_trash.png]"..
|
|
|
|
listrings
|
2017-01-05 23:37:40 +01:00
|
|
|
|
2017-01-23 00:33:01 +01:00
|
|
|
if name == "nix" then
|
|
|
|
if filter == nil then
|
|
|
|
filter = ""
|
|
|
|
end
|
2017-01-24 21:23:30 +01:00
|
|
|
formspec = formspec .. "field[5.3,1.3;4,0.75;suche;;"..minetest.formspec_escape(filter).."]"
|
2017-01-23 00:33:01 +01:00
|
|
|
formspec = formspec .. "field_close_on_enter[suche;false]"
|
|
|
|
end
|
2017-01-05 23:37:40 +01:00
|
|
|
if pagenum ~= nil then formspec = formspec .. "p"..tostring(pagenum) end
|
|
|
|
|
|
|
|
player:set_inventory_formspec(formspec)
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|
|
|
local page = nil
|
|
|
|
if not minetest.setting_getbool("creative_mode") then
|
|
|
|
return
|
|
|
|
end
|
2017-01-23 00:33:01 +01:00
|
|
|
|
2017-01-24 21:18:42 +01:00
|
|
|
local name = player:get_player_name()
|
2017-01-24 21:58:11 +01:00
|
|
|
|
2017-01-22 23:56:10 +01:00
|
|
|
if fields.blocks then
|
2017-01-24 21:22:23 +01:00
|
|
|
set_inv("\0blocks",player)
|
2017-01-05 23:37:40 +01:00
|
|
|
page = "blocks"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.deco then
|
2017-01-24 21:22:23 +01:00
|
|
|
set_inv("\0deco",player)
|
2017-01-05 23:37:40 +01:00
|
|
|
page = "deco"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.redstone then
|
2017-01-24 21:22:23 +01:00
|
|
|
set_inv("\0redstone",player)
|
2017-01-09 13:54:02 +01:00
|
|
|
page = "redstone"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.rail then
|
2017-01-24 21:22:23 +01:00
|
|
|
set_inv("\0rail",player)
|
2017-01-05 23:37:40 +01:00
|
|
|
page = "rail"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.misc then
|
2017-01-24 21:22:23 +01:00
|
|
|
set_inv("\0misc",player)
|
2017-01-05 23:37:40 +01:00
|
|
|
page = "misc"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.nix then
|
2017-01-24 21:22:23 +01:00
|
|
|
set_inv("\0all",player)
|
2017-01-23 00:33:01 +01:00
|
|
|
page = "nix"
|
|
|
|
elseif fields.food then
|
2017-01-24 21:22:23 +01:00
|
|
|
set_inv("\0food",player)
|
2017-01-05 23:37:40 +01:00
|
|
|
page = "food"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.tools then
|
2017-01-24 21:22:23 +01:00
|
|
|
set_inv("\0tools",player)
|
2017-01-05 23:37:40 +01:00
|
|
|
page = "tools"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.combat then
|
2017-01-24 21:22:23 +01:00
|
|
|
set_inv("\0combat",player)
|
2017-01-05 23:37:40 +01:00
|
|
|
page = "combat"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.brew then
|
2017-01-24 21:22:23 +01:00
|
|
|
set_inv("\0brew",player)
|
2017-01-23 00:02:58 +01:00
|
|
|
page = "brew"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.matr then
|
2017-01-24 21:22:23 +01:00
|
|
|
set_inv("\0matr",player)
|
2017-01-05 23:37:40 +01:00
|
|
|
page = "matr"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.inv then
|
2017-01-05 23:37:40 +01:00
|
|
|
page = "inv"
|
2017-01-24 21:58:11 +01:00
|
|
|
elseif fields.suche == "" and not fields.creative_next and not fields.creative_prev then
|
2017-01-24 21:22:23 +01:00
|
|
|
set_inv("\0all", player)
|
2017-01-23 00:33:01 +01:00
|
|
|
page = "nix"
|
2017-01-24 21:58:11 +01:00
|
|
|
elseif fields.suche ~= nil and not fields.creative_next and not fields.creative_prev then
|
2017-01-23 00:33:01 +01:00
|
|
|
set_inv(string.lower(fields.suche),player)
|
|
|
|
page = "nix"
|
2017-01-05 23:37:40 +01:00
|
|
|
end
|
2017-01-24 21:18:42 +01:00
|
|
|
|
|
|
|
if page then
|
|
|
|
players[name].page = page
|
|
|
|
end
|
|
|
|
if players[name].page then
|
|
|
|
page = players[name].page
|
|
|
|
end
|
|
|
|
|
2017-01-05 23:37:40 +01:00
|
|
|
-- Figure out current page from formspec
|
|
|
|
local formspec = player:get_inventory_formspec()
|
|
|
|
|
|
|
|
local size = string.len(formspec)
|
2017-01-24 21:18:42 +01:00
|
|
|
local start_i = players[name].start_i
|
2017-01-05 23:37:40 +01:00
|
|
|
if fields.creative_prev then
|
|
|
|
start_i = start_i - 9*5
|
|
|
|
end
|
|
|
|
if fields.creative_next then
|
|
|
|
start_i = start_i + 9*5
|
|
|
|
end
|
|
|
|
if start_i < 0 then
|
|
|
|
start_i = start_i + 9*5
|
|
|
|
end
|
|
|
|
if start_i >= crafting.creative_inventory_size then
|
|
|
|
start_i = start_i - 9*5
|
|
|
|
end
|
|
|
|
if start_i < 0 or start_i >= crafting.creative_inventory_size then
|
|
|
|
start_i = 0
|
|
|
|
end
|
2017-01-24 21:18:42 +01:00
|
|
|
players[name].start_i = start_i
|
2017-01-23 00:33:01 +01:00
|
|
|
|
|
|
|
local filter
|
|
|
|
if fields.suche ~= nil and fields.suche ~= "" then
|
|
|
|
filter = fields.suche
|
2017-01-24 21:18:42 +01:00
|
|
|
players[name].filter = filter
|
2017-01-23 00:33:01 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
crafting.set_creative_formspec(player, start_i, start_i / (9*5) + 1, false, page, filter)
|
2017-01-05 23:37:40 +01:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
if minetest.setting_getbool("creative_mode") then
|
|
|
|
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
|
|
|
|
return true
|
|
|
|
end)
|
|
|
|
|
|
|
|
function minetest.handle_node_drops(pos, drops, digger)
|
|
|
|
if not digger or not digger:is_player() then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local inv = digger:get_inventory()
|
|
|
|
if inv then
|
|
|
|
for _,item in ipairs(drops) do
|
|
|
|
item = ItemStack(item):get_name()
|
|
|
|
if not inv:contains_item("main", item) then
|
|
|
|
inv:add_item("main", item)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|