Page 1 of 1

[Mod] talliant [taillant]

Posted: Sun Oct 09, 2016 03:07
by zm78
adds Le Taillant! (or the Taillant).

screenshots:

Image
Image
Image

you are welcome to help:

Code: Select all

-- Supporting functions

local hasitem = function(inventory,itemstring)
	for idx,x in pairs(inventory:get_list("main") ) do
		if x:get_name() == itemstring then
			return true
		end
	end
	return false
end

local playdig = function(playername)
	minetest.sound_play("default_dig_cracky",{
		to_player = playername,
	})
end

-- Item defintions

minetest.register_craftitem("taillant:taillant", {
	description = "Taillant",
	inventory_image = "stone_extractor.png",
	stack_max = 1,
	on_use = function(itemstack,puncher,pointedthing)
		if pointedthing.type ~= "node" then return end

		local pos = pointedthing.under
		local node = minetest.get_node(pos)
		if node.name == "default:stone" then
			minetest.set_node(pos, {name="default:cobble"})
			puncher:get_inventory():add_item('main', "default:gravel")
			playdig(puncher:get_player_name())
		elseif node.name == "default:cobble" then
			minetest.dig_node(pos)
			puncher:get_inventory():add_item('main', "default:gravel")
			playdig(puncher:get_player_name())
		end
		return

	end
})

minetest.register_craftitem("taillant:taillant_reverse", {
	description = "Reverse Taillant",
	inventory_image = "stone_extractor_reverse.png",
	stack_max = 1,
	on_use = function(itemstack,puncher,pointedthing)
		if pointedthing.type ~= "node" then return end

		local pos = pointedthing.under
		local node = minetest.get_node(pos)
		if node.name == "default:cobble"
		and hasitem(puncher:get_inventory(),"default:gravel") then
			playdig(puncher:get_player_name())
			minetest.set_node(pos, {name="default:stone"})
			puncher:get_inventory():remove_item('main', "default:gravel")
		end
		return
	end
})

crafting: none

Code: LGPLv2.1+, textures: CC BY-SA

Mod dependencies: default

Download: https://github.com/zander999/taillant
zip:
taillant.zip
(27.92 KiB) Downloaded 69 times

Re: [Mod]talliant[taillant]

Posted: Sun Oct 09, 2016 10:42
by azekill_DIABLO
what does it do?

Re: [Mod]talliant[taillant]

Posted: Sun Oct 09, 2016 16:13
by taikedz
Looking at the code

Code: Select all

minetest.remove_node(pos)
minetest.add_node(pos, {name="default:cobble"})
puncher:get_inventory():add_item('main', "default:cobble")
It looks like you transform stone into cobble stone instantly, and receive a cobble stone piece too.

You can do your node replacement in one go though; it would also make more sense to receive gravel

Code: Select all

minetest.set_node(pos, {name="default:cobble"})
puncher:get_inventory():add_item('main', "default:gravel")
http://dev.minetest.net/minetest.set_node

It would be good if you did also a reverse tool - use gravel from your inventory, to transform existing cobble into regular stone ;-)

Re: [Mod]talliant[taillant]

Posted: Mon Oct 10, 2016 00:03
by zm78
taikedz wrote:Looking at the code

Code: Select all

minetest.remove_node(pos)
minetest.add_node(pos, {name="default:cobble"})
puncher:get_inventory():add_item('main', "default:cobble")
It looks like you transform stone into cobble stone instantly, and receive a cobble stone piece too.

You can do your node replacement in one go though; it would also make more sense to receive gravel

Code: Select all

minetest.set_node(pos, {name="default:cobble"})
puncher:get_inventory():add_item('main', "default:gravel")
http://dev.minetest.net/minetest.set_node

It would be good if you did also a reverse tool - use gravel from your inventory, to transform existing cobble into regular stone ;-)

did it after some time here is the download link: https://github.com/zander999/taillant/commits/master

the download is commit: add taliant reversed

Re: [Mod] talliant [taillant]

Posted: Wed Oct 12, 2016 23:44
by taikedz
So. I did a rewrite and sent a pull request.

Punch logic that depends on the tool should be in the tool itself, not on a global punch.

Also did a check on gravel being in the inventory before actually using gravel to patch some cobble.

Third tool (smash) was not really necessary.... normal Taillant works fine.

Item names should not have the "The" article in front of it.

Hope that is of help. In principle I like this - allows patching up really ugly cobblestone buildings :-P

Re: [Mod] talliant [taillant]

Posted: Thu Oct 13, 2016 07:45
by zm78
taikedz wrote:So. I did a rewrite and sent a pull request.

Punch logic that depends on the tool should be in the tool itself, not on a global punch.

Also did a check on gravel being in the inventory before actually using gravel to patch some cobble.

Third tool (smash) was not really necessary.... normal Taillant works fine.

Item names should not have the "The" article in front of it.

Hope that is of help. In principle I like this - allows patching up really ugly cobblestone buildings :-P
merged!!

(a little bug i cannot fix is that the taliant reverse will still work without gravel in the inventory thanks for the fix)