2019-03-07 21:10:39 +01:00
|
|
|
local S = minetest.get_translator("mcl_inventory")
|
2019-03-14 01:50:29 +01:00
|
|
|
local F = minetest.formspec_escape
|
2019-03-07 21:10:39 +01:00
|
|
|
|
2017-01-24 21:18:42 +01:00
|
|
|
-- Prepare player info table
|
|
|
|
local players = {}
|
|
|
|
|
2017-06-02 19:41:52 +02:00
|
|
|
-- Containing all the items for each Creative Mode tab
|
|
|
|
local inventory_lists = {}
|
|
|
|
|
2020-02-18 15:44:54 +01:00
|
|
|
local show_armor = minetest.get_modpath("mcl_armor") ~= nil
|
2019-03-05 01:50:51 +01:00
|
|
|
local mod_player = minetest.get_modpath("mcl_player") ~= nil
|
|
|
|
|
2017-06-02 19:41:52 +02:00
|
|
|
-- Create tables
|
2020-06-28 15:38:06 +02:00
|
|
|
local builtin_filter_ids = {"blocks","deco","redstone","rail","food","tools","combat","mobs","brew","matr","misc","all"}
|
2017-06-02 19:41:52 +02:00
|
|
|
for _, f in pairs(builtin_filter_ids) do
|
|
|
|
inventory_lists[f] = {}
|
|
|
|
end
|
|
|
|
|
2021-01-04 13:02:55 +01:00
|
|
|
local function replace_enchanted_books(tbl)
|
|
|
|
for k, item in ipairs(tbl) do
|
|
|
|
if item:find("mcl_enchanting:book_enchanted") == 1 then
|
|
|
|
local _, enchantment, level = item:match("(%a+) ([_%w]+) (%d+)")
|
|
|
|
level = level and tonumber(level)
|
|
|
|
if enchantment and level then
|
|
|
|
tbl[k] = mcl_enchanting.enchant(ItemStack("mcl_enchanting:book_enchanted"), enchantment, level)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-06-02 19:41:52 +02:00
|
|
|
--[[ Populate all the item tables. We only do this once. Note this mod must be
|
2018-05-08 16:32:07 +02:00
|
|
|
loaded after _mcl_autogroup for this to work, because it required certain
|
2017-06-02 19:41:52 +02:00
|
|
|
groups to be set. ]]
|
|
|
|
do
|
|
|
|
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
|
|
|
|
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
|
2017-06-11 22:20:25 +02:00
|
|
|
local is_weapon_or_armor = function(def)
|
2018-01-25 22:01:19 +01:00
|
|
|
return def.groups.weapon or def.groups.weapon_ranged or def.groups.ammo or def.groups.combat_item or ((def.groups.armor_head or def.groups.armor_torso or def.groups.armor_legs or def.groups.armor_feet or def.groups.horse_armor) and def.groups.non_combat_armor ~= 1)
|
2017-06-02 19:41:52 +02:00
|
|
|
end
|
2018-05-08 15:58:26 +02:00
|
|
|
-- Is set to true if it was added in any category besides misc
|
|
|
|
local nonmisc = false
|
2017-06-02 19:41:52 +02:00
|
|
|
if def.groups.building_block then
|
2017-06-02 21:33:50 +02:00
|
|
|
table.insert(inventory_lists["blocks"], name)
|
2018-05-08 15:58:26 +02:00
|
|
|
nonmisc = true
|
2017-06-02 19:41:52 +02:00
|
|
|
end
|
|
|
|
if def.groups.deco_block then
|
2017-06-02 21:33:50 +02:00
|
|
|
table.insert(inventory_lists["deco"], name)
|
2018-05-08 15:58:26 +02:00
|
|
|
nonmisc = true
|
2017-06-02 19:41:52 +02:00
|
|
|
end
|
|
|
|
if is_redstone(def) then
|
2017-06-02 21:33:50 +02:00
|
|
|
table.insert(inventory_lists["redstone"], name)
|
2018-05-08 15:58:26 +02:00
|
|
|
nonmisc = true
|
2017-06-02 19:41:52 +02:00
|
|
|
end
|
|
|
|
if def.groups.transport then
|
2017-06-02 21:33:50 +02:00
|
|
|
table.insert(inventory_lists["rail"], name)
|
2018-05-08 15:58:26 +02:00
|
|
|
nonmisc = true
|
2017-06-02 19:41:52 +02:00
|
|
|
end
|
|
|
|
if (def.groups.food and not def.groups.brewitem) or def.groups.eatable then
|
2017-06-02 21:33:50 +02:00
|
|
|
table.insert(inventory_lists["food"], name)
|
2018-05-08 15:58:26 +02:00
|
|
|
nonmisc = true
|
2017-06-02 19:41:52 +02:00
|
|
|
end
|
|
|
|
if is_tool(def) then
|
2017-06-02 21:33:50 +02:00
|
|
|
table.insert(inventory_lists["tools"], name)
|
2018-05-08 15:58:26 +02:00
|
|
|
nonmisc = true
|
2017-06-02 19:41:52 +02:00
|
|
|
end
|
2017-06-11 22:20:25 +02:00
|
|
|
if is_weapon_or_armor(def) then
|
2017-06-02 21:33:50 +02:00
|
|
|
table.insert(inventory_lists["combat"], name)
|
2018-05-08 15:58:26 +02:00
|
|
|
nonmisc = true
|
2017-06-02 19:41:52 +02:00
|
|
|
end
|
2019-02-06 11:31:04 +01:00
|
|
|
if def.groups.spawn_egg == 1 then
|
|
|
|
table.insert(inventory_lists["mobs"], name)
|
|
|
|
nonmisc = true
|
|
|
|
end
|
2020-06-28 15:38:06 +02:00
|
|
|
if def.groups.brewitem then
|
|
|
|
table.insert(inventory_lists["brew"], name)
|
|
|
|
nonmisc = true
|
|
|
|
end
|
2017-06-02 19:41:52 +02:00
|
|
|
if def.groups.craftitem then
|
2017-06-02 21:33:50 +02:00
|
|
|
table.insert(inventory_lists["matr"], name)
|
2018-05-08 15:58:26 +02:00
|
|
|
nonmisc = true
|
2017-06-02 19:41:52 +02:00
|
|
|
end
|
2018-05-08 15:58:26 +02:00
|
|
|
-- Misc. category is for everything which is not in any other category
|
|
|
|
if not nonmisc then
|
2017-06-02 21:33:50 +02:00
|
|
|
table.insert(inventory_lists["misc"], name)
|
2017-06-02 19:41:52 +02:00
|
|
|
end
|
|
|
|
|
2017-06-02 21:33:50 +02:00
|
|
|
table.insert(inventory_lists["all"], name)
|
2017-06-02 19:41:52 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-01-04 13:02:55 +01:00
|
|
|
for ench, def in pairs(mcl_enchanting.enchantments) do
|
|
|
|
local str = "mcl_enchanting:book_enchanted " .. ench .. " " .. def.max_level
|
|
|
|
if def.inv_tool_tab then
|
|
|
|
table.insert(inventory_lists["tools"], str)
|
|
|
|
end
|
|
|
|
if def.inv_combat_tab then
|
|
|
|
table.insert(inventory_lists["combat"], str)
|
|
|
|
end
|
|
|
|
table.insert(inventory_lists["all"], str)
|
|
|
|
end
|
|
|
|
|
2017-06-02 19:41:52 +02:00
|
|
|
for _, to_sort in pairs(inventory_lists) do
|
|
|
|
table.sort(to_sort)
|
2021-01-04 13:02:55 +01:00
|
|
|
replace_enchanted_books(to_sort)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function filter_item(name, description, lang, filter)
|
|
|
|
local desc
|
|
|
|
if not lang then
|
|
|
|
desc = string.lower(description)
|
|
|
|
else
|
|
|
|
desc = string.lower(minetest.get_translated_string(lang, description))
|
2017-06-02 19:41:52 +02:00
|
|
|
end
|
2021-01-04 13:02:55 +01:00
|
|
|
return string.find(name, filter) or string.find(desc, filter)
|
2017-06-02 19:41:52 +02:00
|
|
|
end
|
|
|
|
|
2017-06-02 21:33:50 +02:00
|
|
|
local function set_inv_search(filter, player)
|
2017-01-25 12:20:21 +01:00
|
|
|
local playername = player:get_player_name()
|
|
|
|
local inv = minetest.get_inventory({type="detached", name="creative_"..playername})
|
2017-01-05 23:37:40 +01:00
|
|
|
local creative_list = {}
|
2020-04-25 14:31:01 +02:00
|
|
|
local lang = minetest.get_player_information(playername).lang_code
|
2017-06-02 21:33:50 +02:00
|
|
|
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
|
2021-01-04 13:02:55 +01:00
|
|
|
if filter_item(string.lower(def.name), def.description, lang, filter) then
|
2017-06-02 21:33:50 +02:00
|
|
|
table.insert(creative_list, name)
|
2017-01-05 23:37:40 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-01-04 13:02:55 +01:00
|
|
|
for ench, def in pairs(mcl_enchanting.enchantments) do
|
|
|
|
for i = 1, def.max_level do
|
|
|
|
local stack = mcl_enchanting.enchant(ItemStack("mcl_enchanting:book_enchanted"), ench, i)
|
|
|
|
if filter_item("mcl_enchanting:book_enchanted", minetest.strip_colors(stack:get_description()), lang, filter) then
|
|
|
|
table.insert(creative_list, "mcl_enchanting:book_enchanted " .. ench .. " " .. i)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-06-02 21:33:50 +02:00
|
|
|
table.sort(creative_list)
|
2021-01-04 13:02:55 +01:00
|
|
|
replace_enchanted_books(creative_list)
|
2017-06-02 21:33:50 +02:00
|
|
|
|
|
|
|
inv:set_size("main", #creative_list)
|
2017-06-02 22:09:07 +02:00
|
|
|
inv:set_list("main", creative_list)
|
2017-06-02 21:33:50 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local function set_inv_page(page, player)
|
|
|
|
local playername = player:get_player_name()
|
|
|
|
local inv = minetest.get_inventory({type="detached", name="creative_"..playername})
|
|
|
|
inv:set_size("main", 0)
|
|
|
|
local creative_list = {}
|
|
|
|
if inventory_lists[page] then -- Standard filter
|
|
|
|
creative_list = inventory_lists[page]
|
|
|
|
end
|
2017-01-05 23:37:40 +01:00
|
|
|
inv:set_size("main", #creative_list)
|
2017-06-02 22:09:07 +02:00
|
|
|
inv:set_list("main", creative_list)
|
2017-01-05 23:37:40 +01:00
|
|
|
end
|
|
|
|
|
2017-01-25 12:20:21 +01:00
|
|
|
local function init(player)
|
|
|
|
local playername = player:get_player_name()
|
|
|
|
local inv = minetest.create_detached_inventory("creative_"..playername, {
|
2017-01-24 02:31:49 +01:00
|
|
|
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
2020-07-10 16:08:40 +02:00
|
|
|
if minetest.is_creative_enabled(playername) then
|
2017-01-24 02:31:49 +01:00
|
|
|
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)
|
2020-07-10 16:08:40 +02:00
|
|
|
if minetest.is_creative_enabled(player:get_player_name()) then
|
2017-01-24 02:31:49 +01:00
|
|
|
return -1
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end,
|
2017-01-25 12:20:21 +01:00
|
|
|
}, playername)
|
2017-06-02 21:33:50 +02:00
|
|
|
set_inv_page("all", player)
|
2017-01-24 02:31:49 +01:00
|
|
|
end
|
|
|
|
|
2017-01-05 23:37:40 +01:00
|
|
|
-- Create the trash field
|
2017-01-25 12:20:21 +01:00
|
|
|
local trash = minetest.create_detached_inventory("trash", {
|
2017-01-05 23:37:40 +01:00
|
|
|
allow_put = function(inv, listname, index, stack, player)
|
2020-07-10 16:08:40 +02:00
|
|
|
if minetest.is_creative_enabled(player:get_player_name()) then
|
2017-01-05 23:37:40 +01:00
|
|
|
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)
|
|
|
|
|
2017-01-24 12:45:37 +01:00
|
|
|
local noffset = {} -- numeric tab offset
|
|
|
|
local offset = {} -- string offset:
|
2020-06-28 15:38:06 +02:00
|
|
|
local boffset = {} --
|
2017-01-05 23:37:40 +01:00
|
|
|
local hoch = {}
|
2019-03-16 04:04:41 +01:00
|
|
|
local filtername = {}
|
2017-01-05 23:37:40 +01:00
|
|
|
local bg = {}
|
2017-01-24 12:45:37 +01:00
|
|
|
|
2017-11-21 23:23:56 +01:00
|
|
|
local noffset_x_start = -0.24
|
|
|
|
local noffset_x = noffset_x_start
|
|
|
|
local noffset_y = -0.25
|
|
|
|
local next_noffset = function(id, right)
|
|
|
|
if right then
|
|
|
|
noffset[id] = { 8.94, noffset_y }
|
|
|
|
else
|
|
|
|
noffset[id] = { noffset_x, noffset_y }
|
|
|
|
noffset_x = noffset_x + 1.25
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Upper row
|
|
|
|
next_noffset("blocks")
|
|
|
|
next_noffset("deco")
|
|
|
|
next_noffset("redstone")
|
|
|
|
next_noffset("rail")
|
2020-06-28 15:38:06 +02:00
|
|
|
next_noffset("brew")
|
2017-11-21 23:23:56 +01:00
|
|
|
next_noffset("misc")
|
|
|
|
next_noffset("nix", true)
|
|
|
|
|
|
|
|
noffset_x = noffset_x_start
|
|
|
|
noffset_y = 8.12
|
|
|
|
|
|
|
|
-- Lower row
|
|
|
|
next_noffset("food")
|
|
|
|
next_noffset("tools")
|
|
|
|
next_noffset("combat")
|
2019-02-06 11:31:04 +01:00
|
|
|
next_noffset("mobs")
|
2017-11-21 23:23:56 +01:00
|
|
|
next_noffset("matr")
|
|
|
|
next_noffset("inv", true)
|
2017-01-24 12:45:37 +01:00
|
|
|
|
|
|
|
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"] = ""
|
2020-06-28 15:38:06 +02:00
|
|
|
hoch["brew"] = ""
|
2017-01-05 23:37:40 +01:00
|
|
|
hoch["misc"] = ""
|
|
|
|
hoch["nix"] = ""
|
2017-01-22 23:56:10 +01:00
|
|
|
hoch["default"] = ""
|
2020-03-10 06:38:53 +01:00
|
|
|
hoch["food"] = "_down"
|
|
|
|
hoch["tools"] = "_down"
|
|
|
|
hoch["combat"] = "_down"
|
|
|
|
hoch["mobs"] = "_down"
|
|
|
|
hoch["matr"] = "_down"
|
|
|
|
hoch["inv"] = "_down"
|
2017-01-05 23:37:40 +01:00
|
|
|
|
2019-03-16 04:04:41 +01:00
|
|
|
filtername = {}
|
|
|
|
filtername["blocks"] = S("Building Blocks")
|
|
|
|
filtername["deco"] = S("Decoration Blocks")
|
|
|
|
filtername["redstone"] = S("Redstone")
|
|
|
|
filtername["rail"] = S("Transportation")
|
|
|
|
filtername["misc"] = S("Miscellaneous")
|
|
|
|
filtername["nix"] = S("Search Items")
|
|
|
|
filtername["food"] = S("Foodstuffs")
|
|
|
|
filtername["tools"] = S("Tools")
|
|
|
|
filtername["combat"] = S("Combat")
|
|
|
|
filtername["mobs"] = S("Mobs")
|
2020-06-28 15:38:06 +02:00
|
|
|
filtername["brew"] = S("Brewing")
|
2019-03-16 04:04:41 +01:00
|
|
|
filtername["matr"] = S("Materials")
|
|
|
|
filtername["inv"] = S("Survival Inventory")
|
|
|
|
|
2017-01-05 23:37:40 +01:00
|
|
|
local dark_bg = "crafting_creative_bg_dark.png"
|
|
|
|
|
|
|
|
local function reset_menu_item_bg()
|
2020-06-28 15:38:06 +02:00
|
|
|
bg["blocks"] = dark_bg
|
|
|
|
bg["deco"] = dark_bg
|
|
|
|
bg["redstone"] = dark_bg
|
|
|
|
bg["rail"] = dark_bg
|
|
|
|
bg["misc"] = dark_bg
|
|
|
|
bg["nix"] = dark_bg
|
|
|
|
bg["food"] = dark_bg
|
|
|
|
bg["tools"] = dark_bg
|
|
|
|
bg["combat"] = dark_bg
|
2019-02-06 11:31:04 +01:00
|
|
|
bg["mobs"] = dark_bg
|
2020-06-28 15:38:06 +02:00
|
|
|
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-06-02 22:46:39 +02:00
|
|
|
mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, inv_size, show, page, filter)
|
2017-01-05 23:37:40 +01:00
|
|
|
reset_menu_item_bg()
|
|
|
|
pagenum = math.floor(pagenum) or 1
|
2017-06-02 22:46:39 +02:00
|
|
|
|
|
|
|
local playername = player:get_player_name()
|
|
|
|
|
|
|
|
if not inv_size then
|
|
|
|
if page == "nix" then
|
|
|
|
local inv = minetest.get_inventory({type="detached", name="creative_"..playername})
|
|
|
|
inv_size = inv:get_size("main")
|
|
|
|
elseif page ~= nil and page ~= "inv" then
|
|
|
|
inv_size = #(inventory_lists[page])
|
|
|
|
else
|
|
|
|
inv_size = 0
|
|
|
|
end
|
|
|
|
end
|
2017-06-02 23:03:57 +02:00
|
|
|
local pagemax = math.max(1, math.floor((inv_size-1) / (9*5) + 1))
|
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-25 12:20:21 +01:00
|
|
|
local listrings = "listring[detached:creative_"..playername..";main]"..
|
2017-01-06 01:31:04 +01:00
|
|
|
"listring[current_player;main]"..
|
2017-01-25 12:20:21 +01:00
|
|
|
"listring[detached:trash;main]"
|
2017-01-06 01:31:04 +01:00
|
|
|
|
2017-11-18 09:03:49 +01:00
|
|
|
if page ~= nil then
|
|
|
|
name = page
|
|
|
|
if players[playername] then
|
|
|
|
players[playername].page = page
|
|
|
|
end
|
|
|
|
end
|
2017-01-05 23:37:40 +01:00
|
|
|
bg[name] = "crafting_creative_bg.png"
|
2017-11-18 09:03:49 +01:00
|
|
|
|
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-03-09 06:55:03 +01:00
|
|
|
inv_bg = "crafting_inventory_creative_survival.png"
|
2017-03-09 17:49:02 +01:00
|
|
|
|
2017-03-09 18:26:16 +01:00
|
|
|
-- Show armor and player image
|
2021-02-08 20:13:08 +01:00
|
|
|
local player_preview
|
2021-02-25 09:52:08 +01:00
|
|
|
if minetest.settings:get_bool("3d_player_preview", true) then
|
2021-02-08 20:13:08 +01:00
|
|
|
player_preview = mcl_player.get_player_formspec_model(player, 3.9, 1.4, 1.2333, 2.4666, "")
|
2019-03-05 01:50:51 +01:00
|
|
|
else
|
2021-02-08 20:13:08 +01:00
|
|
|
local img, img_player
|
|
|
|
if mod_player then
|
|
|
|
img_player = mcl_player.player_get_preview(player)
|
|
|
|
else
|
|
|
|
img_player = "player.png"
|
2017-03-09 18:26:16 +01:00
|
|
|
end
|
2021-02-08 20:13:08 +01:00
|
|
|
img = img_player
|
2017-03-09 18:26:16 +01:00
|
|
|
player_preview = "image[3.9,1.4;1.2333,2.4666;"..img.."]"
|
2021-02-08 20:13:08 +01:00
|
|
|
if show_armor and armor.textures[playername] and armor.textures[playername].preview then
|
|
|
|
img = armor.textures[playername].preview
|
|
|
|
local s1 = img:find("character_preview")
|
|
|
|
if s1 ~= nil then
|
|
|
|
s1 = img:sub(s1+21)
|
|
|
|
img = img_player..s1
|
|
|
|
end
|
|
|
|
player_preview = "image[3.9,1.4;1.2333,2.4666;"..img.."]"
|
|
|
|
end
|
2017-03-09 18:26:16 +01:00
|
|
|
end
|
|
|
|
|
2017-03-09 17:49:02 +01:00
|
|
|
-- Background images for armor slots (hide if occupied)
|
|
|
|
local armor_slot_imgs = ""
|
|
|
|
local inv = player:get_inventory()
|
|
|
|
if inv:get_stack("armor", 2):is_empty() then
|
2017-04-01 05:41:53 +02:00
|
|
|
armor_slot_imgs = armor_slot_imgs .. "image[2.5,1.3;1,1;mcl_inventory_empty_armor_slot_helmet.png]"
|
2017-03-09 17:49:02 +01:00
|
|
|
end
|
|
|
|
if inv:get_stack("armor", 3):is_empty() then
|
2017-04-01 05:41:53 +02:00
|
|
|
armor_slot_imgs = armor_slot_imgs .. "image[2.5,2.75;1,1;mcl_inventory_empty_armor_slot_chestplate.png]"
|
2017-03-09 17:49:02 +01:00
|
|
|
end
|
|
|
|
if inv:get_stack("armor", 4):is_empty() then
|
2017-04-01 05:41:53 +02:00
|
|
|
armor_slot_imgs = armor_slot_imgs .. "image[5.5,1.3;1,1;mcl_inventory_empty_armor_slot_leggings.png]"
|
2017-03-09 17:49:02 +01:00
|
|
|
end
|
|
|
|
if inv:get_stack("armor", 5):is_empty() then
|
2017-04-01 05:41:53 +02:00
|
|
|
armor_slot_imgs = armor_slot_imgs .. "image[5.5,2.75;1,1;mcl_inventory_empty_armor_slot_boots.png]"
|
2017-03-09 17:49:02 +01:00
|
|
|
end
|
|
|
|
|
2017-01-24 08:50:31 +01:00
|
|
|
-- Survival inventory slots
|
2017-03-09 06:55:03 +01:00
|
|
|
main_list = "list[current_player;main;0,3.75;9,3;9]"..
|
2020-03-24 18:48:14 +01:00
|
|
|
mcl_formspec.get_itemslot_bg(0,3.75,9,3)..
|
2017-03-09 06:55:03 +01:00
|
|
|
-- armor
|
|
|
|
"list[detached:"..playername.."_armor;armor;2.5,1.3;1,1;1]"..
|
|
|
|
"list[detached:"..playername.."_armor;armor;2.5,2.75;1,1;2]"..
|
|
|
|
"list[detached:"..playername.."_armor;armor;5.5,1.3;1,1;3]"..
|
|
|
|
"list[detached:"..playername.."_armor;armor;5.5,2.75;1,1;4]"..
|
2020-03-24 18:48:14 +01:00
|
|
|
mcl_formspec.get_itemslot_bg(2.5,1.3,1,1)..
|
|
|
|
mcl_formspec.get_itemslot_bg(2.5,2.75,1,1)..
|
|
|
|
mcl_formspec.get_itemslot_bg(5.5,1.3,1,1)..
|
|
|
|
mcl_formspec.get_itemslot_bg(5.5,2.75,1,1)..
|
2017-03-09 17:49:02 +01:00
|
|
|
armor_slot_imgs..
|
2017-03-09 18:26:16 +01:00
|
|
|
-- player preview
|
|
|
|
player_preview..
|
2017-03-04 01:58:14 +01:00
|
|
|
-- crafting guide button
|
|
|
|
"image_button[9,1;1,1;craftguide_book.png;__mcl_craftguide;]"..
|
2019-03-14 01:50:29 +01:00
|
|
|
"tooltip[__mcl_craftguide;"..F(S("Recipe book")).."]"..
|
2017-03-18 03:27:36 +01:00
|
|
|
-- help button
|
|
|
|
"image_button[9,2;1,1;doc_button_icon_lores.png;__mcl_doc;]"..
|
2019-03-14 01:50:29 +01:00
|
|
|
"tooltip[__mcl_doc;"..F(S("Help")).."]"..
|
2019-03-05 13:50:35 +01:00
|
|
|
-- skins button
|
|
|
|
"image_button[9,3;1,1;mcl_skins_button.png;__mcl_skins;]"..
|
2019-03-14 01:50:29 +01:00
|
|
|
"tooltip[__mcl_skins;"..F(S("Select player skin")).."]"..
|
2017-03-04 01:57:10 +01:00
|
|
|
-- achievements button
|
2019-03-05 13:50:35 +01:00
|
|
|
"image_button[9,4;1,1;mcl_achievements_button.png;__mcl_achievements;]"..
|
2020-03-10 05:01:49 +01:00
|
|
|
--"style_type[image_button;border=;bgimg=;bgimg_pressed=]"..
|
2019-03-14 01:50:29 +01:00
|
|
|
"tooltip[__mcl_achievements;"..F(S("Achievements")).."]"
|
2017-03-09 06:55:03 +01:00
|
|
|
|
|
|
|
-- For shortcuts
|
|
|
|
listrings = listrings ..
|
|
|
|
"listring[detached:"..playername.."_armor;armor]"..
|
|
|
|
"listring[current_player;main]"
|
2017-01-24 08:50:31 +01:00
|
|
|
else
|
|
|
|
-- Creative inventory slots
|
2020-03-10 06:10:54 +01:00
|
|
|
main_list = "list[detached:creative_"..playername..";main;0,1.75;9,5;"..tostring(start_i).."]"..
|
2020-03-24 18:48:14 +01:00
|
|
|
mcl_formspec.get_itemslot_bg(0,1.75,9,5)..
|
2020-03-10 06:10:54 +01:00
|
|
|
-- Page buttons
|
|
|
|
"label[9.0,5.5;"..F(S("@1/@2", pagenum, pagemax)).."]"..
|
|
|
|
"image_button[9.0,6.0;0.7,0.7;crafting_creative_prev.png;creative_prev;]"..
|
|
|
|
"image_button[9.5,6.0;0.7,0.7;crafting_creative_next.png;creative_next;]"
|
2017-01-05 23:37:40 +01:00
|
|
|
end
|
2017-11-21 23:23:56 +01:00
|
|
|
|
|
|
|
local tab_icon = {
|
|
|
|
blocks = "mcl_core:brick_block",
|
|
|
|
deco = "mcl_flowers:peony",
|
|
|
|
redstone = "mesecons:redstone",
|
|
|
|
rail = "mcl_minecarts:golden_rail",
|
|
|
|
misc = "mcl_buckets:bucket_lava",
|
|
|
|
nix = "mcl_compass:compass",
|
|
|
|
food = "mcl_core:apple",
|
|
|
|
tools = "mcl_core:axe_iron",
|
|
|
|
combat = "mcl_core:sword_gold",
|
2019-02-06 11:31:04 +01:00
|
|
|
mobs = "mobs_mc:cow",
|
2020-06-28 18:16:07 +02:00
|
|
|
brew = "mcl_potions:dragon_breath",
|
2017-11-21 23:23:56 +01:00
|
|
|
matr = "mcl_core:stick",
|
|
|
|
inv = "mcl_chests:chest",
|
|
|
|
}
|
|
|
|
local function tab(current_tab, this_tab)
|
|
|
|
local bg_img
|
|
|
|
if current_tab == this_tab then
|
2020-03-10 06:38:53 +01:00
|
|
|
bg_img = "crafting_creative_active"..hoch[this_tab]..".png"
|
2017-01-22 23:56:10 +01:00
|
|
|
else
|
2020-03-10 06:38:53 +01:00
|
|
|
bg_img = "crafting_creative_inactive"..hoch[this_tab]..".png"
|
2017-01-22 23:56:10 +01:00
|
|
|
end
|
2020-06-28 15:38:06 +02:00
|
|
|
return
|
2020-03-10 05:01:49 +01:00
|
|
|
"style["..this_tab..";border=false;bgimg=;bgimg_pressed=]"..
|
2017-11-21 23:23:56 +01:00
|
|
|
"item_image_button[" .. boffset[this_tab] ..";1,1;"..tab_icon[this_tab]..";"..this_tab..";]"..
|
2020-03-10 06:38:53 +01:00
|
|
|
"image[" .. offset[this_tab] .. ";1.5,1.44;" .. bg_img .. "]" ..
|
2017-11-21 23:23:56 +01:00
|
|
|
"image[" .. boffset[this_tab] .. ";1,1;crafting_creative_marker.png]"
|
2017-01-22 23:56:10 +01:00
|
|
|
end
|
2019-03-16 04:04:41 +01:00
|
|
|
local caption = ""
|
|
|
|
if name ~= "inv" and filtername[name] then
|
2021-03-30 00:01:29 +02:00
|
|
|
caption = "label[0,1.2;"..F(minetest.colorize(mcl_colors.DARK_GRAY, filtername[name])).."]"
|
2017-03-09 06:55:03 +01:00
|
|
|
end
|
2017-11-21 23:23:56 +01:00
|
|
|
|
2020-03-10 05:01:49 +01:00
|
|
|
formspec = "size[10,9.3]"..
|
|
|
|
"no_prepend[]"..
|
|
|
|
mcl_vars.gui_nonbg..mcl_vars.gui_bg_color..
|
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
|
|
|
tab(name, "blocks") ..
|
2019-03-16 04:04:41 +01:00
|
|
|
"tooltip[blocks;"..F(filtername["blocks"]).."]"..
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "deco") ..
|
2019-03-16 04:04:41 +01:00
|
|
|
"tooltip[deco;"..F(filtername["deco"]).."]"..
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "redstone") ..
|
2019-03-16 04:04:41 +01:00
|
|
|
"tooltip[redstone;"..F(filtername["redstone"]).."]"..
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "rail") ..
|
2019-03-16 04:04:41 +01:00
|
|
|
"tooltip[rail;"..F(filtername["rail"]).."]"..
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "misc") ..
|
2019-03-16 04:04:41 +01:00
|
|
|
"tooltip[misc;"..F(filtername["misc"]).."]"..
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "nix") ..
|
2019-03-16 04:04:41 +01:00
|
|
|
"tooltip[nix;"..F(filtername["nix"]).."]"..
|
|
|
|
caption..
|
2017-01-05 23:37:40 +01:00
|
|
|
"list[current_player;main;0,7;9,1;]"..
|
2020-03-24 18:48:14 +01:00
|
|
|
mcl_formspec.get_itemslot_bg(0,7,9,1)..
|
2017-01-05 23:37:40 +01:00
|
|
|
main_list..
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "food") ..
|
2019-03-16 04:04:41 +01:00
|
|
|
"tooltip[food;"..F(filtername["food"]).."]"..
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "tools") ..
|
2019-03-16 04:04:41 +01:00
|
|
|
"tooltip[tools;"..F(filtername["tools"]).."]"..
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "combat") ..
|
2019-03-16 04:04:41 +01:00
|
|
|
"tooltip[combat;"..F(filtername["combat"]).."]"..
|
2019-02-06 11:31:04 +01:00
|
|
|
tab(name, "mobs") ..
|
2019-03-16 04:04:41 +01:00
|
|
|
"tooltip[mobs;"..F(filtername["mobs"]).."]"..
|
2020-06-28 15:38:06 +02:00
|
|
|
tab(name, "brew") ..
|
|
|
|
"tooltip[brew;"..F(filtername["brew"]).."]"..
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "matr") ..
|
2019-03-16 04:04:41 +01:00
|
|
|
"tooltip[matr;"..F(filtername["matr"]).."]"..
|
2017-01-22 23:56:10 +01:00
|
|
|
tab(name, "inv") ..
|
2019-03-16 04:04:41 +01:00
|
|
|
"tooltip[inv;"..F(filtername["inv"]).."]"..
|
2017-01-25 12:20:21 +01:00
|
|
|
"list[detached:trash;main;9,7;1,1;]"..
|
2020-03-24 18:48:14 +01:00
|
|
|
mcl_formspec.get_itemslot_bg(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
|
2021-03-26 14:32:08 +01:00
|
|
|
formspec = formspec .. "field[5.3,1.34;4,0.75;search;;"..minetest.formspec_escape(filter).."]"
|
|
|
|
formspec = formspec .. "field_close_on_enter[search;false]"
|
2017-01-23 00:33:01 +01:00
|
|
|
end
|
2017-01-05 23:37:40 +01:00
|
|
|
if pagenum ~= nil then formspec = formspec .. "p"..tostring(pagenum) end
|
2017-02-10 19:31:59 +01:00
|
|
|
|
2017-06-02 22:46:39 +02:00
|
|
|
|
2017-01-05 23:37:40 +01:00
|
|
|
player:set_inventory_formspec(formspec)
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|
|
|
local page = nil
|
2020-07-10 16:08:40 +02:00
|
|
|
|
|
|
|
if not minetest.is_creative_enabled(player:get_player_name()) then
|
2017-01-05 23:37:40 +01:00
|
|
|
return
|
2017-03-09 18:51:01 +01:00
|
|
|
end
|
2017-06-02 20:02:24 +02:00
|
|
|
if formname ~= "" or fields.quit == "true" then
|
|
|
|
-- No-op if formspec closed or not player inventory (formname == "")
|
2017-03-09 18:51:01 +01:00
|
|
|
return
|
2017-01-05 23:37:40 +01:00
|
|
|
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-06-02 19:01:12 +02:00
|
|
|
if players[name].page == "blocks" then return end
|
2017-06-02 23:00:12 +02:00
|
|
|
set_inv_page("blocks",player)
|
2017-06-02 22:46:39 +02:00
|
|
|
page = "blocks"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.deco then
|
2017-06-02 19:01:12 +02:00
|
|
|
if players[name].page == "deco" then return end
|
2017-06-02 23:00:12 +02:00
|
|
|
set_inv_page("deco",player)
|
2017-01-05 23:37:40 +01:00
|
|
|
page = "deco"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.redstone then
|
2017-06-02 19:01:12 +02:00
|
|
|
if players[name].page == "redstone" then return end
|
2017-06-02 23:00:12 +02:00
|
|
|
set_inv_page("redstone",player)
|
2017-01-09 13:54:02 +01:00
|
|
|
page = "redstone"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.rail then
|
2017-06-02 19:01:12 +02:00
|
|
|
if players[name].page == "rail" then return end
|
2017-06-02 23:00:12 +02:00
|
|
|
set_inv_page("rail",player)
|
2017-01-05 23:37:40 +01:00
|
|
|
page = "rail"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.misc then
|
2017-06-02 19:01:12 +02:00
|
|
|
if players[name].page == "misc" then return end
|
2017-06-02 21:33:50 +02:00
|
|
|
set_inv_page("misc",player)
|
2017-01-05 23:37:40 +01:00
|
|
|
page = "misc"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.nix then
|
2017-06-02 21:33:50 +02:00
|
|
|
set_inv_page("all",player)
|
2017-01-23 00:33:01 +01:00
|
|
|
page = "nix"
|
|
|
|
elseif fields.food then
|
2017-06-02 19:01:12 +02:00
|
|
|
if players[name].page == "food" then return end
|
2017-06-02 23:00:12 +02:00
|
|
|
set_inv_page("food",player)
|
2017-01-05 23:37:40 +01:00
|
|
|
page = "food"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.tools then
|
2017-06-02 19:01:12 +02:00
|
|
|
if players[name].page == "tools" then return end
|
2017-06-02 23:00:12 +02:00
|
|
|
set_inv_page("tools",player)
|
2017-01-05 23:37:40 +01:00
|
|
|
page = "tools"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.combat then
|
2017-06-02 19:01:12 +02:00
|
|
|
if players[name].page == "combat" then return end
|
2017-06-02 23:00:12 +02:00
|
|
|
set_inv_page("combat",player)
|
2017-01-05 23:37:40 +01:00
|
|
|
page = "combat"
|
2019-02-06 11:31:04 +01:00
|
|
|
elseif fields.mobs then
|
|
|
|
if players[name].page == "mobs" then return end
|
|
|
|
set_inv_page("mobs",player)
|
|
|
|
page = "mobs"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.brew then
|
2017-06-02 19:01:12 +02:00
|
|
|
if players[name].page == "brew" then return end
|
2017-06-02 23:00:12 +02:00
|
|
|
set_inv_page("brew",player)
|
2017-01-23 00:02:58 +01:00
|
|
|
page = "brew"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.matr then
|
2017-06-02 19:01:12 +02:00
|
|
|
if players[name].page == "matr" then return end
|
2017-06-02 23:00:12 +02:00
|
|
|
set_inv_page("matr",player)
|
2017-01-05 23:37:40 +01:00
|
|
|
page = "matr"
|
2017-01-23 00:33:01 +01:00
|
|
|
elseif fields.inv then
|
2017-06-02 19:01:12 +02:00
|
|
|
if players[name].page == "inv" then return end
|
2017-01-05 23:37:40 +01:00
|
|
|
page = "inv"
|
2021-03-26 14:32:08 +01:00
|
|
|
elseif fields.search == "" and not fields.creative_next and not fields.creative_prev then
|
2017-06-02 23:00:12 +02:00
|
|
|
set_inv_page("all", player)
|
2017-01-23 00:33:01 +01:00
|
|
|
page = "nix"
|
2021-03-26 14:32:08 +01:00
|
|
|
elseif fields.search ~= nil and not fields.creative_next and not fields.creative_prev then
|
|
|
|
set_inv_search(string.lower(fields.search),player)
|
2017-01-23 00:33:01 +01:00
|
|
|
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-06-02 22:46:39 +02:00
|
|
|
-- Figure out current scroll bar from formspec
|
2017-01-05 23:37:40 +01:00
|
|
|
local formspec = player:get_inventory_formspec()
|
|
|
|
|
2017-01-24 21:18:42 +01:00
|
|
|
local start_i = players[name].start_i
|
2017-06-02 22:46:39 +02:00
|
|
|
|
2017-01-05 23:37:40 +01:00
|
|
|
if fields.creative_prev then
|
|
|
|
start_i = start_i - 9*5
|
2017-06-02 23:14:19 +02:00
|
|
|
elseif fields.creative_next then
|
2017-01-05 23:37:40 +01:00
|
|
|
start_i = start_i + 9*5
|
2017-06-02 23:14:19 +02:00
|
|
|
else
|
|
|
|
-- Reset scroll bar if not scrolled
|
|
|
|
start_i = 0
|
2017-01-05 23:37:40 +01:00
|
|
|
end
|
|
|
|
if start_i < 0 then
|
|
|
|
start_i = start_i + 9*5
|
|
|
|
end
|
2017-06-02 22:46:39 +02:00
|
|
|
|
|
|
|
local inv_size
|
|
|
|
if page == "nix" then
|
|
|
|
local inv = minetest.get_inventory({type="detached", name="creative_"..name})
|
|
|
|
inv_size = inv:get_size("main")
|
|
|
|
elseif page ~= nil and page ~= "inv" then
|
|
|
|
inv_size = #(inventory_lists[page])
|
|
|
|
else
|
|
|
|
inv_size = 0
|
|
|
|
end
|
|
|
|
|
|
|
|
if start_i >= inv_size then
|
2017-01-05 23:37:40 +01:00
|
|
|
start_i = start_i - 9*5
|
2017-06-02 22:46:39 +02:00
|
|
|
end
|
|
|
|
if start_i < 0 or start_i >= inv_size then
|
2017-01-05 23:37:40 +01:00
|
|
|
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
|
|
|
|
2017-06-02 23:05:55 +02:00
|
|
|
local filter = ""
|
2021-03-26 14:32:08 +01:00
|
|
|
if not fields.nix and fields.search ~= nil and fields.search ~= "" then
|
|
|
|
filter = fields.search
|
2017-01-24 21:18:42 +01:00
|
|
|
players[name].filter = filter
|
2017-01-23 00:33:01 +01:00
|
|
|
end
|
|
|
|
|
2017-06-02 22:46:39 +02:00
|
|
|
mcl_inventory.set_creative_formspec(player, start_i, start_i / (9*5) + 1, inv_size, false, page, filter)
|
2017-01-05 23:37:40 +01:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
2020-07-10 16:08:40 +02:00
|
|
|
if minetest.is_creative_enabled("") then
|
2017-01-05 23:37:40 +01:00
|
|
|
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
|
2017-02-07 02:22:41 +01:00
|
|
|
-- Place infinite nodes, except for shulker boxes
|
|
|
|
local group = minetest.get_item_group(itemstack:get_name(), "shulker_box")
|
|
|
|
return group == 0 or group == nil
|
2017-01-05 23:37:40 +01:00
|
|
|
end)
|
2017-06-02 22:46:39 +02:00
|
|
|
|
2017-01-05 23:37:40 +01:00
|
|
|
function minetest.handle_node_drops(pos, drops, digger)
|
|
|
|
if not digger or not digger:is_player() then
|
2021-01-05 17:23:24 +01:00
|
|
|
for _,item in ipairs(drops) do
|
|
|
|
minetest.add_item(pos, item)
|
|
|
|
end
|
2017-01-05 23:37:40 +01:00
|
|
|
end
|
|
|
|
local inv = digger:get_inventory()
|
|
|
|
if inv then
|
|
|
|
for _,item in ipairs(drops) do
|
2019-03-01 17:30:21 +01:00
|
|
|
if not inv:contains_item("main", item, true) then
|
2017-01-05 23:37:40 +01:00
|
|
|
inv:add_item("main", item)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-06-02 22:46:39 +02:00
|
|
|
|
2019-03-05 10:29:49 +01:00
|
|
|
mcl_inventory.update_inventory_formspec = function(player)
|
|
|
|
local page = nil
|
|
|
|
|
|
|
|
local name = player:get_player_name()
|
|
|
|
|
|
|
|
if players[name].page then
|
|
|
|
page = players[name].page
|
|
|
|
else
|
|
|
|
page = "nix"
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Figure out current scroll bar from formspec
|
|
|
|
local formspec = player:get_inventory_formspec()
|
|
|
|
local start_i = players[name].start_i
|
|
|
|
|
|
|
|
local inv_size
|
|
|
|
if page == "nix" then
|
|
|
|
local inv = minetest.get_inventory({type="detached", name="creative_"..name})
|
|
|
|
inv_size = inv:get_size("main")
|
|
|
|
elseif page ~= nil and page ~= "inv" then
|
|
|
|
inv_size = #(inventory_lists[page])
|
|
|
|
else
|
|
|
|
inv_size = 0
|
|
|
|
end
|
|
|
|
|
|
|
|
local filter = players[name].filter
|
|
|
|
if filter == nil then
|
|
|
|
filter = ""
|
|
|
|
end
|
|
|
|
|
|
|
|
mcl_inventory.set_creative_formspec(player, start_i, start_i / (9*5) + 1, inv_size, false, page, filter)
|
|
|
|
end
|
2017-01-05 23:37:40 +01:00
|
|
|
end
|
2017-01-25 12:20:21 +01:00
|
|
|
|
|
|
|
minetest.register_on_joinplayer(function(player)
|
2017-06-02 23:43:39 +02:00
|
|
|
-- Initialize variables and inventory
|
2017-01-25 12:20:21 +01:00
|
|
|
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
|
|
|
|
init(player)
|
2017-06-02 23:43:39 +02:00
|
|
|
mcl_inventory.set_creative_formspec(player, 0, 1, nil, false, "nix", "")
|
2017-01-25 12:20:21 +01:00
|
|
|
end)
|