[Mod] talliant [taillant]

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

[Mod] talliant [taillant]

by zm78 » Sun Oct 09, 2016 03:07

adds Le Taillant! (or the Taillant).

screenshots:

Image
Image
Image

you are welcome to help:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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 80 times
Attachments
screenshot_20161010_100454.png
screenshot_20161010_100454.png (454.66 KiB) Viewed 923 times
screenshot_20161010_100449.png
screenshot_20161010_100449.png (307.21 KiB) Viewed 923 times
Last edited by zm78 on Mon Oct 24, 2016 06:44, edited 7 times in total.
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: [Mod]talliant[taillant]

by azekill_DIABLO » Sun Oct 09, 2016 10:42

what does it do?
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: [Mod]talliant[taillant]

by taikedz » Sun Oct 09, 2016 16:13

Looking at the code

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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: 50
Joined: Thu Dec 17, 2015 22:34
GitHub: zander999
IRC: [none]
In-game: zm78

Re: [Mod]talliant[taillant]

by zm78 » Mon Oct 10, 2016 00:03

taikedz wrote:Looking at the code

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: [Mod] talliant [taillant]

by taikedz » Wed Oct 12, 2016 23:44

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: 50
Joined: Thu Dec 17, 2015 22:34
GitHub: zander999
IRC: [none]
In-game: zm78

Re: [Mod] talliant [taillant]

by zm78 » Thu Oct 13, 2016 07:45

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)
 


Return to Mod Releases

Who is online

Users browsing this forum: No registered users and 40 guests

cron