diff --git a/mods/unified_inventory/api.lua b/mods/unified_inventory/api.lua index 3eaf4a9c..80946982 100755 --- a/mods/unified_inventory/api.lua +++ b/mods/unified_inventory/api.lua @@ -130,7 +130,7 @@ end -- register_craft function unified_inventory.register_craft(options) - if options.output == nil then + if not options.output then return end local itemstack = ItemStack(options.output) @@ -140,7 +140,7 @@ function unified_inventory.register_craft(options) if options.type == "normal" and options.width == 0 then options = { type = "shapeless", items = options.items, output = options.output, width = 0 } end - if unified_inventory.crafts_for.recipe[itemstack:get_name()] == nil then + if not unified_inventory.crafts_for.recipe[itemstack:get_name()] then unified_inventory.crafts_for.recipe[itemstack:get_name()] = {} end table.insert(unified_inventory.crafts_for.recipe[itemstack:get_name()],options) @@ -233,9 +233,7 @@ end function unified_inventory.is_creative(playername) - if minetest.check_player_privs(playername, {creative=true}) or - minetest.setting_getbool("creative_mode") then - return true - end + return minetest.check_player_privs(playername, {creative=true}) + or minetest.setting_getbool("creative_mode") end diff --git a/mods/unified_inventory/bags.lua b/mods/unified_inventory/bags.lua index b92eb87d..827af1fd 100755 --- a/mods/unified_inventory/bags.lua +++ b/mods/unified_inventory/bags.lua @@ -27,18 +27,84 @@ unified_inventory.register_button("bags", { type = "image", image = "ui_bags_icon.png", tooltip = S("Bags"), + hide_lite=true, show_with = false, --Modif MFF (Crabman 30/06/2015) }) -for i = 1, 4 do - unified_inventory.register_page("bag"..i, { + + unified_inventory.register_page("bag1", { get_formspec = function(player) - local stack = player:get_inventory():get_stack("bag"..i, 1) + local stack = player:get_inventory():get_stack("bag1", 1) local image = stack:get_definition().inventory_image local formspec = "image[7,0;1,1;"..image.."]" - formspec = formspec.."label[0,0;Bag "..i.."]" + formspec = formspec.."label[0,0;Bag 1]" formspec = formspec.."listcolors[#00000000;#00000000]" - formspec = formspec.."list[current_player;bag"..i.."contents;0,1;8,3;]" + formspec = formspec.."list[current_player;bag1contents;0,1;8,3;]" + formspec = formspec.."listring[current_name;bag1contents]" + formspec = formspec.."listring[current_player;main]" + local slots = stack:get_definition().groups.bagslots + if slots == 8 then + formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_sm_form.png]" + elseif slots == 16 then + formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_med_form.png]" + elseif slots == 24 then + formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_lg_form.png]" + end + return {formspec=formspec} + end, + }) + unified_inventory.register_page("bag2", { + get_formspec = function(player) + local stack = player:get_inventory():get_stack("bag2", 1) + local image = stack:get_definition().inventory_image + local formspec = "image[7,0;1,1;"..image.."]" + formspec = formspec.."label[0,0;Bag 2]" + formspec = formspec.."listcolors[#00000000;#00000000]" + formspec = formspec.."list[current_player;bag2contents;0,1;8,3;]" + formspec = formspec.."listring[current_name;bag2contents]" + formspec = formspec.."listring[current_player;main]" + local slots = stack:get_definition().groups.bagslots + if slots == 8 then + formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_sm_form.png]" + elseif slots == 16 then + formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_med_form.png]" + elseif slots == 24 then + formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_lg_form.png]" + end + return {formspec=formspec} + end, + }) + unified_inventory.register_page("bag3", { + get_formspec = function(player) + local stack = player:get_inventory():get_stack("bag3", 1) + local image = stack:get_definition().inventory_image + local formspec = "image[7,0;1,1;"..image.."]" + formspec = formspec.."label[0,0;Bag 3]" + formspec = formspec.."listcolors[#00000000;#00000000]" + formspec = formspec.."list[current_player;bag3contents;0,1;8,3;]" + formspec = formspec.."listring[current_name;bag3contents]" + formspec = formspec.."listring[current_player;main]" + local slots = stack:get_definition().groups.bagslots + if slots == 8 then + formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_sm_form.png]" + elseif slots == 16 then + formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_med_form.png]" + elseif slots == 24 then + formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_lg_form.png]" + end + return {formspec=formspec} + end, + }) + unified_inventory.register_page("bag4", { + get_formspec = function(player) + local stack = player:get_inventory():get_stack("bag4", 1) + local image = stack:get_definition().inventory_image + local formspec = "image[7,0;1,1;"..image.."]" + formspec = formspec.."label[0,0;Bag 4]" + formspec = formspec.."listcolors[#00000000;#00000000]" + formspec = formspec.."list[current_player;bag4contents;0,1;8,3;]" + formspec = formspec.."listring[current_name;bag4contents]" + formspec = formspec.."listring[current_player;main]" local slots = stack:get_definition().groups.bagslots if slots == 8 then formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_sm_form.png]" @@ -50,7 +116,6 @@ for i = 1, 4 do return {formspec=formspec} end, }) -end minetest.register_on_player_receive_fields(function(player, formname, fields) if formname ~= "" then @@ -128,9 +193,9 @@ minetest.register_tool("unified_inventory:bag_large", { minetest.register_craft({ output = "unified_inventory:bag_small", recipe = { - {"", "group:stick", ""}, - {"group:wood", "group:wood", "group:wood"}, - {"group:wood", "group:wood", "group:wood"}, + {"", "farming:cotton", ""}, + {"group:wool", "group:wool", "group:wool"}, + {"group:wool", "group:wool", "group:wool"}, }, }) @@ -138,8 +203,8 @@ minetest.register_craft({ output = "unified_inventory:bag_medium", recipe = { {"", "", ""}, - {"group:stick", "unified_inventory:bag_small", "group:stick"}, - {"group:stick", "unified_inventory:bag_small", "group:stick"}, + {"farming:cotton", "unified_inventory:bag_small", "farming:cotton"}, + {"farming:cotton", "unified_inventory:bag_small", "farming:cotton"}, }, }) @@ -147,8 +212,8 @@ minetest.register_craft({ output = "unified_inventory:bag_large", recipe = { {"", "", ""}, - {"group:stick", "unified_inventory:bag_medium", "group:stick"}, - {"group:stick", "unified_inventory:bag_medium", "group:stick"}, + {"farming:cotton", "unified_inventory:bag_medium", "farming:cotton"}, + {"farming:cotton", "unified_inventory:bag_medium", "farming:cotton"}, }, }) diff --git a/mods/unified_inventory/callbacks.lua b/mods/unified_inventory/callbacks.lua index 3a41c32d..392e855b 100755 --- a/mods/unified_inventory/callbacks.lua +++ b/mods/unified_inventory/callbacks.lua @@ -1,7 +1,9 @@ local function default_refill(stack) stack:set_count(stack:get_stack_max()) local itemdef = minetest.registered_items[stack:get_name()] - if itemdef and (itemdef.wear_represents or "mechanical_wear") == "mechanical_wear" and stack:get_wear() ~= 0 then + if itemdef + and (itemdef.wear_represents or "mechanical_wear") == "mechanical_wear" + and stack:get_wear() ~= 0 then stack:set_wear(0) end return stack @@ -12,7 +14,7 @@ minetest.register_on_joinplayer(function(player) unified_inventory.players[player_name] = {} unified_inventory.current_index[player_name] = 1 unified_inventory.filtered_items_list[player_name] = - unified_inventory.items_list + unified_inventory.items_list unified_inventory.activefilter[player_name] = "" unified_inventory.active_search_direction[player_name] = "nochange" unified_inventory.apply_filter(player, "", "nochange") @@ -21,7 +23,7 @@ minetest.register_on_joinplayer(function(player) unified_inventory.current_item[player_name] = nil unified_inventory.current_craft_direction[player_name] = "recipe" unified_inventory.set_inventory_formspec(player, - unified_inventory.default) + unified_inventory.default) -- Refill slot local refill = minetest.create_detached_inventory(player_name.."refill", { @@ -46,13 +48,17 @@ minetest.register_on_joinplayer(function(player) end) minetest.register_on_player_receive_fields(function(player, formname, fields) + local player_name = player:get_player_name() + + local ui_peruser,draw_lite_mode = unified_inventory.get_per_player_formspec(player_name) + if formname ~= "" then return end - local player_name = player:get_player_name() -- always take new search text, even if not searching on it yet - if fields.searchbox ~= nil and fields.searchbox ~= unified_inventory.current_searchbox[player_name] then + if fields.searchbox + and fields.searchbox ~= unified_inventory.current_searchbox[player_name] then unified_inventory.current_searchbox[player_name] = fields.searchbox unified_inventory.set_inventory_formspec(player, unified_inventory.current_page[player_name]) end @@ -68,11 +74,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) -- Inventory page controls local start = math.floor( - unified_inventory.current_index[player_name] / unified_inventory.items_per_page + 1) + unified_inventory.current_index[player_name] / ui_peruser.items_per_page + 1) local start_i = start local pagemax = math.floor( (#unified_inventory.filtered_items_list[player_name] - 1) - / (unified_inventory.items_per_page) + 1) + / (ui_peruser.items_per_page) + 1) if fields.start_list then start_i = 1 @@ -98,15 +104,15 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if start_i > pagemax then start_i = pagemax end - if not (start_i == start) then + if start_i ~= start then minetest.sound_play("paperflip1", {to_player=player_name, gain = 1.0}) - unified_inventory.current_index[player_name] = (start_i - 1) * unified_inventory.items_per_page + 1 + unified_inventory.current_index[player_name] = (start_i - 1) * ui_peruser.items_per_page + 1 unified_inventory.set_inventory_formspec(player, unified_inventory.current_page[player_name]) end - local clicked_item = nil + local clicked_item for name, value in pairs(fields) do if string.sub(name, 1, 12) == "item_button_" then local new_dir, mangled_item = string.match(name, "^item_button_([a-z]+)_(.*)$") @@ -116,7 +122,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) unified_inventory.apply_filter(player, clicked_item, new_dir) return end - if new_dir == "recipe" or new_dir == "usage" then + if new_dir == "recipe" + or new_dir == "usage" then unified_inventory.current_craft_direction[player_name] = new_dir end break @@ -126,22 +133,20 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) minetest.sound_play("click", {to_player=player_name, gain = 0.1}) local page = unified_inventory.current_page[player_name] - if not unified_inventory.is_creative(player_name) then + local player_creative = unified_inventory.is_creative(player_name) + if not player_creative then page = "craftguide" end if page == "craftguide" then unified_inventory.current_item[player_name] = clicked_item unified_inventory.alternate[player_name] = 1 - unified_inventory.set_inventory_formspec(player, - "craftguide") - else - if unified_inventory.is_creative(player_name) then - local inv = player:get_inventory() - local stack = ItemStack(clicked_item) - stack:set_count(stack:get_stack_max()) - if inv:room_for_item("main", stack) then - inv:add_item("main", stack) - end + unified_inventory.set_inventory_formspec(player, "craftguide") + elseif player_creative then + local inv = player:get_inventory() + local stack = ItemStack(clicked_item) + stack:set_count(stack:get_stack_max()) + if inv:room_for_item("main", stack) then + inv:add_item("main", stack) end end end @@ -156,27 +161,29 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end -- alternate button - if fields.alternate then - minetest.sound_play("click", - {to_player=player_name, gain = 0.1}) - local item_name = unified_inventory.current_item[player_name] - if item_name then - local alternates = 0 - local alternate = unified_inventory.alternate[player_name] - local crafts = unified_inventory.crafts_for[unified_inventory.current_craft_direction[player_name]][item_name] - if crafts ~= nil then - alternates = #crafts - end - if alternates > 1 then - alternate = alternate + 1 - if alternate > alternates then - alternate = 1 - end - unified_inventory.alternate[player_name] = alternate - unified_inventory.set_inventory_formspec(player, - unified_inventory.current_page[player_name]) - end - end + if not fields.alternate then + return end + minetest.sound_play("click", + {to_player=player_name, gain = 0.1}) + local item_name = unified_inventory.current_item[player_name] + if not item_name then + return + end + local crafts = unified_inventory.crafts_for[unified_inventory.current_craft_direction[player_name]][item_name] + if not crafts then + return + end + local alternates = #crafts + if alternates <= 1 then + return + end + local alternate = unified_inventory.alternate[player_name] + 1 + if alternate > alternates then + alternate = 1 + end + unified_inventory.alternate[player_name] = alternate + unified_inventory.set_inventory_formspec(player, + unified_inventory.current_page[player_name]) end) diff --git a/mods/unified_inventory/init.lua b/mods/unified_inventory/init.lua index 4abbcc85..b327ecd6 100755 --- a/mods/unified_inventory/init.lua +++ b/mods/unified_inventory/init.lua @@ -47,20 +47,6 @@ unified_inventory = { form_header_y = 0 } -if unified_inventory.lite_mode then - unified_inventory.pagecols = 4 - unified_inventory.pagerows = 6 - unified_inventory.page_y = 0.25 - unified_inventory.formspec_y = 0.47 - unified_inventory.main_button_x = 8.2 - unified_inventory.main_button_y = 6.5 - unified_inventory.craft_result_x = 2.8 - unified_inventory.craft_result_y = 3.4 - unified_inventory.form_header_y = -0.1 -end - -unified_inventory.items_per_page = unified_inventory.pagecols * unified_inventory.pagerows - -- Disable default creative inventory if rawget(_G, "creative_inventory") then function creative_inventory.set_creative_formspec(player, start_i, pagenum) @@ -73,14 +59,11 @@ dofile(modpath.."/api.lua") dofile(modpath.."/internal.lua") dofile(modpath.."/callbacks.lua") dofile(modpath.."/register.lua") - -if not unified_inventory.lite_mode then - dofile(modpath.."/bags.lua") -end +dofile(modpath.."/bags.lua") dofile(modpath.."/item_names.lua") -if minetest.get_modpath("datastorage") and not unified_inventory.lite_mode then +if minetest.get_modpath("datastorage") then dofile(modpath.."/waypoints.lua") end diff --git a/mods/unified_inventory/internal.lua b/mods/unified_inventory/internal.lua index 75120ad6..2cf21e31 100755 --- a/mods/unified_inventory/internal.lua +++ b/mods/unified_inventory/internal.lua @@ -15,79 +15,131 @@ function unified_inventory.demangle_for_formspec(str) return string.gsub(str, "_([0-9]+)_", function (v) return string.char(v) end) end +function unified_inventory.get_per_player_formspec(player_name) + local lite = unified_inventory.lite_mode and not minetest.check_player_privs(player_name, {ui_full=true}) + + local ui = {} + ui.pagecols = unified_inventory.pagecols + ui.pagerows = unified_inventory.pagerows + ui.page_y = unified_inventory.page_y + ui.formspec_y = unified_inventory.formspec_y + ui.main_button_x = unified_inventory.main_button_x + ui.main_button_y = unified_inventory.main_button_y + ui.craft_result_x = unified_inventory.craft_result_x + ui.craft_result_y = unified_inventory.craft_result_y + ui.form_header_y = unified_inventory.form_header_y + + if lite then + ui.pagecols = 4 + ui.pagerows = 6 + ui.page_y = 0.25 + ui.formspec_y = 0.47 + ui.main_button_x = 8.2 + ui.main_button_y = 6.5 + ui.craft_result_x = 2.8 + ui.craft_result_y = 3.4 + ui.form_header_y = -0.1 + end + + ui.items_per_page = ui.pagecols * ui.pagerows + return ui, lite +end + function unified_inventory.get_formspec(player, page) + if not player then return "" end + local player_name = player:get_player_name() + local ui_peruser,draw_lite_mode = unified_inventory.get_per_player_formspec(player_name) + unified_inventory.current_page[player_name] = page local pagedef = unified_inventory.pages[page] - local formspec = "size[14,10]" - -- Background - formspec = formspec .. "background[-0.19,-0.25;14.4,10.75;ui_form_bg.png]" + local formspec = { + "size[14,10]", + "background[-0.19,-0.25;14.4,10.75;ui_form_bg.png]" -- Background + } + local n = 3 - if unified_inventory.lite_mode then - formspec = "size[11,7.7]" - formspec = formspec .. "background[-0.19,-0.2;11.4,8.4;ui_form_bg.png]" + if draw_lite_mode then + formspec[1] = "size[11,7.7]" + formspec[2] = "background[-0.19,-0.2;11.4,8.4;ui_form_bg.png]" end - local fsdata = nil + if unified_inventory.is_creative(player_name) + and page == "craft" then + formspec[n] = "background[0,"..(ui_peruser.formspec_y + 2)..";1,1;ui_single_slot.png]" + n = n+1 + end -- Current page - if unified_inventory.pages[page] then - fsdata = pagedef.get_formspec(player) - formspec = formspec .. fsdata.formspec - else + if not unified_inventory.pages[page] then return "" -- Invalid page name end - local privs = minetest.get_player_privs(player_name) --Modif MFF (Crabman 30/06/2015) DEBUT,12 buttons max by row and not show if player has not privs requiered + local perplayer_formspec = unified_inventory.get_per_player_formspec(player_name) + local fsdata = pagedef.get_formspec(player, perplayer_formspec) + + formspec[n] = fsdata.formspec + n = n+1 + + local privs = minetest.get_player_privs(player_name) --Modif MFF (Crabman 13/10/2015) not show if player has not privs requiered local button_row = 0 local button_col = 0 - local i = 1 -- Main buttons - for _, def in pairs(unified_inventory.buttons) do - if (def.show_with == nil or def.show_with == false) or (privs[def.show_with] and privs[def.show_with] == true) then - if unified_inventory.lite_mode and i > 4 then - button_row = 1 - button_col = 1 - elseif not unified_inventory.lite_mode and i > 12 then - button_row = 1 - i = 1 - end - local tooltip = def.tooltip or "" - if def.type == "image" then - formspec = formspec.."image_button[" - ..( unified_inventory.main_button_x + 0.65 * (i - 1) - button_col * 0.65 * 4) - ..","..(unified_inventory.main_button_y + button_row * 0.7)..";0.8,0.8;" - ..minetest.formspec_escape(def.image)..";" - ..minetest.formspec_escape(def.name)..";]" - .."tooltip["..minetest.formspec_escape(def.name) - ..";"..tooltip.."]" - end - i = i + 1 + local filtered_inv_buttons = {} + + for i, def in pairs(unified_inventory.buttons) do + if not (draw_lite_mode and def.hide_lite) and (not def.show_with or (privs[def.show_with] and privs[def.show_with] == true)) then --Modif MFF (Crabman 13/10/2015) not show if player has not privs requiered + table.insert(filtered_inv_buttons, def) end - end --Modif MFF (Crabman 30/06/2015) FIN + end + + local i = 1 --Modif MFF (Crabman 13/10/2015) 12 buttons max by row + for i, def in pairs(filtered_inv_buttons) do --Modif MFF (Crabman 13/10/2015) + + if draw_lite_mode and i > 4 then + button_row = 1 + button_col = 1 + elseif not draw_lite_mode and i > 12 then --Modif MFF (Crabman 13/10/2015) + button_row = 1 + i = 1 + end + + if def.type == "image" then + formspec[n] = "image_button[" + formspec[n+1] = ( ui_peruser.main_button_x + 0.65 * (i - 1) - button_col * 0.65 * 4) + formspec[n+2] = ","..(ui_peruser.main_button_y + button_row * 0.7)..";0.8,0.8;" + formspec[n+3] = minetest.formspec_escape(def.image)..";" + formspec[n+4] = minetest.formspec_escape(def.name)..";]" + formspec[n+5] = "tooltip["..minetest.formspec_escape(def.name) + formspec[n+6] = ";"..(def.tooltip or "").."]" + n = n+7 + end + i = i + 1 --Modif MFF (Crabman 13/10/2015) + end if fsdata.draw_inventory ~= false then -- Player inventory - formspec = formspec.."listcolors[#00000000;#00000000]" - formspec = formspec .. "list[current_player;main;0,"..(unified_inventory.formspec_y + 3.5)..";8,4;]" + formspec[n] = "listcolors[#00000000;#00000000]" + formspec[n+1] = "list[current_player;main;0,"..(ui_peruser.formspec_y + 3.5)..";8,4;]" + n = n+2 end if fsdata.draw_item_list == false then - return formspec + return table.concat(formspec, "") end -- Controls to flip items pages local start_x = 9.2 - if not unified_inventory.lite_mode then - formspec = formspec - .. "image_button[" .. (start_x + 0.6 * 0) + if not draw_lite_mode then + formspec[n] = + "image_button[" .. (start_x + 0.6 * 0) .. ",9;.8,.8;ui_skip_backward_icon.png;start_list;]" .. "tooltip[start_list;" .. minetest.formspec_escape(S("First page")) .. "]" @@ -109,8 +161,8 @@ function unified_inventory.get_formspec(player, page) .. ",9;.8,.8;ui_skip_forward_icon.png;end_list;]" .. "tooltip[end_list;" .. minetest.formspec_escape(S("Last page")) .. "]" else - formspec = formspec - .. "image_button[" .. (8.2 + 0.65 * 0) + formspec[n] = + "image_button[" .. (8.2 + 0.65 * 0) .. ",5.8;.8,.8;ui_skip_backward_icon.png;start_list;]" .. "tooltip[start_list;" .. minetest.formspec_escape(S("First page")) .. "]" .. "image_button[" .. (8.2 + 0.65 * 1) @@ -123,70 +175,76 @@ function unified_inventory.get_formspec(player, page) .. ",5.8;.8,.8;ui_skip_forward_icon.png;end_list;]" .. "tooltip[end_list;" .. minetest.formspec_escape(S("Last page")) .. "]" end + n = n+1 -- Search box - if not unified_inventory.lite_mode then - formspec = formspec .. "field[9.5,8.325;3,1;searchbox;;" + if not draw_lite_mode then + formspec[n] = "field[9.5,8.325;3,1;searchbox;;" .. minetest.formspec_escape(unified_inventory.current_searchbox[player_name]) .. "]" - formspec = formspec .. "image_button[12.2,8.1;.8,.8;ui_search_icon.png;searchbutton;]" + formspec[n+1] = "image_button[12.2,8.1;.8,.8;ui_search_icon.png;searchbutton;]" .. "tooltip[searchbutton;" ..S("Search") .. "]" else - formspec = formspec .. "field[8.5,5.225;2.2,1;searchbox;;" + formspec[n] = "field[8.5,5.225;2.2,1;searchbox;;" .. minetest.formspec_escape(unified_inventory.current_searchbox[player_name]) .. "]" - formspec = formspec .. "image_button[10.3,5;.8,.8;ui_search_icon.png;searchbutton;]" + formspec[n+1] = "image_button[10.3,5;.8,.8;ui_search_icon.png;searchbutton;]" .. "tooltip[searchbutton;" ..S("Search") .. "]" end + n = n+2 local no_matches = "No matching items" - if unified_inventory.lite_mode then + if draw_lite_mode then no_matches = "No matches." end -- Items list if #unified_inventory.filtered_items_list[player_name] == 0 then - formspec = formspec.."label[8.2,"..unified_inventory.form_header_y..";" .. S(no_matches) .. "]" + formspec[n] = "label[8.2,"..ui_peruser.form_header_y..";" .. S(no_matches) .. "]" else local dir = unified_inventory.active_search_direction[player_name] local list_index = unified_inventory.current_index[player_name] - local page = math.floor(list_index / (unified_inventory.items_per_page) + 1) + local page = math.floor(list_index / (ui_peruser.items_per_page) + 1) local pagemax = math.floor( (#unified_inventory.filtered_items_list[player_name] - 1) - / (unified_inventory.items_per_page) + 1) + / (ui_peruser.items_per_page) + 1) local item = {} - for y = 0, unified_inventory.pagerows - 1 do - for x = 0, unified_inventory.pagecols - 1 do + for y = 0, ui_peruser.pagerows - 1 do + for x = 0, ui_peruser.pagecols - 1 do local name = unified_inventory.filtered_items_list[player_name][list_index] if minetest.registered_items[name] then - formspec = formspec.."item_image_button[" - ..(8.2 + x * 0.7).."," - ..(unified_inventory.formspec_y + unified_inventory.page_y + y * 0.7)..";.81,.81;" - ..name..";item_button_"..dir.."_" - ..unified_inventory.mangle_for_formspec(name)..";]" + formspec[n] = "item_image_button[" + ..(8.2 + x * 0.7).."," + ..(ui_peruser.formspec_y + ui_peruser.page_y + y * 0.7)..";.81,.81;" + ..name..";item_button_"..dir.."_" + ..unified_inventory.mangle_for_formspec(name)..";]" + n = n+1 list_index = list_index + 1 end end end - formspec = formspec.."label[8.2,"..unified_inventory.form_header_y..";"..S("Page") .. ": " + formspec[n] = "label[8.2,"..ui_peruser.form_header_y..";"..S("Page") .. ": " .. S("%s of %s"):format(page,pagemax).."]" end + n= n+1 + if unified_inventory.activefilter[player_name] ~= "" then - formspec = formspec.."label[8.2,"..(unified_inventory.form_header_y + 0.4)..";" .. S("Filter") .. ":]" - formspec = formspec.."label[9.1,"..(unified_inventory.form_header_y + 0.4)..";"..minetest.formspec_escape(unified_inventory.activefilter[player_name]).."]" + formspec[n] = "label[8.2,"..(ui_peruser.form_header_y + 0.4)..";" .. S("Filter") .. ":]" + formspec[n+1] = "label[9.1,"..(ui_peruser.form_header_y + 0.4)..";"..minetest.formspec_escape(unified_inventory.activefilter[player_name]).."]" end - return formspec + return table.concat(formspec, "") end function unified_inventory.set_inventory_formspec(player, page) if player then - local formspec = unified_inventory.get_formspec(player, page) - player:set_inventory_formspec(formspec) + player:set_inventory_formspec(unified_inventory.get_formspec(player, page)) end end --apply filter to the inventory list (create filtered copy of full one) function unified_inventory.apply_filter(player, filter, search_dir) - if not player then return false end + if not player then + return false + end local player_name = player:get_player_name() local lfilter = string.lower(filter) local ffilter @@ -194,7 +252,8 @@ function unified_inventory.apply_filter(player, filter, search_dir) local groups = lfilter:sub(7):split(",") ffilter = function(name, def) for _, group in ipairs(groups) do - if not ((def.groups[group] or 0) > 0) then + if not def.groups[group] + or def.groups[group] <= 0 then return false end end @@ -209,11 +268,13 @@ function unified_inventory.apply_filter(player, filter, search_dir) end unified_inventory.filtered_items_list[player_name]={} for name, def in pairs(minetest.registered_items) do - if (def.groups.not_in_creative_inventory or 0) == 0 - and (def.description or "") ~= "" - and ffilter(name, def) - and (unified_inventory.is_creative(player_name) - or unified_inventory.crafts_for.recipe[def.name]) then + if (not def.groups.not_in_creative_inventory + or def.groups.not_in_creative_inventory == 0) + and def.description + and def.description ~= "" + and ffilter(name, def) + and (unified_inventory.is_creative(player_name) + or unified_inventory.crafts_for.recipe[def.name]) then table.insert(unified_inventory.filtered_items_list[player_name], name) end end @@ -223,7 +284,7 @@ function unified_inventory.apply_filter(player, filter, search_dir) unified_inventory.activefilter[player_name] = filter unified_inventory.active_search_direction[player_name] = search_dir unified_inventory.set_inventory_formspec(player, - unified_inventory.current_page[player_name]) + unified_inventory.current_page[player_name]) end function unified_inventory.items_in_group(groups) diff --git a/mods/unified_inventory/locale/de.txt b/mods/unified_inventory/locale/de.txt index 9f12d8c4..d678b683 100755 --- a/mods/unified_inventory/locale/de.txt +++ b/mods/unified_inventory/locale/de.txt @@ -1,4 +1,4 @@ -# Translation by Xanthin +# Translation mostly by Xanthin ### bags.lua ### Bags = Rucksaecke @@ -11,23 +11,23 @@ Medium Bag = Rucksack (mittel) Large Bag = Rucksack (gross) ### inernal.lua ### -First page = -Back three pages = -Back one page = -Forward one page = -Forward three pages = -Last page = -No matching items = +First page = Erste Seite +Back three pages = Drei Seiten zurueckblaettern +Back one page = Eine Seiten zurueckblaettern +Forward one page = Eine Seiten vorblaettern +Forward three pages = Drei Seiten vorblaettern +Last page = Letzte Seite +No matching items = Keine passenden Gegenstände Page = Seite %s of %s = %s von %s Filter = Suche -Search = +Search = Suchen ### register.lua ### Can use the creative inventory = Kann das Kreativinventar nutzen Home position set to: %s = Ausgangsposition nach: %s gesetzt Time of day set to 6am = Tageszeit auf 6 Uhr morgens geaendert -You don't have the settime priviledge! = Du hast nicht das "settime" Privileg! +You don't have the settime privilege! = Du hast nicht das "settime" Privileg! Time of day set to 9pm = Tageszeit auf 9 Uhr abends geaendert This button has been disabled outside of creative mode to prevent accidental inventory trashing. Use the trash slot instead. = Diese Funktion ist ausserhalb des Kreativmodus deaktiviert um ein versehentliches Loeschen des ganzen Inventars zu verhindern.\nNutze stattdessen das Muellfeld. Inventory Cleared! = Inventar geleert! @@ -45,27 +45,27 @@ Copy to craft grid: = Kopiere ins Baufeld: All = Alles Recipe %s of %s = Rezept %s von %s Alternate = Alternative -Crafting Grid = +Crafting Grid = ### waypoints.lua ### -White = -Yellow = -Red = -Green = -Blue = -Waypoints = -Waypoint active = -Waypoint inactive = -World position = -Name = -HUD text color = -Edit waypoint name = -Rename waypoint = -Change color of waypoint display = -Set waypoint to current location = -Make waypoint visible = -Make waypoint invisible = -Disable display of waypoint coordinates = -Enable display of waypoint coordinates = -Finish editing = -Select Waypoint #%d = +White = Weiß +Yellow = Gelb +Red = Rot +Green = Gruen +Blue = Blau +Waypoints = Markierungen +Waypoint active = Markierung aktiv +Waypoint inactive = Markierung inaktiv +World position = Welt Position +Name = +HUD text color = +Edit waypoint name = Name der Markierung aendern +Rename waypoint = Markierung umbenennen +Change color of waypoint display = Farbe der Darstellung der Markierung aendern +Set waypoint to current location = Setze Markierung zur derzeitigen Position +Make waypoint visible = Markierung sichtbar machen +Make waypoint invisible = Markierung verstecken +Disable display of waypoint coordinates = +Enable display of waypoint coordinates = +Finish editing = +Select Waypoint #%d = diff --git a/mods/unified_inventory/register.lua b/mods/unified_inventory/register.lua index 8aa32dec..068eb239 100755 --- a/mods/unified_inventory/register.lua +++ b/mods/unified_inventory/register.lua @@ -5,6 +5,12 @@ minetest.register_privilege("creative", { give_to_singleplayer = false, }) +minetest.register_privilege("ui_full", { + description = "Forces UI to display in Full mode when Lite mode is configured globally", + give_to_singleplayer = false, +}) + + local trash = minetest.create_detached_inventory("trash", { --allow_put = function(inv, listname, index, stack, player) -- if unified_inventory.is_creative(player:get_player_name()) then @@ -35,73 +41,78 @@ unified_inventory.register_button("craftguide", { show_with = false, --Modif MFF (Crabman 30/06/2015) }) -if not unified_inventory.lite_mode then - unified_inventory.register_button("home_gui_set", { - type = "image", - image = "ui_sethome_icon.png", - tooltip = S("Set home position"), - show_with = "interact", --Modif MFF (Crabman 30/06/2015) - action = function(player) +unified_inventory.register_button("home_gui_set", { + type = "image", + image = "ui_sethome_icon.png", + tooltip = S("Set home position"), + hide_lite=true, + show_with = "interact", --Modif MFF (Crabman 30/06/2015) + action = function(player) if home.sethome(player:get_player_name()) == true then --modif MFF minetest.sound_play("dingdong", {to_player=player:get_player_name(), gain = 1.0}) end end, - }) +}) - unified_inventory.register_button("home_gui_go", { - type = "image", - image = "ui_gohome_icon.png", - tooltip = S("Go home"), - show_with = "interact", --Modif MFF (Crabman 30/06/2015) - action = function(player) - if home.tohome(player:get_player_name()) == true then --modif MFF - minetest.sound_play("teleport", - {to_player=player:get_player_name(), gain = 1.0}) - end - end, - }) - unified_inventory.register_button("misc_set_day", { - type = "image", - image = "ui_sun_icon.png", - tooltip = S("Set time to day"), - show_with = "settime", --Modif MFF (Crabman 30/06/2015) - action = function(player) - local player_name = player:get_player_name() - if minetest.check_player_privs(player_name, {settime=true}) then - minetest.sound_play("birds", - {to_player=player_name, gain = 1.0}) - minetest.set_timeofday((6000 % 24000) / 24000) - minetest.chat_send_player(player_name, - S("Time of day set to 6am")) - else - minetest.chat_send_player(player_name, - S("You don't have the settime priviledge!")) - end - end, - }) - unified_inventory.register_button("misc_set_night", { - type = "image", - image = "ui_moon_icon.png", - tooltip = S("Set time to night"), - show_with = "settime", --Modif MFF (Crabman 30/06/2015) - action = function(player) - local player_name = player:get_player_name() - if minetest.check_player_privs(player_name, {settime=true}) then - minetest.sound_play("owl", - {to_player=player_name, gain = 1.0}) - minetest.set_timeofday((21000 % 24000) / 24000) - minetest.chat_send_player(player_name, - S("Time of day set to 9pm")) - else - minetest.chat_send_player(player_name, - S("You don't have the settime priviledge!")) - end - end, - }) -end + +unified_inventory.register_button("home_gui_go", { + type = "image", + image = "ui_gohome_icon.png", + tooltip = S("Go home"), + hide_lite=true, + show_with = "interact", --Modif MFF (Crabman 30/06/2015) + action = function(player) + if home.tohome(player:get_player_name()) == true then --modif MFF + minetest.sound_play("teleport", + {to_player=player:get_player_name(), gain = 1.0}) + end + end, +}) + +unified_inventory.register_button("misc_set_day", { + type = "image", + image = "ui_sun_icon.png", + tooltip = S("Set time to day"), + hide_lite=true, + show_with = "settime", --Modif MFF (Crabman 30/06/2015) + action = function(player) + local player_name = player:get_player_name() + if minetest.check_player_privs(player_name, {settime=true}) then + minetest.sound_play("birds", + {to_player=player_name, gain = 1.0}) + minetest.set_timeofday((6000 % 24000) / 24000) + minetest.chat_send_player(player_name, + S("Time of day set to 6am")) + else + minetest.chat_send_player(player_name, + S("You don't have the settime privilege!")) + end + end, +}) + +unified_inventory.register_button("misc_set_night", { + type = "image", + image = "ui_moon_icon.png", + tooltip = S("Set time to night"), + hide_lite=true, + show_with = "settime", --Modif MFF (Crabman 30/06/2015) + action = function(player) + local player_name = player:get_player_name() + if minetest.check_player_privs(player_name, {settime=true}) then + minetest.sound_play("owl", + {to_player=player_name, gain = 1.0}) + minetest.set_timeofday((21000 % 24000) / 24000) + minetest.chat_send_player(player_name, + S("Time of day set to 9pm")) + else + minetest.chat_send_player(player_name, + S("You don't have the settime privilege!")) + end + end, +}) unified_inventory.register_button("clear_inv", { type = "image", @@ -126,19 +137,25 @@ unified_inventory.register_button("clear_inv", { }) unified_inventory.register_page("craft", { - get_formspec = function(player, formspec) + get_formspec = function(player, perplayer_formspec) + + local formspecy = perplayer_formspec.formspec_y + local formheadery = perplayer_formspec.form_header_y + local player_name = player:get_player_name() - local formspec = "background[0,"..unified_inventory.formspec_y..";8,3;ui_crafting_form.png]" - formspec = formspec.."background[0,"..(unified_inventory.formspec_y + 3.5)..";8,4;ui_main_inventory.png]" - formspec = formspec.."label[0,"..unified_inventory.form_header_y..";Crafting]" + local formspec = "background[2,"..formspecy..";6,3;ui_crafting_form.png]" + formspec = formspec.."background[0,"..(formspecy + 3.5)..";8,4;ui_main_inventory.png]" + formspec = formspec.."label[0,"..formheadery..";Crafting]" formspec = formspec.."listcolors[#00000000;#00000000]" - formspec = formspec.."list[current_player;craftpreview;6,"..unified_inventory.formspec_y..";1,1;]" - formspec = formspec.."list[current_player;craft;2,"..unified_inventory.formspec_y..";3,3;]" - formspec = formspec.."label[7,"..(unified_inventory.formspec_y + 1.5)..";" .. S("Trash:") .. "]" - formspec = formspec.."list[detached:trash;main;7,"..(unified_inventory.formspec_y + 2)..";1,1;]" + formspec = formspec.."list[current_player;craftpreview;6,"..formspecy..";1,1;]" + formspec = formspec.."list[current_player;craft;2,"..formspecy..";3,3;]" + formspec = formspec.."label[7,"..(formspecy + 1.5)..";" .. S("Trash:") .. "]" + formspec = formspec.."list[detached:trash;main;7,"..(formspecy + 2)..";1,1;]" + formspec = formspec.."listring[current_name;craft]" + formspec = formspec.."listring[current_player;main]" if unified_inventory.is_creative(player_name) then - formspec = formspec.."label[0,"..(unified_inventory.formspec_y + 1.5)..";" .. S("Refill:") .. "]" - formspec = formspec.."list[detached:"..minetest.formspec_escape(player_name).."refill;main;0,"..(unified_inventory.formspec_y +2)..";1,1;]" + formspec = formspec.."label[0,"..(formspecy + 1.5)..";" .. S("Refill:") .. "]" + formspec = formspec.."list[detached:"..minetest.formspec_escape(player_name).."refill;main;0,"..(formspecy +2)..";1,1;]" end return {formspec=formspec} end, @@ -196,12 +213,18 @@ local other_dir = { } unified_inventory.register_page("craftguide", { - get_formspec = function(player) + get_formspec = function(player, perplayer_formspec) + + local formspecy = perplayer_formspec.formspec_y + local formheadery = perplayer_formspec.form_header_y + local craftresultx = perplayer_formspec.craft_result_x + local craftresulty = perplayer_formspec.craft_result_y + local player_name = player:get_player_name() local player_privs = minetest.get_player_privs(player_name) local formspec = "" - formspec = formspec.."background[0,"..(unified_inventory.formspec_y + 3.5)..";8,4;ui_main_inventory.png]" - formspec = formspec.."label[0,"..unified_inventory.form_header_y..";" .. S("Crafting Guide") .. "]" + formspec = formspec.."background[0,"..(formspecy + 3.5)..";8,4;ui_main_inventory.png]" + formspec = formspec.."label[0,"..formheadery..";" .. S("Crafting Guide") .. "]" formspec = formspec.."listcolors[#00000000;#00000000]" local item_name = unified_inventory.current_item[player_name] if not item_name then return {formspec=formspec} end @@ -218,25 +241,25 @@ unified_inventory.register_page("craftguide", { craft = crafts[alternate] end - formspec = formspec.."background[0.5,"..(unified_inventory.formspec_y + 0.2)..";8,3;ui_craftguide_form.png]" - formspec = formspec.."textarea["..unified_inventory.craft_result_x..","..unified_inventory.craft_result_y + formspec = formspec.."background[0.5,"..(formspecy + 0.2)..";8,3;ui_craftguide_form.png]" + formspec = formspec.."textarea["..craftresultx..","..craftresulty ..";10,1;;"..minetest.formspec_escape(role_text[dir]..": "..item_name)..";]" - formspec = formspec..stack_image_button(0, unified_inventory.formspec_y, 1.1, 1.1, "item_button_" + formspec = formspec..stack_image_button(0, formspecy, 1.1, 1.1, "item_button_" .. rdir .. "_", ItemStack(item_name)) if not craft then - formspec = formspec.."label[5.5,"..(unified_inventory.formspec_y + 2.35)..";" + formspec = formspec.."label[5.5,"..(formspecy + 2.35)..";" ..minetest.formspec_escape(no_recipe_text[dir]).."]" local no_pos = dir == "recipe" and 4.5 or 6.5 local item_pos = dir == "recipe" and 6.5 or 4.5 - formspec = formspec.."image["..no_pos..","..unified_inventory.formspec_y..";1.1,1.1;ui_no.png]" - formspec = formspec..stack_image_button(item_pos, unified_inventory.formspec_y, 1.1, 1.1, "item_button_" + formspec = formspec.."image["..no_pos..","..formspecy..";1.1,1.1;ui_no.png]" + formspec = formspec..stack_image_button(item_pos, formspecy, 1.1, 1.1, "item_button_" ..other_dir[dir].."_", ItemStack(item_name)) if player_privs.give == true then - formspec = formspec.."label[0,"..(unified_inventory.formspec_y + 2.10)..";" .. S("Give me:") .. "]" - .."button[0, "..(unified_inventory.formspec_y + 2.7)..";0.6,0.5;craftguide_giveme_1;1]" - .."button[0.6,"..(unified_inventory.formspec_y + 2.7)..";0.7,0.5;craftguide_giveme_10;10]" - .."button[1.3,"..(unified_inventory.formspec_y + 2.7)..";0.8,0.5;craftguide_giveme_99;99]" + formspec = formspec.."label[0,"..(formspecy + 2.10)..";" .. S("Give me:") .. "]" + .."button[0, "..(formspecy + 2.7)..";0.6,0.5;craftguide_giveme_1;1]" + .."button[0.6,"..(formspecy + 2.7)..";0.7,0.5;craftguide_giveme_10;10]" + .."button[1.3,"..(formspecy + 2.7)..";0.8,0.5;craftguide_giveme_99;99]" end return {formspec = formspec} end @@ -244,10 +267,10 @@ unified_inventory.register_page("craftguide", { local craft_type = unified_inventory.registered_craft_types[craft.type] or unified_inventory.craft_type_defaults(craft.type, {}) if craft_type.icon then - formspec = formspec..string.format(" image[%f,%f;%f,%f;%s]",5.7,(unified_inventory.formspec_y + 0.05),0.5,0.5,craft_type.icon) + formspec = formspec..string.format(" image[%f,%f;%f,%f;%s]",5.7,(formspecy + 0.05),0.5,0.5,craft_type.icon) end - formspec = formspec.."label[5.5,"..(unified_inventory.formspec_y + 1)..";" .. minetest.formspec_escape(craft_type.description).."]" - formspec = formspec..stack_image_button(6.5, unified_inventory.formspec_y, 1.1, 1.1, "item_button_usage_", ItemStack(craft.output)) + formspec = formspec.."label[5.5,"..(formspecy + 1)..";" .. minetest.formspec_escape(craft_type.description).."]" + formspec = formspec..stack_image_button(6.5, formspecy, 1.1, 1.1, "item_button_usage_", ItemStack(craft.output)) local display_size = craft_type.dynamic_display_size and craft_type.dynamic_display_size(craft) or { width = craft_type.width, height = craft_type.height } local craft_width = craft_type.get_shaped_craft_width and craft_type.get_shaped_craft_width(craft) or display_size.width @@ -262,36 +285,36 @@ unified_inventory.register_page("craftguide", { end if item then formspec = formspec..stack_image_button( - xoffset + x, unified_inventory.formspec_y - 1 + y, 1.1, 1.1, + xoffset + x, formspecy - 1 + y, 1.1, 1.1, "item_button_recipe_", ItemStack(item)) else -- Fake buttons just to make grid formspec = formspec.."image_button[" - ..tostring(xoffset + x)..","..tostring(unified_inventory.formspec_y - 1 + y) + ..tostring(xoffset + x)..","..tostring(formspecy - 1 + y) ..";1,1;ui_blank_image.png;;]" end end end if craft_type.uses_crafting_grid then - formspec = formspec.."label[0,"..(unified_inventory.formspec_y + 0.9)..";" .. S("To craft grid:") .. "]" - .."button[0, "..(unified_inventory.formspec_y + 1.5)..";0.6,0.5;craftguide_craft_1;1]" - .."button[0.6,"..(unified_inventory.formspec_y + 1.5)..";0.7,0.5;craftguide_craft_10;10]" - .."button[1.3,"..(unified_inventory.formspec_y + 1.5)..";0.8,0.5;craftguide_craft_max;" .. S("All") .. "]" + formspec = formspec.."label[0,"..(formspecy + 0.9)..";" .. S("To craft grid:") .. "]" + .."button[0, "..(formspecy + 1.5)..";0.6,0.5;craftguide_craft_1;1]" + .."button[0.6,"..(formspecy + 1.5)..";0.7,0.5;craftguide_craft_10;10]" + .."button[1.3,"..(formspecy + 1.5)..";0.8,0.5;craftguide_craft_max;" .. S("All") .. "]" end if player_privs.give then - formspec = formspec.."label[0,"..(unified_inventory.formspec_y + 2.1)..";" .. S("Give me:") .. "]" - .."button[0, "..(unified_inventory.formspec_y + 2.7)..";0.6,0.5;craftguide_giveme_1;1]" - .."button[0.6,"..(unified_inventory.formspec_y + 2.7)..";0.7,0.5;craftguide_giveme_10;10]" - .."button[1.3,"..(unified_inventory.formspec_y + 2.7)..";0.8,0.5;craftguide_giveme_99;99]" + formspec = formspec.."label[0,"..(formspecy + 2.1)..";" .. S("Give me:") .. "]" + .."button[0, "..(formspecy + 2.7)..";0.6,0.5;craftguide_giveme_1;1]" + .."button[0.6,"..(formspecy + 2.7)..";0.7,0.5;craftguide_giveme_10;10]" + .."button[1.3,"..(formspecy + 2.7)..";0.8,0.5;craftguide_giveme_99;99]" end if alternates and alternates > 1 then - formspec = formspec.."label[5.5,"..(unified_inventory.formspec_y + 1.6)..";"..recipe_text[dir].." " + formspec = formspec.."label[5.5,"..(formspecy + 1.6)..";"..recipe_text[dir].." " ..tostring(alternate).." of " ..tostring(alternates).."]" - .."button[5.5,"..(unified_inventory.formspec_y + 2)..";2,1;alternate;" .. S("Alternate") .. "]" + .."button[5.5,"..(formspecy + 2)..";2,1;alternate;" .. S("Alternate") .. "]" end return {formspec = formspec} end, @@ -318,6 +341,80 @@ local function craftguide_giveme(player, formname, fields) player_inv:add_item("main", {name = output, count = amount}) end +-- tells if an item can be moved and returns an index if so +local function item_fits(player_inv, craft_item, needed_item) + local need_group = string.sub(needed_item, 1, 6) == "group:" + if need_group then + need_group = string.sub(needed_item, 7) + end + if craft_item + and not craft_item:is_empty() then + local ciname = craft_item:get_name() + + -- abort if the item there isn't usable + if ciname ~= needed_item + and not need_group then + return + end + + -- abort if no item fits onto it + if craft_item:get_count() >= craft_item:get_definition().stack_max then + return + end + + -- use the item there if it's in the right group and a group item is needed + if need_group then + if minetest.get_item_group(ciname, need_group) == 0 then + return + end + needed_item = ciname + need_group = false + end + end + + if need_group then + -- search an item of the specific group + for i,item in pairs(player_inv:get_list("main")) do + if not item:is_empty() + and minetest.get_item_group(item:get_name(), need_group) > 0 then + return i + end + end + + -- no index found + return + end + + -- search an item with a the name needed_item + for i,item in pairs(player_inv:get_list("main")) do + if not item:is_empty() + and item:get_name() == needed_item then + return i + end + end + + -- no index found +end + +-- modifies the player inventory and returns the changed craft_item if possible +local function move_item(player_inv, craft_item, needed_item) + local stackid = item_fits(player_inv, craft_item, needed_item) + if not stackid then + return + end + local wanted_stack = player_inv:get_stack("main", stackid) + local taken_item = wanted_stack:take_item() + player_inv:set_stack("main", stackid, wanted_stack) + + if not craft_item + or craft_item:is_empty() then + return taken_item + end + + craft_item:add_item(taken_item) + return craft_item +end + local function craftguide_craft(player, formname, fields) local amount for k, v in pairs(fields) do @@ -350,11 +447,13 @@ local function craftguide_craft(player, formname, fields) width = 3 end + amount = tonumber(amount) or 99 + --[[ if amount == "max" then amount = 99 -- Arbitrary; need better way to do this. else amount = tonumber(amount) - end + end--]] for iter = 1, amount do local index = 1 @@ -364,17 +463,9 @@ local function craftguide_craft(player, formname, fields) if needed_item then local craft_index = ((y - 1) * 3) + x local craft_item = craft_list[craft_index] - if (not craft_item) or (craft_item:is_empty()) or (craft_item:get_name() == needed_item) then - local itemname = craft_item and craft_item:get_name() or needed_item - local needed_stack = ItemStack(needed_item) - if player_inv:contains_item("main", needed_stack) then - local count = (craft_item and craft_item:get_count() or 0) + 1 - if count <= needed_stack:get_definition().stack_max then - local stack = ItemStack({name=needed_item, count=count}) - craft_list[craft_index] = stack - player_inv:remove_item("main", needed_stack) - end - end + local newitem = move_item(player_inv, craft_item, needed_item) + if newitem then + craft_list[craft_index] = newitem end end index = index + 1 @@ -391,10 +482,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) for k, v in pairs(fields) do if k:match("craftguide_craft_") then craftguide_craft(player, formname, fields) - break - elseif k:match("craftguide_giveme_") then + return + end + if k:match("craftguide_giveme_") then craftguide_giveme(player, formname, fields) - break + return end end end) diff --git a/mods/unified_inventory/textures/ui_colorbutton0.png b/mods/unified_inventory/textures/ui_colorbutton0.png deleted file mode 100755 index 3d4889be..00000000 Binary files a/mods/unified_inventory/textures/ui_colorbutton0.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_colorbutton1.png b/mods/unified_inventory/textures/ui_colorbutton1.png deleted file mode 100755 index c63cd673..00000000 Binary files a/mods/unified_inventory/textures/ui_colorbutton1.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_colorbutton10.png b/mods/unified_inventory/textures/ui_colorbutton10.png deleted file mode 100755 index d85f91e4..00000000 Binary files a/mods/unified_inventory/textures/ui_colorbutton10.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_colorbutton11.png b/mods/unified_inventory/textures/ui_colorbutton11.png deleted file mode 100755 index f3fd106a..00000000 Binary files a/mods/unified_inventory/textures/ui_colorbutton11.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_colorbutton12.png b/mods/unified_inventory/textures/ui_colorbutton12.png deleted file mode 100755 index d4d0be89..00000000 Binary files a/mods/unified_inventory/textures/ui_colorbutton12.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_colorbutton13.png b/mods/unified_inventory/textures/ui_colorbutton13.png deleted file mode 100755 index 19e0960b..00000000 Binary files a/mods/unified_inventory/textures/ui_colorbutton13.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_colorbutton14.png b/mods/unified_inventory/textures/ui_colorbutton14.png deleted file mode 100755 index ff385e45..00000000 Binary files a/mods/unified_inventory/textures/ui_colorbutton14.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_colorbutton15.png b/mods/unified_inventory/textures/ui_colorbutton15.png deleted file mode 100755 index afdf0de4..00000000 Binary files a/mods/unified_inventory/textures/ui_colorbutton15.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_colorbutton2.png b/mods/unified_inventory/textures/ui_colorbutton2.png deleted file mode 100755 index d52f6713..00000000 Binary files a/mods/unified_inventory/textures/ui_colorbutton2.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_colorbutton3.png b/mods/unified_inventory/textures/ui_colorbutton3.png deleted file mode 100755 index 9366fbe2..00000000 Binary files a/mods/unified_inventory/textures/ui_colorbutton3.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_colorbutton4.png b/mods/unified_inventory/textures/ui_colorbutton4.png deleted file mode 100755 index cb6ffeee..00000000 Binary files a/mods/unified_inventory/textures/ui_colorbutton4.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_colorbutton5.png b/mods/unified_inventory/textures/ui_colorbutton5.png deleted file mode 100755 index f1e7ca01..00000000 Binary files a/mods/unified_inventory/textures/ui_colorbutton5.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_colorbutton6.png b/mods/unified_inventory/textures/ui_colorbutton6.png deleted file mode 100755 index 07d5b604..00000000 Binary files a/mods/unified_inventory/textures/ui_colorbutton6.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_colorbutton7.png b/mods/unified_inventory/textures/ui_colorbutton7.png deleted file mode 100755 index 951d52ec..00000000 Binary files a/mods/unified_inventory/textures/ui_colorbutton7.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_colorbutton8.png b/mods/unified_inventory/textures/ui_colorbutton8.png deleted file mode 100755 index 904116ed..00000000 Binary files a/mods/unified_inventory/textures/ui_colorbutton8.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_colorbutton9.png b/mods/unified_inventory/textures/ui_colorbutton9.png deleted file mode 100755 index cde440f9..00000000 Binary files a/mods/unified_inventory/textures/ui_colorbutton9.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_copper_chest_inventory.png b/mods/unified_inventory/textures/ui_copper_chest_inventory.png deleted file mode 100755 index 0790d5c2..00000000 Binary files a/mods/unified_inventory/textures/ui_copper_chest_inventory.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_crafting_form.png b/mods/unified_inventory/textures/ui_crafting_form.png index e25d891c..420323c2 100755 Binary files a/mods/unified_inventory/textures/ui_crafting_form.png and b/mods/unified_inventory/textures/ui_crafting_form.png differ diff --git a/mods/unified_inventory/textures/ui_furnace_inventory.png b/mods/unified_inventory/textures/ui_furnace_inventory.png deleted file mode 100755 index ea37f349..00000000 Binary files a/mods/unified_inventory/textures/ui_furnace_inventory.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_gold_chest_inventory.png b/mods/unified_inventory/textures/ui_gold_chest_inventory.png deleted file mode 100755 index 5c441112..00000000 Binary files a/mods/unified_inventory/textures/ui_gold_chest_inventory.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_hv_battery_box.png b/mods/unified_inventory/textures/ui_hv_battery_box.png deleted file mode 100755 index 3131714c..00000000 Binary files a/mods/unified_inventory/textures/ui_hv_battery_box.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_iron_chest_inventory.png b/mods/unified_inventory/textures/ui_iron_chest_inventory.png deleted file mode 100755 index 9e66d6c9..00000000 Binary files a/mods/unified_inventory/textures/ui_iron_chest_inventory.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_lv_alloy_furnace.png b/mods/unified_inventory/textures/ui_lv_alloy_furnace.png deleted file mode 100755 index 453d0f8a..00000000 Binary files a/mods/unified_inventory/textures/ui_lv_alloy_furnace.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_lv_battery_box.png b/mods/unified_inventory/textures/ui_lv_battery_box.png deleted file mode 100755 index 3131714c..00000000 Binary files a/mods/unified_inventory/textures/ui_lv_battery_box.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_lv_electric_furnace.png b/mods/unified_inventory/textures/ui_lv_electric_furnace.png deleted file mode 100755 index 67611a86..00000000 Binary files a/mods/unified_inventory/textures/ui_lv_electric_furnace.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_lv_grinder.png b/mods/unified_inventory/textures/ui_lv_grinder.png deleted file mode 100755 index c53e3d61..00000000 Binary files a/mods/unified_inventory/textures/ui_lv_grinder.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_mithril_chest_inventory.png b/mods/unified_inventory/textures/ui_mithril_chest_inventory.png deleted file mode 100755 index 9061ab12..00000000 Binary files a/mods/unified_inventory/textures/ui_mithril_chest_inventory.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_mv_battery_box.png b/mods/unified_inventory/textures/ui_mv_battery_box.png deleted file mode 100755 index 3131714c..00000000 Binary files a/mods/unified_inventory/textures/ui_mv_battery_box.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_silver_chest_inventory.png b/mods/unified_inventory/textures/ui_silver_chest_inventory.png deleted file mode 100755 index 85cbae2a..00000000 Binary files a/mods/unified_inventory/textures/ui_silver_chest_inventory.png and /dev/null differ diff --git a/mods/unified_inventory/textures/ui_single_slot.png b/mods/unified_inventory/textures/ui_single_slot.png new file mode 100755 index 00000000..ef2a2465 Binary files /dev/null and b/mods/unified_inventory/textures/ui_single_slot.png differ diff --git a/mods/unified_inventory/textures/ui_wooden_chest_inventory.png b/mods/unified_inventory/textures/ui_wooden_chest_inventory.png deleted file mode 100755 index 58a93df3..00000000 Binary files a/mods/unified_inventory/textures/ui_wooden_chest_inventory.png and /dev/null differ diff --git a/mods/unified_inventory/waypoints.lua b/mods/unified_inventory/waypoints.lua index 7f91a74d..4e99d75f 100755 --- a/mods/unified_inventory/waypoints.lua +++ b/mods/unified_inventory/waypoints.lua @@ -16,6 +16,11 @@ local waypoints_temp = {} unified_inventory.register_page("waypoints", { get_formspec = function(player) local player_name = player:get_player_name() + + -- build a "fake" temp entry if the server took too long + -- during sign-on and returned an empty entry + if not waypoints_temp[player_name] then waypoints_temp[player_name] = {hud = 1} end + local waypoints = datastorage.get(player_name, "waypoints") local formspec = "background[0,4.5;8,4;ui_main_inventory.png]" .. "image[0,0;1,1;ui_waypoints_icon.png]" .. @@ -107,6 +112,7 @@ unified_inventory.register_button("waypoints", { type = "image", image = "ui_waypoints_icon.png", tooltip = S("Waypoints"), + hide_lite=true, show_with = false, --Modif MFF (Crabman 30/06/2015) })