tinkers construct clone help

Post Reply
User avatar
TechNolaByte
Member
Posts: 465
Joined: Wed May 10, 2017 21:00
GitHub: TechNolaByte

tinkers construct clone help

by TechNolaByte » Post

soo yeah somebody finally decided to make a tinkers construct clone for minetest and I need a little help with a function
I'm using a bit of code from the magma and ice paxels mod for a tool station to assemble parts

Code: Select all

local paxelnodeformspec = 
	"size[8,9]"..
	"label[3,0;part builder]"..
	"list[current_name;paxeltype;1,2;1,1;]"..
	"label[0,2;Material:]"..
	"list[current_name;head;3,1;1,1;]"..
	"label[2,1;Head:]"..
	"list[current_name;binding;3,2;1,1;]"..
	"label[2,2;     Binding:]"..
	"list[current_name;handle;3,3;1,1;]"..
	"label[2,3; Handle:]"..
	"list[current_name;tool;6,2;1,1;]"..
	"label[5,2;  Tool:]"..
	"list[current_player;main;0,5;8,4;]"..
	"button[5,3;3,1;create;Create Tool]"
-----recipie registration
local paxels = {
	{"default:flint", "default:flint", "tinkers_testers:binding_flint", "tinkers_testers:tool_rod_flint", "default:stone"}
}	
-----recipie registration
minetest.register_node("tinkers_testers:partbuilder", {
    description = "Part Builder",
	tiles = {
		"partbuilder_top.png",
		"table_side.png",
		"table_side.png",
		"table_side.png",
		"table_side.png",
		"table_side.png"
	},
	drawtype = "nodebox",
	paramtype = "light",
	node_box = {
		type = "fixed",
		fixed = {
			{-0.5, 0.25, -0.5, 0.5, 0.5, 0.5},
			{-0.5, -0.5, -0.5, -0.3125, 0.25, -0.3125},
			{0.3125, -0.5, -0.5, 0.5, 0.5, -0.3125},
			{-0.5, -0.5, 0.3125, -0.375, 0.5, 0.5},
			{0.3125, -0.5, 0.3125, 0.5, 0.5, 0.5},
		},
	},
	on_construct = function(pos)
		local meta = minetest.get_meta(pos)
		meta:set_string("formspec",paxelnodeformspec)
		meta:set_string("infotext", "Part Builder")
		local inv = meta:get_inventory()
		inv:set_size("main", 8*4)
		inv:set_size("head", 1*1)
		inv:set_size("binding", 1*1)
		inv:set_size("handle", 1*1)
		inv:set_size("tool", 1*1)
		inv:set_size("paxeltype", 1*1)		
	end,
	allow_metadata_inventory_put = function(pos, listname, index, stack, player)
		if listname == "head" or listname == "binding" or listname == "handle" or listname == "paxeltype" then
			return stack:get_count()
		else
			return 0
		end
	end,
	allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
		if to_list == "tool" then
			return 0
		else
			return 1
		end
	end,
	can_dig = function(pos,player)
		local meta = minetest.get_meta(pos);
		local inv = meta:get_inventory()
		if not inv:is_empty("head") then
			return false
		elseif not inv:is_empty("binding") then
			return false
		elseif not inv:is_empty("paxeltype") then
			return false
		elseif not inv:is_empty("handle") then
			return false
		elseif not inv:is_empty("tool") then
			return false
		end
		return true
	end,
	on_receive_fields = function(pos, formname, fields, sender)
		local meta = minetest.get_meta(pos);
		local inv = meta:get_inventory()
		for _, row in ipairs(paxels) do
			local paxeltype = row[1]
			local pick = row[2]
			local binding = row[3]
			local handle = row[4]
			local tool = row[5]
			if fields.create then
			if	inv:get_stack('paxeltype', 1):get_name() == paxeltype and inv:get_stack("head", 1):get_name() == pick and inv:get_stack("binding", 1):get_name() == binding and inv:get_stack("handle", 1):get_name() == handle and inv:is_empty("tool") then
					inv:add_item("tool", tool)
					inv:set_stack("head", 1, nil)
					inv:set_stack("binding", 1, nil)
					inv:set_stack("handle", 1, nil)
					inv:remove_item("paxeltype", paxeltype)
				end
			end
		end
	end,
	groups = {choppy=3,oddly_breakable_by_hand=3},
})

-----recipie registration
local paxels = {
	{"default:diamond", "default:diamond", "default:diamond", "default:dirt", "default:cobble"}
}
-----recipie registration
minetest.register_craftitem("tinkers_testers:blank_pattern", {
    description = "Blank Pattern",
    inventory_image = "pattern.png"
})
minetest.register_craftitem("tinkers_testers:cast", {
    description = "Blank cast",
    inventory_image = "cast.png"
})
minetest.register_craftitem("tinkers_testers:blank_tool_rod", {
    description = "Blank Tool Rod",
    inventory_image = "tool_rod.png"
})
minetest.register_craftitem("tinkers_testers:blank_binding", {
    description = "Blank Tool Binding",
    inventory_image = "binding.png"
})
minetest.register_craft({
    output = "tinkers_testers:blank_binding",
    recipe = {
        {"tinkers_testers:blank_pattern","","tinkers_testers:blank_pattern"},
        {"","tinkers_testers:blank_pattern",""},
        {"tinkers_testers:blank_pattern","","tinkers_testers:blank_pattern"}
    }
})
minetest.register_craft({
    output = "tinkers_testers:blank_tool_rod",
    recipe = {
        {"","","tinkers_testers:blank_pattern"},
        {"","tinkers_testers:blank_pattern",""},
        {"tinkers_testers:blank_pattern","",""}
    }
})
minetest.register_craftitem("tinkers_testers:flint_steel", {
    description = "Flint Steel Ingot",
    inventory_image = "seared_brick.png^[colorize:white:70"
})
minetest.register_craft({
    output = "tinkers_testers:flint_steel",
    recipe = {
        {"default:steel_ingot","tinkers_testers:binding_flint","default:steel_ingot"},
        {"tinkers_testers:binding_flint","","tinkers_testers:binding_flint"},
        {"default:steel_ingot","tinkers_testers:binding_flint","default:steel_ingot"}
    }
})
for name, data in pairs({
    flint_steel = {
        mat = "Flint Steel",
        mod = "tinkers_testers:flint_steel",
	shovel = "shovel_head_contrast.png",
	toolrod = "tool_rod_contrast.png",
	toolbinding = "binding_contrast.png",
	pickhead = "pick_head_contrast.png",
	axehead = "axe_head_contrast.png",
	swordblade = "large_sword_blade_contrast.png",
	largeplate = "large_plate_contrast.png",
    },
    flint = {
        mat = "Flint",
        mod = "default:flint",
	shovel = "shovel_head_contrast.png^[colorize:black:70",
	toolrod = "tool_rod_contrast.png^[colorize:black:70",
	toolbinding = "binding_contrast.png^[colorize:black:70",
	pickhead = "pick_head_contrast.png^[colorize:black:70",
	axehead = "axe_head_contrast.png^[colorize:black:70",
	swordblade = "large_sword_blade_contrast.png^[colorize:black:70",
	largeplate = "large_plate_contrast.png^[colorize:black:70",
    },
}) do
minetest.register_craftitem("tinkers_testers:shovel_head_"..name.."", {
	description = ""..data.mat.." shovel head",
	inventory_image = data.shovel,
})
minetest.register_craftitem("tinkers_testers:tool_rod_"..name.."", {
	description = ""..data.mat.." tool rod",
	inventory_image = data.toolrod,
})
minetest.register_craftitem("tinkers_testers:binding_"..name.."", {
	description = ""..data.mat.." tool binding",
	inventory_image = data.toolbinding,
})
minetest.register_craftitem("tinkers_testers:pick_head_"..name.."", {
	description = ""..data.mat.." pick head",
	inventory_image = data.pickhead,
})
minetest.register_craftitem("tinkers_testers:axe_head_"..name.."", {
	description = ""..data.mat.." axe head",
	inventory_image = data.axehead,
})
minetest.register_craftitem("tinkers_testers:sword_blade_"..name.."", {
	description = ""..data.mat.." sword blade",
	inventory_image = data.swordblade,
})
minetest.register_craftitem("tinkers_testers:large_plate_"..name.."", {
	description = ""..data.mat.." large plate",
	inventory_image = data.largeplate,
})
minetest.register_craft({
    output = "tinkers_testers:shovel_head_"..name.."",
    recipe = {
        {"",data.mod,""},
        {data.mod,"tinkers_testers:cast_shovel_head",data.mod},
        {"",data.mod,""}
    },
	replacements = {
		{"tinkers_testers:cast_shovel_head", "tinkers_testers:cast_shovel_head"}
	}
})
minetest.register_craft({
    output = "tinkers_testers:pick_head_"..name.."",
    recipe = {
        {"",data.mod,""},
        {data.mod,"tinkers_testers:cast_pick_head",data.mod},
        {"",data.mod,""}
    },
	replacements = {
		{"tinkers_testers:cast_pick_head", "tinkers_testers:cast_pick_head"}
	}
})
minetest.register_craft({
    output = "tinkers_testers:axe_head_"..name.."",
    recipe = {
        {"",data.mod,""},
        {data.mod,"tinkers_testers:cast_axe_head",data.mod},
        {"",data.mod,""}
    },
	replacements = {
		{"tinkers_testers:cast_axe_head", "tinkers_testers:cast_axe_head"}
	}
})
minetest.register_craft({
    output = "tinkers_testers:sword_blade_"..name.."",
    recipe = {
        {"",data.mod,""},
        {data.mod,"tinkers_testers:cast_sword_blade",data.mod},
        {"",data.mod,""}
    },
	replacements = {
		{"tinkers_testers:cast_sword_blade", "tinkers_testers:cast_sword_blade"}
	}
})
minetest.register_craft({
    output = "tinkers_testers:large_plate_"..name.."",
    recipe = {
        {"",data.mod,""},
        {data.mod,"tinkers_testers:cast_large_plate",data.mod},
        {"",data.mod,""}
    },
	replacements = {
		{"tinkers_testers:cast_large_plate", "tinkers_testers:cast_large_plate"}
	}
})
minetest.register_craft({
    output = "tinkers_testers:tool_rod_"..name.."",
    recipe = {
        {"",data.mod,""},
        {data.mod,"tinkers_testers:blank_tool_rod",data.mod},
        {"",data.mod,""}
    }
})
minetest.register_craft({
    output = "tinkers_testers:binding_"..name.."",
    recipe = {
        {"",data.mod,""},
        {data.mod,"tinkers_testers:blank_binding",data.mod},
        {"",data.mod,""}
    }
})
end
currently the 2 recipies registered under local paxels are only for testing but I want to be able to register recipies in both the first local paxles list and also in a second one is inside one of these things

Code: Select all

for name, data in pairs({
    flint_steel = {
	shovel = "shovel_head_contrast.png",
	toolrod = "tool_rod_contrast.png",
	toolbinding = "binding_contrast.png",
	pickhead = "pick_head_contrast.png",
	axehead = "axe_head_contrast.png",
	swordblade = "large_sword_blade_contrast.png",
	largeplate = "large_plate_contrast.png",
    },
}) do
local paxels = {
	{"default:diamond", "default:diamond", "default:diamond", "default:dirt", "default:cobble"}--bla bla bla all possible combinations of tool parts...
}
end


I have tried global paxels but that didn't work
The great quest of alchemy neither failed nor attained gold; programmers are those great alchemists who transmute caffeine into code.

User avatar
GamingAssociation39
Member
Posts: 858
Joined: Mon Apr 25, 2016 16:09
GitHub: Gerold55
IRC: Gerold55
In-game: Gerold55
Location: Maryland, USA

Re: tinkers construct clone help

by GamingAssociation39 » Post

It would help if there was a link to the mod :)
Jesus Is Lord and Savior!!!

User avatar
TechNolaByte
Member
Posts: 465
Joined: Wed May 10, 2017 21:00
GitHub: TechNolaByte

Re: tinkers construct clone help

by TechNolaByte » Post

well its not finished or even nearly close
I just need a little help with a variable(wow never thought I would ever say that)

I have include all code(and some more) that is relevant
The great quest of alchemy neither failed nor attained gold; programmers are those great alchemists who transmute caffeine into code.

User avatar
cx384
Member
Posts: 653
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: tinkers construct clone help

by cx384 » Post

I don't like the Idea of cloning minecraft mods for minetest and I prefer new, different, creative mods which can perform the same things, like pipeworks, mesecons, realtest, zmobs, technic, (hd) nether, unifiedinventory ...
Moreover, minetest doesn't offer the same moding possibility as minecraft. Therefore it is mostly not advisable to completely clone a mod from minecraft.
RSLRedstonier wrote: currently the 2 recipies registered under local paxels are only for testing but I want to be able to register recipies in both the first local paxles list and also in a second one is inside one of these things

Code: Select all

for name, data in pairs({
    flint_steel = {
	shovel = "shovel_head_contrast.png",
	toolrod = "tool_rod_contrast.png",
	toolbinding = "binding_contrast.png",
	pickhead = "pick_head_contrast.png",
	axehead = "axe_head_contrast.png",
	swordblade = "large_sword_blade_contrast.png",
	largeplate = "large_plate_contrast.png",
    },
}) do
local paxels = {
	{"default:diamond", "default:diamond", "default:diamond", "default:dirt", "default:cobble"}--bla bla bla all possible combinations of tool parts...
}
end

I have tried global paxels but that didn't work
Why don't you use "table.insert(paxels, {<stuff>})" ?
Can your read this?

User avatar
TechNolaByte
Member
Posts: 465
Joined: Wed May 10, 2017 21:00
GitHub: TechNolaByte

Re: tinkers construct clone help

by TechNolaByte » Post

cx384 wrote:I don't like the Idea of cloning minecraft mods for minetest and I prefer new, different, creative mods which can perform the same things, like pipeworks, mesecons, realtest, zmobs, technic, (hd) nether, unifiedinventory ...
Moreover, minetest doesn't offer the same moding possibility as minecraft. Therefore it is mostly not advisable to completely clone a mod from minecraft.
well I'm just trying to create something which to my knowledge hasn't yet been functionally created just to prove that it can


why I don't use "table.insert(paxels, {<stuff>})"
I am a programming noob and just use as basic code as I can and didn't even know about hat feature
all of my knowledge of minetest lua modding was completely self taught by looking over the code of other peoples mods and trying to reverse engineer them
The great quest of alchemy neither failed nor attained gold; programmers are those great alchemists who transmute caffeine into code.

User avatar
cx384
Member
Posts: 653
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: tinkers construct clone help

by cx384 » Post

RSLRedstonier wrote:I am a programming noob and just use as basic code as I can and didn't even know about hat feature
all of my knowledge of minetest lua modding was completely self taught by looking over the code of other peoples mods and trying to reverse engineer them
Lua is a very easy and simple programing language but you should take a look at this and some involved links like Lua 5.1 Reference Manual.
Can your read this?

User avatar
TechNolaByte
Member
Posts: 465
Joined: Wed May 10, 2017 21:00
GitHub: TechNolaByte

Re: tinkers construct clone help

by TechNolaByte » Post

cx384 wrote:Lua is a very easy and simple programing language but you should take a look at this and some involved links like Lua 5.1 Reference Manual.
ty!
The great quest of alchemy neither failed nor attained gold; programmers are those great alchemists who transmute caffeine into code.

User avatar
TechNolaByte
Member
Posts: 465
Joined: Wed May 10, 2017 21:00
GitHub: TechNolaByte

Re: tinkers construct clone help

by TechNolaByte » Post

cx384 wrote:Why don't you use "table.insert(paxels, {<stuff>})" ?
could you show an example of how I would use it with my code?
I cant seem to get it to work with this code
The great quest of alchemy neither failed nor attained gold; programmers are those great alchemists who transmute caffeine into code.

User avatar
cx384
Member
Posts: 653
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: tinkers construct clone help

by cx384 » Post

RSLRedstonier wrote:
cx384 wrote:Why don't you use "table.insert(paxels, {<stuff>})" ?
could you show an example of how I would use it with my code?
I cant seem to get it to work with this code
I am not sure what you want to achieve with your code but this is an example:

Code: Select all

local my_table = {"a", "b", "c"}
table.insert(my_table, "d")

print(dump(my_table))
This should print:

Code: Select all

{
	"a",
	"b",
	"c",
	"d"
}
Can your read this?

User avatar
TechNolaByte
Member
Posts: 465
Joined: Wed May 10, 2017 21:00
GitHub: TechNolaByte

Re: tinkers construct clone help

by TechNolaByte » Post

I want to be able to register recipe's for tool combinations in the part builder inside a for loop
edit now it works for some reason ty!
The great quest of alchemy neither failed nor attained gold; programmers are those great alchemists who transmute caffeine into code.

User avatar
whovian44
New member
Posts: 6
Joined: Mon Feb 26, 2018 07:17
GitHub: whovian44
IRC: whovian44
In-game: lsuak whovian44 masterofkittys
Location: Tunneler's abyss

Re: tinkers construct clone help

by whovian44 » Post

umm just wondering if this is still being worked on becuase there has not been a post in 2 months(which is fine i understand coding takes alot of time and you all have other things to do as well)im not a programer and can't help tho just really exsited for this mod coming! thx.

User avatar
TechNolaByte
Member
Posts: 465
Joined: Wed May 10, 2017 21:00
GitHub: TechNolaByte

Re: tinkers construct clone help

by TechNolaByte » Post

whovian44 wrote:umm just wondering if this is still being worked on becuase there has not been a post in 2 months(which is fine i understand coding takes alot of time and you all have other things to do as well)im not a programer and can't help tho just really exsited for this mod coming! thx.
i have abandoned this project to work on gemeric instead
The great quest of alchemy neither failed nor attained gold; programmers are those great alchemists who transmute caffeine into code.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests