deivan wrote:Don't be a cry baby.... Is a function, you give the group and the function return a item from the group... Easy and clear...
Yeah, fuck it, why be polite?
deivan wrote:Don't be a cry baby.... Is a function, you give the group and the function return a item from the group... Easy and clear...
deivan wrote:Don't be a cry baby.... Is a function, you give the group and the function return a item from the group... Easy and clear...
Don wrote:This is the bug that is discussed above. Glass is made by cooking group:sand. Hopefully someone will fix this soon.
arcturian_vagabond wrote:I'll wait for a fix then. Thanks for the confirmation.
Miner59 wrote:The code for the "You need" feature is very hacky :-(
Miner59 wrote:but it's more informative maybe for machines from technic mod.
Miner59 wrote:Do you think I can name this feature "Purchase list"?
cornernote wrote:How on earth did you code it with no tab indentation!? My brain can't even think about the code unless I indent it.
Linuxdirk wrote:Miner59 wrote:The code for the "You need" feature is very hacky :-(
And it replaces the bookmarks :(
Napiophelios wrote:there is room if you ditch to chitchat about "Learn to craft..."
Napiophelios wrote:First time users may not know how to get things started.
Linuxdirk wrote:Napiophelios wrote:First time users may not know how to get things started.
Well, first-time users could/should/did read this. The text could be extended and usage instructions could be given there for people that are too lazy to click the link leading to the instructions.
--- newest_git.lua 2014-12-14 16:33:08.000000000 +0100
+++ api_craft_guide.lua 2014-12-14 17:00:44.000000000 +0100
@@ -18,8 +18,6 @@
-- define api variables
craft_guide.crafts = {}
-craft_guide.groups = {}
-craft_guide.group_messages = {}
-- log
@@ -51,6 +49,11 @@
if search == nil then
search = meta:get_string("search")
end
+ if meta:get_string("formspec")=="" then
+ meta:set_string("saved_search","|")
+ meta:set_string("saved_page","1")
+ meta:set_string("saved_pages","1")
+ end
if page == nil then
page = craft_guide.get_current_page(meta)
end
@@ -59,7 +62,7 @@
end
local inv = meta:get_inventory()
local size = inv:get_size("main")
- local start = (page-1) * (5*14) + 1
+ local start = (page-1) * (5*14) --was one too much before
local pages = math.floor((size-1) / (5*14) + 1)
local alternates = 0
local stack = inv:get_stack("output",1)
@@ -67,6 +70,126 @@
if crafts ~= nil then
alternates = #crafts
end
+ local build=""
+ for ii=1,9,1 do
+ local build_old=build
+ local build_stack = inv:get_stack("build",ii)
+ if build_stack~=nil then
+ local build_name=build_stack:get_name()
+ if string.sub(build_name,1,6)=="group:" then
+ local groups=string.sub(build_name,7)
+ local saved=""
+ for name,def in pairs(minetest.registered_items) do
+ local hasgroup=1
+ for group in string.gmatch(groups,"([^,]+)") do
+ if minetest.get_item_group(name, group)==0 then
+ hasgroup=0
+ end
+ end
+ if hasgroup==1 then
+ --prefer items from default mod
+ if string.sub(name,1,8)=="default:" then
+ build=build.."item_image_button["..tostring(2+((ii-1)%3))..","
+ ..tostring(7+math.floor((ii-1)/3))..";1,1;"
+ ..name..";t_758s"..tostring(ii)..";group]"
+ .."tooltip[t_758s"..tostring(ii)..";"..string.upper(string.sub(groups,1,1))..string.sub(groups.." ",2).."]"
+
+ saved=""
+ break
+ else
+ saved=name
+ end
+ end
+ end
+ if saved~="" then
+ build=build.."item_image_button["..tostring(2+((ii-1)%3))..","
+ ..tostring(7+math.floor((ii-1)/3))..";1,1;"..saved..";t_758s"..tostring(ii)..";group]"
+ .."tooltip[t_758s"..tostring(ii)..";"..string.upper(string.sub(groups,1,1))..string.sub(groups.." ",2).."]"
+ end
+ end
+ end
+ if build_old==build then
+ build=build.."list[current_name;build;"..tostring(2+((ii-1)%3))..","..tostring(7+math.floor((ii-1)/3))..";1,1;"..tostring(ii-1).."]"
+ end
+ end
+ local cook=""
+ local cook_stack = inv:get_stack("cook",1)
+ if cook_stack~=nil then
+ local cook_name=cook_stack:get_name()
+ if string.sub(cook_name,1,6)=="group:" then
+ local groups=string.sub(cook_name,7)
+ local saved=""
+ for name,def in pairs(minetest.registered_items) do
+ local hasgroup=1
+ for group in string.gmatch(groups,"([^,]+)") do
+ if minetest.get_item_group(name, group)==0 then
+ hasgroup=0
+ end
+ end
+ if hasgroup==1 then
+ if string.sub(name,1,8)=="default:" then
+ cook="item_image_button[6,7;1,1;"..name..";c_758s1;group]"
+ .."tooltip[c_758s1;"..string.upper(string.sub(groups,1,1))..string.sub(groups.." ",2).."]"
+
+ saved=""
+ break
+ else
+ saved=name
+ end
+ end
+ end
+ if saved~="" then
+ cook="item_image_button[6,7;1,1;"..saved..";c_758s1;group]"
+ .."tooltip[c_758s1;"..string.upper(string.sub(groups,1,1))..string.sub(groups.." ",2).."]"
+ end
+ end
+ if cook=="" then
+ cook="list[current_name;cook;6,7;1,1;]"
+ end
+ end
+
+ local fuel=""
+ local fuel_stack = inv:get_stack("fuel",1)
+ if fuel_stack~=nil then
+ local fuel_name=fuel_stack:get_name()
+ if string.sub(fuel_name,1,6)=="group:" then
+ local groups=string.sub(fuel_name,7)
+ local saved=""
+ for name,def in pairs(minetest.registered_items) do
+ local hasgroup=1
+ for group in string.gmatch(groups,"([^,]+)") do
+ if minetest.get_item_group(name, group)==0 then
+ hasgroup=0
+ end
+ end
+ if hasgroup==1 then
+ if string.sub(name,1,8)=="default:" then
+ fuel="item_image_button[6,7;1,1;"..name..";f_758s1;group]"
+ .."tooltip[f_758s1;"..string.upper(string.sub(groups,1,1))..string.sub(groups.." ",2).."]"
+
+ saved=""
+ break
+ else
+ saved=name
+ end
+ end
+ end
+ if saved~="" then
+ fuel="item_image_button[6,7;1,1;"..saved..";f_758s1;group]"
+ .."tooltip[f_758s1;"..string.upper(string.sub(groups,1,1))..string.sub(groups.." ",2).."]"
+ end
+ end
+ if fuel=="" then
+ fuel="list[current_name;fuel;6,9;1,1;]"
+ end
+ end
+
+ back=""
+ if meta:get_string("saved_search")~="|" then
+ back="button[6,5.8;2.7,1;back_button;<--- Back]"
+ end
+
+
local formspec = "size[14,10;]"
.."list[current_name;main;0,0;14,5;"..tostring(start).."]"
@@ -76,7 +199,7 @@
.."field[6,5.4;2,1;craft_guide_search_box;;"..tostring(search).."]"
.."button[7.5,5.1;1.2,1;craft_guide_search_button;Search]"
-
+ ..back
.."label[9,5.2;page "..tostring(page).." of "..tostring(pages).."]"
.."button[11,5;1.5,1;craft_guide_prev;<<]"
.."button[12.5,5;1.5,1;craft_guide_next;>>]"
@@ -85,13 +208,11 @@
.."list[current_name;output;0,7;1,1;]"
.."label[2,6.5;Inventory Craft]"
- .."list[current_name;build;2,7;3,3;]"
-
+ ..build
.."label[6,6.5;Cook]"
- .."list[current_name;cook;6,7;1,1;]"
+ ..cook
.."label[6,8.5;Fuel]"
- .."list[current_name;fuel;6,9;1,1;]"
-
+ ..fuel
.."label[8,6.5;Bookmarks]"
.."list[current_name;bookmark;8,7;6,3;]"
@@ -142,23 +263,43 @@
-- search
search = fields.craft_guide_search_box
+ if search~=nil then
+ --empty search input when there is no caracter or digit, "*" displays all items registered
+ if string.lower(search)==string.upper(search) and tonumber(search)==nil and search~="*" then
+ search=""
+ end
+ end
+
meta:set_string("search", search)
if fields.craft_guide_search_button then
+ meta:set_string("saved_search", "|")
page = 1
end
-- change page
if fields.craft_guide_prev then
page = page - 1
+ if page < 1 then
+ page = pages
+ end
+
end
if fields.craft_guide_next then
page = page + 1
- end
- if page < 1 then
+ if page > pages then
page = 1
end
- if page > pages then
- page = pages
+ end
+
+ if fields.back_button then
+ local saved = meta:get_string("saved_search")
+ if saved~="|" then
+ search=saved
+ meta:set_string("search", saved)
+ page=tonumber(meta:get_string("saved_page"))
+ pages=tonumber(meta:get_string("saved_pages"))
+ meta:set_string("saved_search", "|")
+ end
end
-- get an alternate recipe
@@ -170,6 +311,177 @@
alternate = 1
end
+ --group buttons
+ local starts=""
+ local ends=""
+ local xx=""
+ local formspec = meta:get_string("formspec")
+ if fields.c_758s1 then --cook
+ xx,starts=string.find(formspec,"tooltip%[c_758s1;")
+ if starts~=nil then
+ ends,xx=string.find(formspec,"%]",starts+1)
+ local group=string.lower(string.sub(formspec,starts+1,ends-2))
+ meta:set_string("search", "group:"..group)
+ if meta:get_string("saved_search")=="|" then
+ meta:set_string("saved_search", search)
+ meta:set_string("saved_page", tostring(page))
+ meta:set_string("saved_pages", tostring(pages))
+ end
+ page = 1
+ search="group:"..group
+ end
+ end
+ if fields.f_758s1 then --fuel
+ xx,starts=string.find(formspec,"tooltip%[f_758s1;")
+ if starts~=nil then
+ ends,xx=string.find(formspec,"%]",starts+1)
+ local group=string.lower(string.sub(formspec,starts+1,ends-2))
+ meta:set_string("search", "group:"..group)
+ if meta:get_string("saved_search")=="|" then
+ meta:set_string("saved_search", search)
+ meta:set_string("saved_page", tostring(page))
+ meta:set_string("saved_pages", tostring(pages))
+ end
+ page = 1
+ search="group:"..group
+ end
+ end
+ if fields.t_758s1 then
+ xx,starts=string.find(formspec,"tooltip%[t_758s1;")
+ if starts~=nil then
+ ends,xx=string.find(formspec,"%]",starts+1)
+ local group=string.lower(string.sub(formspec,starts+1,ends-2))
+ meta:set_string("search", "group:"..group)
+ if meta:get_string("saved_search")=="|" then
+ meta:set_string("saved_search", search)
+ meta:set_string("saved_page", tostring(page))
+ meta:set_string("saved_pages", tostring(pages))
+ end
+ page = 1
+ search="group:"..group
+ end
+ end
+ if fields.t_758s2 then
+ xx,starts=string.find(formspec,"tooltip%[t_758s2;")
+ if starts~=nil then
+ ends,xx=string.find(formspec,"%]",starts+1)
+ local group=string.lower(string.sub(formspec,starts+1,ends-2))
+ meta:set_string("search", "group:"..group)
+ if meta:get_string("saved_search")=="|" then
+ meta:set_string("saved_search", search)
+ meta:set_string("saved_page", tostring(page))
+ meta:set_string("saved_pages", tostring(pages))
+ end
+ page = 1
+ search="group:"..group
+ end
+ end
+ if fields.t_758s3 then
+ xx,starts=string.find(formspec,"tooltip%[t_758s3;")
+ if starts~=nil then
+ ends,xx=string.find(formspec,"%]",starts+1)
+ local group=string.lower(string.sub(formspec,starts+1,ends-2))
+ meta:set_string("search", "group:"..group)
+ if meta:get_string("saved_search")=="|" then
+ meta:set_string("saved_search", search)
+ meta:set_string("saved_page", tostring(page))
+ meta:set_string("saved_pages", tostring(pages))
+ end
+ page = 1
+ search="group:"..group
+ end
+ end
+ if fields.t_758s4 then
+ xx,starts=string.find(formspec,"tooltip%[t_758s4;")
+ if starts~=nil then
+ ends,xx=string.find(formspec,"%]",starts+1)
+ local group=string.lower(string.sub(formspec,starts+1,ends-2))
+ meta:set_string("search", "group:"..group)
+ if meta:get_string("saved_search")=="|" then
+ meta:set_string("saved_search", search)
+ meta:set_string("saved_page", tostring(page))
+ meta:set_string("saved_pages", tostring(pages))
+ end
+ page = 1
+ search="group:"..group
+ end
+ end
+ if fields.t_758s5 then
+ xx,starts=string.find(formspec,"tooltip%[t_758s5;")
+ if starts~=nil then
+ ends,xx=string.find(formspec,"%]",starts+1)
+ local group=string.lower(string.sub(formspec,starts+1,ends-2))
+ meta:set_string("search", "group:"..group)
+ if meta:get_string("saved_search")=="|" then
+ meta:set_string("saved_search", search)
+ meta:set_string("saved_page", tostring(page))
+ meta:set_string("saved_pages", tostring(pages))
+ end
+ page = 1
+ search="group:"..group
+ end
+ end
+ if fields.t_758s6 then
+ xx,starts=string.find(formspec,"tooltip%[t_758s6;")
+ if starts~=nil then
+ ends,xx=string.find(formspec,"%]",starts+1)
+ local group=string.lower(string.sub(formspec,starts+1,ends-2))
+ meta:set_string("search", "group:"..group)
+ if meta:get_string("saved_search")=="|" then
+ meta:set_string("saved_search", search)
+ meta:set_string("saved_page", tostring(page))
+ meta:set_string("saved_pages", tostring(pages))
+ end
+ page = 1
+ search="group:"..group
+ end
+ end
+ if fields.t_758s7 then
+ xx,starts=string.find(formspec,"tooltip%[t_758s7;")
+ if starts~=nil then
+ ends,xx=string.find(formspec,"%]",starts+1)
+ local group=string.lower(string.sub(formspec,starts+1,ends-2))
+ meta:set_string("search", "group:"..group)
+ if meta:get_string("saved_search")=="|" then
+ meta:set_string("saved_search", search)
+ meta:set_string("saved_page", tostring(page))
+ meta:set_string("saved_pages", tostring(pages))
+ end
+ page = 1
+ search="group:"..group
+ end
+ end
+ if fields.t_758s8 then
+ xx,starts=string.find(formspec,"tooltip%[t_758s8;")
+ if starts~=nil then
+ ends,xx=string.find(formspec,"%]",starts+1)
+ local group=string.lower(string.sub(formspec,starts+1,ends-2))
+ meta:set_string("search", "group:"..group)
+ if meta:get_string("saved_search")=="|" then
+ meta:set_string("saved_search", search)
+ meta:set_string("saved_page", tostring(page))
+ meta:set_string("saved_pages", tostring(pages))
+ end
+ page = 1
+ search="group:"..group
+ end
+ end
+ if fields.t_758s9 then
+ xx,starts=string.find(formspec,"tooltip%[t_758s9;")
+ if starts~=nil then
+ ends,xx=string.find(formspec,"%]",starts+1)
+ local group=string.lower(string.sub(formspec,starts+1,ends-2))
+ meta:set_string("search", "group:"..group)
+ if meta:get_string("saved_search")=="|" then
+ meta:set_string("saved_search", search)
+ meta:set_string("saved_page", tostring(page))
+ meta:set_string("saved_pages", tostring(pages))
+ end
+ page = 1
+ search="group:"..group
+ end
+ end
+
-- update the formspec
craft_guide.create_inventory(inv, search)
meta:set_string("formspec",craft_guide.get_craft_guide_formspec(meta, search, page, alternate))
@@ -196,8 +508,6 @@
-- update_recipe
craft_guide.update_recipe = function(meta, player, stack, alternate)
- craft_guide.group_messages[player:get_player_name()] = {}
-
local inv = meta:get_inventory()
for i=0,inv:get_size("build"),1 do
inv:set_stack("build", i, nil)
@@ -208,6 +518,8 @@
if stack==nil then return end
inv:set_stack("output", 1, stack:get_name())
+ alternate = tonumber(alternate) or 1
+ craft_guide.log(player:get_player_name().." requests recipe "..alternate.." for "..stack:get_name())
local crafts = craft_guide.crafts[stack:get_name()]
if crafts == nil then
@@ -217,101 +529,105 @@
meta:set_string("formspec",craft_guide.get_craft_guide_formspec(meta))
return
end
- alternate = tonumber(alternate) or 1
if alternate < 1 or alternate > #crafts then
alternate = 1
end
local craft = crafts[alternate]
+
+ -- show me the unknown items
+ craft_guide.log(dump(craft))
+ --minetest.chat_send_player(player:get_player_name(), "recipe for "..stack:get_name()..": "..dump(craft))
+
local itemstack = ItemStack(craft.output)
inv:set_stack("output", 1, itemstack)
-
+
-- cook
if craft.type == "cooking" then
- inv:set_stack("cook", 1, craft_guide.get_item_name(craft.recipe, player))
+ inv:set_stack("cook", 1, craft.recipe)
meta:set_string("formspec",craft_guide.get_craft_guide_formspec(meta))
return
end
-- fuel
if craft.type == "fuel" then
- inv:set_stack("fuel", 1, craft_guide.get_item_name(craft.recipe, player))
+ inv:set_stack("fuel", 1, craft.recipe)
meta:set_string("formspec",craft_guide.get_craft_guide_formspec(meta))
return
end
-- build (shaped or shapeless)
if craft.recipe[1] then
if (type(craft.recipe[1]) == "string") then
- inv:set_stack("build", 1, craft_guide.get_item_name(craft.recipe[1], player))
+ inv:set_stack("build", 1, craft.recipe[1])
else
if craft.recipe[1][1] then
- inv:set_stack("build", 1, craft_guide.get_item_name(craft.recipe[1][1], player))
+ inv:set_stack("build", 1, craft.recipe[1][1])
end
if craft.recipe[1][2] then
- inv:set_stack("build", 2, craft_guide.get_item_name(craft.recipe[1][2], player))
+ inv:set_stack("build", 2, craft.recipe[1][2])
end
if craft.recipe[1][3] then
- inv:set_stack("build", 3, craft_guide.get_item_name(craft.recipe[1][3], player))
+ inv:set_stack("build", 3, craft.recipe[1][3])
end
end
end
if craft.recipe[2] then
if (type(craft.recipe[2]) == "string") then
- inv:set_stack("build", 2, craft_guide.get_item_name(craft.recipe[2], player))
+ inv:set_stack("build", 2, craft.recipe[2])
else
if craft.recipe[2][1] then
- inv:set_stack("build", 4, craft_guide.get_item_name(craft.recipe[2][1], player))
+ inv:set_stack("build", 4, craft.recipe[2][1])
end
if craft.recipe[2][2] then
- inv:set_stack("build", 5, craft_guide.get_item_name(craft.recipe[2][2], player))
+ inv:set_stack("build", 5, craft.recipe[2][2])
end
if craft.recipe[2][3] then
- inv:set_stack("build", 6, craft_guide.get_item_name(craft.recipe[2][3], player))
+ inv:set_stack("build", 6, craft.recipe[2][3])
end
end
end
if craft.recipe[3] then
if (type(craft.recipe[3]) == "string") then
- inv:set_stack("build", 3, craft_guide.get_item_name(craft.recipe[3], player))
+ inv:set_stack("build", 3, craft.recipe[3])
else
if craft.recipe[3][1] then
- inv:set_stack("build", 7, craft_guide.get_item_name(craft.recipe[3][1], player))
+ inv:set_stack("build", 7, craft.recipe[3][1])
end
if craft.recipe[3][2] then
- inv:set_stack("build", 8, craft_guide.get_item_name(craft.recipe[3][2], player))
+ inv:set_stack("build", 8, craft.recipe[3][2])
end
if craft.recipe[3][3] then
- inv:set_stack("build", 9, craft_guide.get_item_name(craft.recipe[3][3], player))
+ inv:set_stack("build", 9, craft.recipe[3][3])
end
end
end
if craft.recipe[4] then
if (type(craft.recipe[4]) == "string") then
- inv:set_stack("build", 4, craft_guide.get_item_name(craft.recipe[4], player))
+ inv:set_stack("build", 4, craft.recipe[4])
end
end
if craft.recipe[5] then
if (type(craft.recipe[5]) == "string") then
- inv:set_stack("build", 5, craft_guide.get_item_name(craft.recipe[5], player))
+ inv:set_stack("build", 5, craft.recipe[5])
end
end
if craft.recipe[6] then
if (type(craft.recipe[6]) == "string") then
- inv:set_stack("build", 6, craft_guide.get_item_name(craft.recipe[6], player))
+ inv:set_stack("build", 6, craft.recipe[6])
end
end
if craft.recipe[7] then
if (type(craft.recipe[7]) == "string") then
- inv:set_stack("build", 7, craft_guide.get_item_name(craft.recipe[7], player))
+ inv:set_stack("build", 7, craft.recipe[7])
end
end
if craft.recipe[8] then
if (type(craft.recipe[8]) == "string") then
- inv:set_stack("build", 8, craft_guide.get_item_name(craft.recipe[8], player))
+ inv:set_stack("build", 8, craft.recipe[8])
end
end
if craft.recipe[9] then
if (type(craft.recipe[9]) == "string") then
- inv:set_stack("build", 9, craft_guide.get_item_name(craft.recipe[9], player))
+ inv:set_stack("build", 9, craft.recipe[9])
end
end
meta:set_string("formspec",craft_guide.get_craft_guide_formspec(meta))
@@ -324,22 +640,47 @@
for name,def in pairs(minetest.registered_items) do
-- local craft_recipe = minetest.get_craft_recipe(name);
-- if craft_recipe.items ~= nil then
- local craft = craft_guide.crafts[name];
- if craft ~= nil then
- if (not def.groups.not_in_craft_guide or def.groups.not_in_craft_guide == 0)
- --and (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0)
- and def.description and def.description ~= "" then
- if search then
- if string.find(def.name, search) or string.find(def.description, search) then
+ local craft = craft_guide.crafts[name];
+ if (not def.groups.not_in_craft_guide or def.groups.not_in_craft_guide == 0)
+ and (craft ~= nil or (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0))
+ --and (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0)
+ and def.description and def.description ~= "" then
+ if search and search~="" then
+ --search used to display groups of items
+ --if you enter something in search field it displays items without crafting recipes too
+ search=string.lower(search)
+ if string.sub(search,1,6)=="group:" then
+ local groups=string.sub(search,7)
+ local hasgroup=0
+ for group in string.gmatch(groups,"([^,]+)") do
+ if minetest.get_item_group(name, group)>0 then
+ hasgroup=1
+ else
+ hasgroup=0
+ break
+ end
+ end
+ if hasgroup==1 then
table.insert(craft_guide_list, name)
end
else
+ search=string.lower(search)
+ local test1=0
+ local test2=0
+ local test3=0
+ test1,test2=string.find(string.lower(def.name.." "), search)
+ test2,test3=string.find(string.lower(def.description.." "), search)
+ if (test1~=nil and test1>0) or (test2~=nil and test2>0) or search=="*" then
+ table.insert(craft_guide_list, name)
+ end
+ end
+ else
+ if craft ~= nil then
table.insert(craft_guide_list, name)
end
end
end
end
-
table.sort(craft_guide_list)
for i=0,inv:get_size("main"),1 do
inv:set_stack("main", i, nil)
@@ -390,57 +731,3 @@
end
--- get an item name, if it's a group then get an item in the group
-craft_guide.get_item_name = function(item_name, player)
- if string.find(item_name, "group:") then
- local group_name = item_name
- if craft_guide.table_count(craft_guide.groups) == 0 then
- craft_guide.load_item_groups()
- end
- if craft_guide.table_count(craft_guide.groups) > 0 then
- local other_items = {}
- if craft_guide.groups[string.sub(group_name, 7)] ~= nil then
- item_name = craft_guide.groups[string.sub(group_name, 7)].item_name
- other_items = craft_guide.groups[string.sub(group_name, 7)].other_items
- if #other_items > 0 then
- if craft_guide.group_messages[player:get_player_name()][item_name] == nil then
- minetest.chat_send_player(player:get_player_name(), "Item "..item_name.." used for "..group_name..". You can also use "..table.concat(other_items, ", ")..".")
- end
- craft_guide.group_messages[player:get_player_name()][item_name] = true
- end
- end
- end
- end
- return item_name
-end
-
-
--- load the item groups table
-craft_guide.load_item_groups = function()
- for name,def in pairs(minetest.registered_items) do
- if name ~= nil and def ~= nil and dump(name) ~= "\"\"" and dump(def) ~= "\"\"" then
- local i = 1
- for group,_ in pairs(def.groups) do
- if craft_guide.groups[group] == nil then
- craft_guide.groups[group] = {}
- craft_guide.groups[group].other_items = {}
- craft_guide.groups[group].item_name = name
- else
- craft_guide.groups[group].other_items[i] = name
- i = i+1
- end
- end
- end
- end
-end
-
-
--- count items in a table
-craft_guide.table_count = function(count_table)
- local count = 0;
- for k,v in pairs(count_table) do
- count = count + 1
- end
- return count
-end
-
cornernote wrote:It was fixed today.
Miner59 wrote:Hi cornernote,
I made a diff file with a formatted version of my code. It adds a button instead of a unknown item, when a crafting recipe contains a item called "group:xy". Also changes search function a bit and adds switching from first to last page and reverse.
Please copy from below.
I can do it for you, but it means github will not mark you as a contributor (although I will still add you to the credits section)
Users browsing this forum: No registered users and 43 guests