[Mod] Explorer Tools [explorer]

User avatar
Kilarin
Member
Posts: 896
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

[Mod] Explorer Tools [explorer]

by Kilarin » Post

Explorer Tools Version 1.2
This mod adds a pick, axe, and shovel that not only dig on a left click, but will place whatever item is in the inventory slot immediately to their right on a right click.

Have you ever been frustrated when digging a mine or exploring a cavern because you have to dig, dig, dig, then swap the active inventory item to a torch, place a torch, swap the active inventory item back to your pick, and repeat? Did you ever wish that you could just place a torch (or a block of stone or glass) with a right click while still wielding your pick, axe, or shovel? If so, then this mod is for you!

The tools are based upon the diamond versions, and are crafted by replacing the top stick in the recipe with a mese crystal:

Code: Select all

diamond,   diamond   ,diamond        diamond,diamond              diamond
       ,mese fragment,               diamond,mese fragment      mese fragment
       ,   stick     ,                      ,stick                 stick
Image

These tools have the same stats as a diamond tool, with the exception that the uses has been increased by 10%. (to account for the extra expense of adding a mese crystal)
The tools work exactly like the base diamond version, EXCEPT that when wielding these tools, if you right click, it does a "place" using the item directly to the right in the players inventory. So, for example, if your inventory slots looked like this:

Image

Then a left click with the pick would dig, but point the pick at the wall and right click, and it will place a torch from your second inventory slot on the wall. No need to switch active inventory items at all. Left click to dig with the pick, right click to place a torch.

And it doesn't have to be a torch. Perhaps you are building a project that requires digging out stone and replacing it with glass. Just put your stack of glass in the inventory slot next to the explorer pick, dig the stone out with a left click, place the glass with a right click. The axe and the shovel work the same way.

Alternative mod:
There was a request that the explorertool place on rightclick function be added to every pick, axe, and shovel in the game. 4aiman implemented this in his magichet game, and kindly gave me permission to create an explorertoolsall mod based on his code. Download THAT version if you want ALL tools to be able to place an item on right click.

Possible future changes:
The textures, eh, not so great here. If someone gets inspired to suggest an improvement, I'm very open to it. I didn't create an explorer hoe, because there was not a diamond version of the hoe in the default game, but adding a hoe would be simple.
This is my first MineTest mod, and my first time ever programming in Lua, so any suggestions for improvements in the code are very welcome.

Credits:
My son helped me with the idea, the programming, and the textures. Thanks to kaeza for sample code of how to get the inventory item to the right of the tool, and to PilzAdam and Stu for answering my questions about how the uses field works. 4aiman for the change the code for Explorer Tools All.

Incompatibilities:
Do not use with Inventory Tweak mod, on right click your tool will disappear!

---For Explorer Tools: (use this one for special explorer tools)
Dependencies:
soft depends on default, but without default you have no recipe.

License: CC0

To browse source:
https://github.com/Kilarin/ExplorerTools

Download:
https://github.com/Kilarin/ExplorerTool ... master.zip

---For Explorer Tools All: (use this one to let all tools do a right click place)
Dependencies:
Soft depends on default. Add soft dependencies for any other tool mods you want this to affect.

License: gplv3

To browse source:
https://github.com/Kilarin/explorertoolsall

Download:
https://github.com/Kilarin/explorertool ... master.zip

---

To install:
Simply unzip the file into your mods folder, and rename the folder to explorertools (Or explorertoolsall)
OR, simply install it directly from minetest using the online mod repository.

Mod Database:
If you use either of these mods, please consider reviewing it on the MineTest Mod Database.
mmdb/mod/explorertools/
mmdb/mod/explorertoolsall/

Change Log:
1.2 change from kaeza: Force-update stack instead of relying on success indicator.
This eliminates a problem where using explorertoolsall and an itemframe would
allow you to duplicate items. And, to my surprise, it does not seem to cause
you to lose items when you can't place the stack.
1.1 changed hard depends on default to soft
removed requirement that index pos of tool be less than 8
updated readme to include explorertoolsall referenc
1.0 initial release
Last edited by Kilarin on Sun Oct 12, 2014 23:30, edited 6 times in total.

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

by rubenwardy » Post

I like this!

You need to upload your file to somewhere. You are currently linking to a directory on your computer.
  • Upload it as a forum attachment
  • or Dropbox.com
  • or Add your mod to mod store and upload it there
Last edited by rubenwardy on Sun Apr 13, 2014 15:45, edited 1 time in total.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
Krock
Developer
Posts: 4683
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

by Krock » Post

Yup, try dropbox, mediafire or 2shared to upload your file. Else we can not download it.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
Kilarin
Member
Posts: 896
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

by Kilarin » Post

Krock wrote:Yup, try dropbox, mediafire or 2shared to upload your file. Else we can not download it.
UGH!!!
Sorry, what a stupid mistake. I uploaded it to mediafire, tested the link, and then somehow I copied the wrong link into the post and didn't notice it. <sigh> Anyway, link corrected.

I'll look into putting it on modstore once a few people have tried it and confirmed everything is working ok.
Last edited by Kilarin on Sun Apr 13, 2014 16:55, edited 1 time in total.

Sokomine
Member
Posts: 4317
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

by Sokomine » Post

Sounds simple but could be extremly useful. Nice idea! Hope it will be available for download soon (no, mediafire dosn't count as that does not work - a site that requires JavaScript for a mere download is broken by design). Please be so kind to add a forum attachment :-) Adding it to the minetest mod database would also be nice. I'm sure a lot of people will enjoy it!
A list of my mods can be found here.

User avatar
Krock
Developer
Posts: 4683
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

by Krock » Post

Well I didn't say my opinion yet because it's not world-moving, it's just ... an useful function to put torches without needing to switch.
(Well scrolling the mouse wheel isn't a big thing too but I'm not used in it)
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
Kilarin
Member
Posts: 896
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

by Kilarin » Post

Krock wrote:Well I didn't say my opinion yet because it's not world-moving, it's just ... an useful function to put torches without needing to switch.
yep, pretty simple, but I didn't want to pick something really complicated for my first mod. :)
Sokomine wrote: Nice idea! Hope it will be available for download soon (no, mediafire dosn't count as that does not work - a site that requires JavaScript for a mere download is broken by design). Please be so kind to add a forum attachment :-) Adding it to the minetest mod database would also be nice.
I added it as an attachment, and I added it to the mod database:
mmdb/mod/83/

Sokomine
Member
Posts: 4317
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

by Sokomine » Post

Kilarin wrote: I added it as an attachment, and I added it to the mod database:
Thank you! Hope it gets installed on servers I build on.
A list of my mods can be found here.

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

by 4aiman » Post

Cool idea and so is mod!
I've just realized why there isn't smth like this in Minecraft - ppl use RMB to block :)

I've couple suggestions:
1. You could use player:get_inventory():get_width(player:get_wielded_list()) to find out width of a wield bar. Then compare idx with it instead of assuming that width = 8.

2. Could you redefine all tools that are registered before your mod loaded to use the same feature? I can help with that if you want :)

bajanhgk
Member
Posts: 75
Joined: Sun Apr 06, 2014 16:31
In-game: bajanhgk
Location: The World Of Darkness

by bajanhgk » Post

Krock wrote:Well I didn't say my opinion yet because it's not world-moving, it's just ... an useful function to put torches without needing to switch.
(Well scrolling the mouse wheel isn't a big thing too but I'm not used in it)
Krock sometimes people use laptop and they don't use a mouse on there laptop like me
Edit: oh yah this a really useful mod for me
Last edited by bajanhgk on Mon Apr 14, 2014 08:09, edited 1 time in total.
Just a Loner In the Winds which Blow Endlessly towards Death

User avatar
nman3600
Member
Posts: 168
Joined: Fri Feb 07, 2014 17:06
GitHub: nman3600
IRC: nman3600
In-game: nman3600

by nman3600 » Post

Krock wrote:Well I didn't say my opinion yet because it's not world-moving, it's just ... an useful function to put torches without needing to switch.
(Well scrolling the mouse wheel isn't a big thing too but I'm not used in it)
*a useful*
There is just no angry way to say 'Bubbles'

User avatar
Krock
Developer
Posts: 4683
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

by Krock » Post

nman3600 wrote:*a useful*
Do not correct my grammar fails, #grammarnazi.

Testing this mod now on my server, 100%of the players (2) like it already xD
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
nman3600
Member
Posts: 168
Joined: Fri Feb 07, 2014 17:06
GitHub: nman3600
IRC: nman3600
In-game: nman3600

by nman3600 » Post

Krock wrote:
nman3600 wrote:*a useful*
Do not correct my grammar fails, #grammarnazi.

Testing this mod now on my server, 100%of the players (2) like it already xD
Lol im one of them #imagrammarnazi
There is just no angry way to say 'Bubbles'

User avatar
Kilarin
Member
Posts: 896
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

by Kilarin » Post

4aiman wrote:You could use player:get_inventory():get_width(player:get_wielded_list()) to find out width of a wield bar. Then compare idx with it instead of assuming that width = 8.
That is a most excellent idea! Like I said, this is my first mod, so I didn't have any clue how to get the inventory list width. (Or think about the fact that a Mod might have changed it) Much to learn!
4aiman wrote:2. Could you redefine all tools that are registered before your mod loaded to use the same feature? I can help with that if you want :)
You mean, have this work for all tools, instead of just a particular pick/axe/shovel? I considered that, but was worried about making too big an impact on the game and also that overriding the right click behavior on some tools could cause problems (Such as the screwdriver) But my son had suggested this, making the argument that you do a lot of mining and cavern exploring before you've gotten down to the depth where you can get diamond and mese. Which I think is a valid point.

So, certainly, if you think this would be an improvement, I would welcome help in how to make the change.
Krock wrote:Testing this mod now on my server, 100%of the players (2) like it already xD
I'm glad both of you are finding it useful! Thank you for giving it a try.

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

by 4aiman » Post

Kilarin wrote:So, certainly, if you think this would be an improvement, I would welcome help in how to make the change.
I meant that on_place should be defined if only there is NO definition. So things like screwdriver shouldn't suffer.

To override a tool you'll need to:
(If you'll need extra details - feel free to ask via PM.)
1. Soft-depend on all mods that have tools. This is essential. You need all tools to be loaded prior to your mod.
2. You already have your function to place items, so this step is taken already :)
3. Add the following to the end of you init.lua:

Code: Select all

    for cou,def in pairs(minetest.registered_tools) do
        if not def['on_place'] then
          minetest.override_item(def.name, {on_place = explorertools_place,})
        end
    end
Already tested and working!

User avatar
Krock
Developer
Posts: 4683
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

by Krock » Post

4aiman wrote:Already tested and working!
Wooden pickaxes and pain sticks would have no difference with the explorer tools with this.
Explorer tools have to be special and unique.

EDIT: Also, your code would override all swords, do you want to place nodes with swords? I don't think so.
Last edited by Krock on Tue Apr 15, 2014 07:41, edited 1 time in total.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

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

by 4aiman » Post

Krock wrote:pain sticks
Is it "plain" or there is a mod with sticks as weapon? I want such a thing.

Also sorry, I've tested this w/o if statement and my "works" was referring the piece with substitution.

Here's working version. Only axes, pics and shovels/spades.

Code: Select all

    for cou,def in pairs(minetest.registered_tools) do
        if def.name:find('pick')
        or def.name:find('axe')
        or def.name:find('shovel')
        or def.name:find('spade')
        then
          minetest.override_item(def.name, {on_place = explorertools_place,})
        end
    end
Last edited by 4aiman on Tue Apr 15, 2014 09:01, edited 1 time in total.

bajanhgk
Member
Posts: 75
Joined: Sun Apr 06, 2014 16:31
In-game: bajanhgk
Location: The World Of Darkness

by bajanhgk » Post

warning: do not use this mod with inventory twerk you lose your pick if you right click
Just a Loner In the Winds which Blow Endlessly towards Death

User avatar
Kilarin
Member
Posts: 896
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

by Kilarin » Post

4aiman wrote:Here's working version. Only axes, pics and shovels/spades.
Krock wrote:Explorer tools have to be special and unique.
Sounds like I should put two versions out there. One that works the way I set this one up, with explorer tools being a special item you create, and one using the fascinating code 4aiman has offered that changes the behavior of all pick/axe/shoves that don't have a on_place already defined. That way everyone can choose which way they want it to work for their game/server.
bajanhgk wrote:warning: do not use this mod with inventory twerk you lose your pick if you right click
Yikes! I updated the post to indicate that. Any idea WHY it does this? Or how I could fix it not to do that anymore?

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

by 4aiman » Post

Kilarin wrote: that don't have a on_place already defined
PM-ed you on this matter. on_place is always defined... Please, use the second piece of code.
Kilarin wrote:Sounds like I should put two versions out there.
If you want to keep 2 versions separately then you can create 2 different files for each one.
You can add a variable which would load "original_ver.lua" or "chnged_ver.lua" depending on it's state:

Code: Select all

-- change this to "true" if you want on_place called on right click for all tools: 
local same_trick_for_all = false
if same_trick_for_all then
    dofile(minetest.get_modpath('explorertools').."/changed_ver.lua")
else
    dofile(minetest.get_modpath('explorertools').."/original_ver.lua")
end
Then place your old code in "original_ver.lua" file and changed into "changed_ver.lua".

But I'd recommend to wrap redefinition only within that " if " clause. So, It'll look like this (I'll shorten this):

Code: Select all

-- change this to "true" if you want on_place called on right click for all tools: 
local same_trick_for_all = false


function explorertools_place(item, player, pointed)
...
end

if same_trick_for_all then
 ...
         minetest.override_item(def.name, {on_place = explorertools_place,})
 ...
else
---Explorer Pickaxe
minetest.register_craft({...})
minetest.register_tool("explorertools:pick_explorer", {...})


---Explorer Axe
minetest.register_craft({...})
minetest.register_tool("explorertools:axe_explorer", {...})

---Explorer Shovel
minetest.register_craft({...})
minetest.register_tool("explorertools:shovel_explorer", {...})
end
Inventory tweak is unstable by itself. Here we have a different story, but I lost like a dozen of different tools while breaking them.
It was like this:
- I dig a node;
- My pick breaks down;
- Client predicts server behaviour and removes the broken tool;
- Inventory tweak replaces it with a new one;
- Server thinks that I'm holding the tool that's supposed to break and removes it;
- My new tool is gone.

I don't know how it was in reality and what client-server communication occurs here, but every time there are lags this happens to me if I'm using inventory tweak.
---------------------

Please, provide us a link to the Inventory tweak you're using.

User avatar
Kilarin
Member
Posts: 896
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

Re: [Mod] Explorer Tools (place an item on right click) [exp

by Kilarin » Post

Explorer Tools is now correctly uploaded to the MineTest Mod Database mmdb/mod/explorertools/

This should make it easy to install directly from MineTest. If you use it and like it (or not), please feel free to rate/review it there.

User avatar
Kilarin
Member
Posts: 896
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

Re: [Mod] Explorer Tools (place an item on right click) [exp

by Kilarin » Post

Version 1.1 of Explorer Tools is uploaded. No significant changes for the users here. I made the dependency on default soft instead of hard, and I removed the limit that the explorer tool had to be in an inventory slot less than 8.
Without that limit, the explorer tools should work correctly even if you have a mod that changes the inventory width. And if you put the explorer tool in the very last slot in your inventory, it will still work, it will just place the first item from the next line of inventory items. Which is intuitive.

The big change here isn't Explorer Tools, but the new mod ExplorerToolsAll. 4aiman wrote this code and gave me permission to use a slightly modified version of it here. The ExplorerToolsAll mod gives the "place on right click" ability to every pick, axe, and shovel in the game. So you don't have to create special tools, instead you can use any tool as an explorer tool. (Big thanks to 4aiman for this very clever and elegant code!)

I don't think this will mess up game balance in any way, since the "place on right click" ability doesn't actually increase your power in the game, it just saves you some keystrokes and possible carpel tunnel syndrome. :)

But, obviously, some people will prefer that the explorer tool function remain in only a special recipe tool, and those people should use the ExplorerTool mod. But if you want all tools to work that way, use Explorer Tools All.

To browse source:
https://github.com/Kilarin/explorertoolsall

Download:
https://github.com/Kilarin/explorertool ... master.zip

Have fun, and let me know if you run into any problems.

User avatar
Kilarin
Member
Posts: 896
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

Re: [Mod] Explorer Tools (place an item on right click) [exp

by Kilarin » Post

explorertools and explorertoolsall have been updated with a change from kaeza: Force-update stack instead of relying on success indicator. This eliminates a problem where using explorertoolsall and an itemframe would allow you to duplicate items.

original problem thread: https://github.com/VanessaE/homedecor_m ... issues/126
Pull: https://github.com/Kilarin/explorertoolsall/pull/1

And, to my surprise, it does not seem to cause you to lose items when you can't place the stack.

If anyone could explain to me why I don't need to check for success on placing before removing the item from the itemstack, I would be much obliged.

Thanks folks!

User avatar
Kilarin
Member
Posts: 896
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

Re: [Mod] Explorer Tools (place an item on right click) [exp

by Kilarin » Post

and donat-b answered my question. DUH!
since the Engine doesn't decrement the stack unless the place was successful, the update always has the right count.

MykieDoesStuff
Member
Posts: 136
Joined: Sat Aug 16, 2014 02:44

Re: [Mod] Explorer Tools (place an item on right click) [exp

by MykieDoesStuff » Post

So now what???
https://www.youtube.com/watch?v=_mD-zaC ... e=youtu.be

*Edit*

Ok so basically i got it all installed but how do I use it? Run it? Lol look like I'm a total newbie at installing mods :P

*EDIT*

Alright for some reason all the other mods seems to work now... not sure what went wrong ... however this kind of mods doesn't seems to work.
For fast response... send me a PM

Post Reply