[Mod] Zeg9's craft guide [github] [zcg]

User avatar
TenPlus1
Member
Posts: 2936
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

by TenPlus1 » Post

Tried applying same technique to beds mod by pilzadam, didn't work, the craft is too complicated and has all functions within the registered node... pah!

User avatar
TenPlus1
Member
Posts: 2936
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

by TenPlus1 » Post

Tried applying same technique to beds mod by pilzadam, didn't work, the craft is too complicated and has all functions within the registered node... pah!

4aiman
Member
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Post

I don't get it...
It shouldn't matter how one registers any node...
By the time zcg kicks in all crafts should be registered and

Code: Select all

protector.node .. ' 4'
should already be substituted by

Code: Select all

'protector:protector 4'
Could you try to re-read craft recipe every time instead of on 1st run only?

*Also I had found that setting formspec not inside the receive_fields func result in formspec changed but the node itself still shows an old formspec until some button will be pressed*

User avatar
gsmanners
Member
Posts: 159
Joined: Fri Jan 10, 2014 21:37

by gsmanners » Post

I made a few changes to the init file. It's mostly cosmetic changes.

I've been noticing some strange quirks, mostly in various mods (like the beds mod, which uses an alias as its registered craft name).
Attachments
zcg-init.lua.zip
(2.06 KiB) Downloaded 68 times

User avatar
TenPlus1
Member
Posts: 2936
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

by TenPlus1 » Post

gsmanners: beds show using your edited init.lua file but it brings up unknown items for the recipe, adding a simple crafting recipe to the beds mod still doesnt make it show either...

User avatar
gsmanners
Member
Posts: 159
Joined: Fri Jan 10, 2014 21:37

by gsmanners » Post

Yeah, see what I mean about the recipes? A simple wool recipe can get messed up by one outdated mod.

As for the beds, I just renamed them like so:

Code: Select all

output = "beds:bed_bottom_"..colour

User avatar
Napiophelios
Member
Posts: 1025
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: [Mod] Zeg9's craft guide [github] [zcg]

by Napiophelios » Post

I dont know how recipes that use a larger crafting grid show on normal sized computer screens
but I have a tiny netbook and it overlaps terrible

So I modified the formspec to support recipes that use larger crafting grids
+ Spoiler
Furnace textures from Summerfield by LithiumSound
License of media (textures):CC BY-NC-SA 4.0
Attachments
zcg_[modified].zip
supports workbench mod
(22.71 KiB) Downloaded 60 times

User avatar
LazerRay
Member
Posts: 147
Joined: Sun Jul 27, 2014 01:32
GitHub: LazerRay

Re: [Mod] Zeg9's craft guide [github] [zcg]

by LazerRay » Post

This mod is a must have for those who can't remember all the possible crafting recipes, but it tends to get very cluttered when running a lot of mods.

If it is all possible, adding a search bar to the guide will help with this situation, I could use it since I now have over 200 pages of items in the guide.

amadin
Member
Posts: 548
Joined: Tue Jun 16, 2015 16:23

Re: [Mod] Zeg9's craft guide [github] [zcg]

by amadin » Post

Zeg9, do you can add division in craft guide for items like in crafting mod (see creative inventory)?

Image

Crafting mod viewtopic.php?f=11&t=5641&hilit=craftingpack
Attachments
creative.png
(289.11 KiB) Not downloaded yet

User avatar
Neon
Member
Posts: 126
Joined: Thu Aug 15, 2013 02:03
In-game: Neon

Re: [Mod] Zeg9's craft guide [github] [zcg]

by Neon » Post

Had an error with this, from the git version 6bd997e. It didn't seem to impact the game; I wouldn't have noticed, except that I was checking some other interactions when I saw this.

Code: Select all

2016-03-02 23:14:07: ACTION[ServerThread]: player {blah} crafts {something}
Loading all crafts, this may take some time...
23:14:19: WARNING: Assignment to undeclared global "out" inside a function at .minetest/mods/minetest-zcg/zcg/init.lua:28.
All crafts loaded !
23:14:20: WARNING: Assignment to undeclared global "page" inside a function at .minetest/mods/minetest-zcg/zcg/init.lua:103.
23:14:20: WARNING: Assignment to undeclared global "alt" inside a function at .minetest/mods/minetest-zcg/zcg/init.lua:104.
23:14:20: WARNING: Assignment to undeclared global "current_item" inside a function at .minetest/mods/minetest-zcg/zcg/init.lua:105.

User avatar
maikerumine
Member
Posts: 1399
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: [Mod] Zeg9's craft guide [github] [zcg]

by maikerumine » Post

Neon wrote:Had an error with this, from the git version 6bd997e. It didn't seem to impact the game; I wouldn't have noticed, except that I was checking some other interactions when I saw this.

Code: Select all

2016-03-02 23:14:07: ACTION[ServerThread]: player {blah} crafts {something}
Loading all crafts, this may take some time...
23:14:19: WARNING: Assignment to undeclared global "out" inside a function at .minetest/mods/minetest-zcg/zcg/init.lua:28.
All crafts loaded !
23:14:20: WARNING: Assignment to undeclared global "page" inside a function at .minetest/mods/minetest-zcg/zcg/init.lua:103.
23:14:20: WARNING: Assignment to undeclared global "alt" inside a function at .minetest/mods/minetest-zcg/zcg/init.lua:104.
23:14:20: WARNING: Assignment to undeclared global "current_item" inside a function at .minetest/mods/minetest-zcg/zcg/init.lua:105.
I noticed this too. What I did was add local to the beginning of all those...

Code: Select all

-- ZCG mod for minetest
-- See README for more information
-- Released by Zeg9 under WTFPL

zcg = {}

zcg.users = {}
zcg.crafts = {}
zcg.itemlist = {}

zcg.items_in_group = function(group)
	local items = {}
	local ok = true
	for name, item in pairs(minetest.registered_items) do
		-- the node should be in all groups
		ok = true
		for _, g in ipairs(group:split(',')) do
			if not item.groups[g] then
				ok = false
			end
		end
		if ok then table.insert(items,name) end
	end
	return items
end

local table_copy = function(table)
	local out = {}  --GLOBAL
	for k,v in pairs(table) do
		out[k] = v
	end
	return out
end

zcg.add_craft = function(input, output, groups)
	if minetest.get_item_group(output, "not_in_craft_guide") > 0 then
		return
	end
	if not groups then groups = {} end
	local c = {}
	c.width = input.width
	c.type = input.type
	c.items = input.items
	if c.items == nil then return end
	for i, item in pairs(c.items) do
		if item:sub(0,6) == "group:" then
			local groupname = item:sub(7)
			if groups[groupname] ~= nil then
				c.items[i] = groups[groupname]
			else
				for _, gi in ipairs(zcg.items_in_group(groupname)) do
					local g2 = groups
					g2[groupname] = gi
					zcg.add_craft({
						width = c.width,
						type = c.type,
						items = table_copy(c.items)
					}, output, g2) -- it is needed to copy the table, else groups won't work right
				end
				return
			end
		end
	end
	if c.width == 0 then c.width = 3 end
	table.insert(zcg.crafts[output],c)
end

zcg.load_crafts = function(name)
	zcg.crafts[name] = {}
	local _recipes = minetest.get_all_craft_recipes(name)
	if _recipes then
		for i, recipe in ipairs(_recipes) do
			if (recipe and recipe.items and recipe.type) then
				zcg.add_craft(recipe, name)
			end
		end
	end
	if zcg.crafts[name] == nil or #zcg.crafts[name] == 0 then
		zcg.crafts[name] = nil
	else
		table.insert(zcg.itemlist,name)
	end
end

zcg.need_load_all = true

zcg.load_all = function()
	print("Loading all crafts, this may take some time...")
	local i = 0
	for name, item in pairs(minetest.registered_items) do
		if (name and name ~= "") then
			zcg.load_crafts(name)
		end
		i = i+1
	end
	table.sort(zcg.itemlist)
	zcg.need_load_all = false
	print("All crafts loaded !")
end

zcg.formspec = function(pn)
	if zcg.need_load_all then zcg.load_all() end
	local page = zcg.users[pn].page  --GLOBAL
	local alt = zcg.users[pn].alt  --GLOBAL
	local current_item = zcg.users[pn].current_item  --GLOBAL
	local formspec = "size[8,7.5]"
	.. "button[0,0;2,.5;main;Back]"
	if zcg.users[pn].history.index > 1 then
		formspec = formspec .. "image_button[0,1;1,1;zcg_previous.png;zcg_previous;;false;false;zcg_previous_press.png]"
	else
		formspec = formspec .. "image[0,1;1,1;zcg_previous_inactive.png]"
	end
	if zcg.users[pn].history.index < #zcg.users[pn].history.list then
		formspec = formspec .. "image_button[1,1;1,1;zcg_next.png;zcg_next;;false;false;zcg_next_press.png]"
	else
		formspec = formspec .. "image[1,1;1,1;zcg_next_inactive.png]"
	end
	-- Show craft recipe
	if current_item ~= "" then
		if zcg.crafts[current_item] then
			if alt > #zcg.crafts[current_item] then
				alt = #zcg.crafts[current_item]
			end
			if alt > 1 then
				formspec = formspec .. "button[7,0;1,1;zcg_alt:"..(alt-1)..";^]"
			end
			if alt < #zcg.crafts[current_item] then
				formspec = formspec .. "button[7,2;1,1;zcg_alt:"..(alt+1)..";v]"
			end
			local c = zcg.crafts[current_item][alt]
			if c then
				local x = 3
				local y = 0
				for i, item in pairs(c.items) do
					formspec = formspec .. "item_image_button["..((i-1)%c.width+x)..","..(math.floor((i-1)/c.width+y))..";1,1;"..item..";zcg:"..item..";]"
				end
				if c.type == "normal" or c.type == "cooking" then
					formspec = formspec .. "image[6,2;1,1;zcg_method_"..c.type..".png]"
				else -- we don't have an image for other types of crafting
					formspec = formspec .. "label[0,2;Method: "..c.type.."]"
				end
				formspec = formspec .. "image[6,1;1,1;zcg_craft_arrow.png]"
				formspec = formspec .. "item_image_button[7,1;1,1;"..zcg.users[pn].current_item..";;]"
			end
		end
	end
	
	-- Node list
	local npp = 8*3 -- nodes per page
	local i = 0 -- for positionning buttons
	local s = 0 -- for skipping pages
	for _, name in ipairs(zcg.itemlist) do
		if s < page*npp then s = s+1 else
			if i >= npp then break end
			formspec = formspec .. "item_image_button["..(i%8)..","..(math.floor(i/8)+3.5)..";1,1;"..name..";zcg:"..name..";]"
			i = i+1
		end
	end
	if page > 0 then
		formspec = formspec .. "button[0,7;1,.5;zcg_page:"..(page-1)..";<<]"
	end
	if i >= npp then
		formspec = formspec .. "button[1,7;1,.5;zcg_page:"..(page+1)..";>>]"
	end
	formspec = formspec .. "label[2,6.85;Page "..(page+1).."/"..(math.floor(#zcg.itemlist/npp+1)).."]" -- The Y is approximatively the good one to have it centered vertically...
	return formspec
end

minetest.register_on_joinplayer(function(player)
	inventory_plus.register_button(player,"zcg","Craft guide")
end)

minetest.register_on_player_receive_fields(function(player,formname,fields)
	local pn = player:get_player_name();  --maikerumine added local
	if zcg.users[pn] == nil then zcg.users[pn] = {current_item = "", alt = 1, page = 0, history={index=0,list={}}} end
	if fields.zcg then
		inventory_plus.set_inventory_formspec(player, zcg.formspec(pn))
		return
	elseif fields.zcg_previous then
		if zcg.users[pn].history.index > 1 then
			zcg.users[pn].history.index = zcg.users[pn].history.index - 1
			zcg.users[pn].current_item = zcg.users[pn].history.list[zcg.users[pn].history.index]
			inventory_plus.set_inventory_formspec(player,zcg.formspec(pn))
		end
	elseif fields.zcg_next then
		if zcg.users[pn].history.index < #zcg.users[pn].history.list then
			zcg.users[pn].history.index = zcg.users[pn].history.index + 1
			zcg.users[pn].current_item = zcg.users[pn].history.list[zcg.users[pn].history.index]
			inventory_plus.set_inventory_formspec(player,zcg.formspec(pn))
		end
	end
	for k, v in pairs(fields) do
		if (k:sub(0,4)=="zcg:") then
			local ni = k:sub(5)
			if zcg.crafts[ni] then
				zcg.users[pn].current_item = ni
				table.insert(zcg.users[pn].history.list, ni)
				zcg.users[pn].history.index = #zcg.users[pn].history.list
				inventory_plus.set_inventory_formspec(player,zcg.formspec(pn))
			end
		elseif (k:sub(0,9)=="zcg_page:") then
			zcg.users[pn].page = tonumber(k:sub(10))
			inventory_plus.set_inventory_formspec(player,zcg.formspec(pn))
		elseif (k:sub(0,8)=="zcg_alt:") then
			zcg.users[pn].alt = tonumber(k:sub(9))
			inventory_plus.set_inventory_formspec(player,zcg.formspec(pn))
		end
	end
end)
Extreme Survival Minetest-->viewtopic.php?f=10&t=12959

JoshMars
Member
Posts: 109
Joined: Sat May 17, 2014 23:24
In-game: rubber UbuntuJosh

Re: [Mod] Zeg9's craft guide [github] [zcg]

by JoshMars » Post

This mod sucks. It lacks a search function, which is a must. Unified inventory is better.

User avatar
benrob0329
Member
Posts: 1337
Joined: Thu Aug 06, 2015 22:39
GitHub: Benrob0329
IRC: benrob0329
In-game: benrob03
Location: Michigan
Contact:

Re: [Mod] Zeg9's craft guide [github] [zcg]

by benrob0329 » Post

Ok....it hasn't been updated in years...
Social: YouTube Peertube Matrix Room: #minetest:matrix.org | Games: The Infinite IKEA

BBmine
Member
Posts: 3475
Joined: Sun Jul 12, 2015 22:51
GitHub: BBmine
IRC: BBmine
In-game: Baggins
Location: USA

Re: [Mod] Zeg9's craft guide [github] [zcg]

by BBmine » Post

Does this have support for sfinv?

User avatar
rubenwardy
Moderator
Posts: 6387
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: [Mod] Zeg9's craft guide [github] [zcg]

by rubenwardy » Post

BBmine wrote:Does this have support for sfinv?
Craft Guide does

User avatar
Wuzzy
Member
Posts: 4128
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [Mod] Zeg9's craft guide [github] [zcg]

by Wuzzy » Post

Servers and games should stop using this mod. It doesn't display the correct output count for crafts. This is a serious bug. It frustrates me that many popular servers still rely on this sub-par and outdated mod.

zcg is only good for historic interest since it is one of the first crafting guide mods for Minetest. But that's it.

Besides, this mod is very old. People should use modern crafting guides if they can.
My creations. I gladly accept bitcoins: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest