[Mod] talliant [taillant]

Post Reply
User avatar
zm78
Member
Posts: 72
Joined: Thu Dec 17, 2015 22:34
GitHub: zander999
IRC: [none]
In-game: zm78

[Mod] talliant [taillant]

by zm78 » Post

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 114 times
Attachments
screenshot_20161010_100454.png
screenshot_20161010_100454.png (454.66 KiB) Viewed 709 times
screenshot_20161010_100449.png
screenshot_20161010_100449.png (307.21 KiB) Viewed 709 times
Last edited by zm78 on Mon Oct 24, 2016 06:44, edited 7 times in total.

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: [Mod]talliant[taillant]

by azekill_DIABLO » Post

what does it do?
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

User avatar
taikedz
Member
Posts: 698
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: [Mod]talliant[taillant]

by taikedz » Post

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 ;-)

User avatar
zm78
Member
Posts: 72
Joined: Thu Dec 17, 2015 22:34
GitHub: zander999
IRC: [none]
In-game: zm78

Re: [Mod]talliant[taillant]

by zm78 » Post

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

User avatar
taikedz
Member
Posts: 698
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: [Mod] talliant [taillant]

by taikedz » Post

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

User avatar
zm78
Member
Posts: 72
Joined: Thu Dec 17, 2015 22:34
GitHub: zander999
IRC: [none]
In-game: zm78

Re: [Mod] talliant [taillant]

by zm78 » Post

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)

Post Reply

Who is online

Users browsing this forum: No registered users and 47 guests