[Mod] Re-Cycle Age [1.3.1] [recycleage]

Post Reply
User avatar
Hamlet
Member
Posts: 716
Joined: Sat Jul 29, 2017 21:09
GitHub: h4ml3t
IRC: H4mlet
In-game: Hamlet
Location: Lombardy, Italy

[Mod] Re-Cycle Age [1.3.1] [recycleage]

by Hamlet » Post

Image
Allows to recycle broken items.

Version: 1.3.1
Source code's license: EUPL v1.2 or later
Texture's license: CC BY-SA v3.0 Unported

Dependencies: default, farming (found in Minetest Game)
Compatible with: moreores

Not compatible with: toolranks
Advanced options: Settings -> All Settings -> Mods -> recycleage

Description:
When an item breaks it will no longer vanish, instead it will break in
pieces: wooden sticks from the handle, and metal scraps or mineral shards
for mese and diamond.
Metal scraps and mineral shards can then be turned into mese or diamonds
by cooking them into a furnace.


Notes:
Wooden sticks will replace the broken tool into your inventory, while
scrap metals or shards will be dropped where your character is standing.
Smelting 1 scrap diamond shard requires 1 coal block.
Smelting 1 scrap mese shard requires half coal block.


Downloads:
Archives: .tar.gz, .zip
Source code: GitLab


Installation:
Unzip the archive, rename the folder to recycleage and place it in
../minetest/mods/

GNU+Linux: If you use a system-wide installation place it in
~/.minetest/mods/

If you only want this to be used in a single world, place the folder in
../minetest/worlds/world_name/worldmods/

For further information or help see:
http://wiki.minetest.net/wiki/Installing_Mods
Attachments
screenshot.png
(3.8 KiB) Not downloaded yet
Last edited by Hamlet on Mon May 11, 2020 18:58, edited 11 times in total.
GitLab ContentDB VanessaE's Basic-plus Server (-1122.0, 19.5, -2438.0)

User avatar
FreeGamers
Member
Posts: 569
Joined: Sat May 25, 2019 00:15
GitHub: is proprietary I use NotABug
Location: United States
Contact:

Re: [Mod] Re-Cycle Age [0.1.0] [recycleage]

by FreeGamers » Post

Nice concept.

I see that it overrides tools and then replaces the tool with the broken tool when it reaches a wear level.

Code: Select all

minetest.override_item("default:pick_wood", {
	after_use = function(itemstack, user, node, digparams)
	   
	   -- This adds the default wear amount.
	   -- Source: lua_api.txt at line 5907 (Minetest v5.0.1)
	   itemstack:add_wear(digparams.wear)
	   
	   -- If the tool isn't broken then return the updated item.
	   if (itemstack:get_wear() > 0) then
		  --print(itemstack:get_wear())
		  return itemstack
	   
	   -- If the tool is broken then replace it with something else.
	   else
		  --print(itemstack:get_wear())
		  --Note: the above would return "0".
		  itemstack:replace("recycleage:pick_wood")
		  return itemstack

	   end
	end
})
What about adding support for the popular toolranks mod? I guess this is would be optional. It seems like this mod sort of encourages players to be OK with tools breaking since there is a refund for materials included. I don't think toolranks really needs to be used side by side with this, as that seems like an alternative philosophy in some ways.

If people want to add custom tools from other mods, I guess they should use the above format in the overrides.lua file?

User avatar
texmex
Member
Posts: 1751
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex

Re: [Mod] Re-Cycle Age [0.1.0] [recycleage]

by texmex » Post

Very good! Much better than the tool just disappearing into air on break.
Mods | Support Mesehub: bc1qluuests9rxmlnvpjrhsnyjg9ucwy6z3r0y3srw

Chem871
Member
Posts: 947
Joined: Sat Aug 19, 2017 21:49
GitHub: Chemguy99
In-game: Chem Nyx
Location: My Basement's Attic

Re: [Mod] Re-Cycle Age [0.1.0] [recycleage]

by Chem871 » Post

Who in their right mind would ever choose to get the sticks?? Sticks are renewable, steel and mese are not.
What is SCP-055 again? I forgot.

Kurtzmusch
Member
Posts: 41
Joined: Sat Oct 21, 2017 18:12
In-game: Kurtzmusch

Re: [Mod] Re-Cycle Age [0.1.0] [recycleage]

by Kurtzmusch » Post

Chem871 wrote:Who in their right mind would ever choose to get the sticks?? Sticks are renewable, steel and mese are not.
exaclty...

here's an idea: when a tool breaks it gets replaced by 1 tool handle and 1 tool "head". the head part can be smelted back into less bars and the tool handle can be used like a stick
Like Puzzles? Escape The Dungeon

User avatar
Yvanhoe
Member
Posts: 131
Joined: Fri Jul 05, 2019 03:18
Location: Japan

Re: [Mod] Re-Cycle Age [0.1.0] [recycleage]

by Yvanhoe » Post

Chem871 wrote:Who in their right mind would ever choose to get the sticks?? Sticks are renewable, steel and mese are not.
If you are stuck underground, far from the surface, iron feels more renewable than wood. It can make sense.

User avatar
Hamlet
Member
Posts: 716
Joined: Sat Jul 29, 2017 21:09
GitHub: h4ml3t
IRC: H4mlet
In-game: Hamlet
Location: Lombardy, Italy

Re: [Mod] Re-Cycle Age [0.1.0] [recycleage]

by Hamlet » Post

Freegamers:
I will try to make it compatible with Toolranks; if you want to add another tool you must add the relative code in each lua file:

craft_item - for the broken item placeholder; i.e. the one with the red flash
cooking_recipes.lua - for the item smelting; output: ingots or minerals
crafting_recipes.lua - for the item reverse-crafting; output: wood
overriders.lua - to prevent worn items to vanish

Question: "Why not a single file with a lua table automatically doing the above?"
Answer pt1: "Tables are memory consuming, the resulting code is way less clear."
Answer pt2: "Localization would be a mess, or impossible; separated files allow for easy code management and maintenance."

Texmex:
Thank you! Hopefully this will make survival in hard biomes a bit more easier/interesting while keeping it realistic.

Chem871, Kurtzmusch:
The idea is to allow complete recycleage of an item, but the game does not allow to get both materials: you can't put a pickaxe in the crafting grid and get 2 sticks and 2 ingots in the output slot. The same goes for the replacement item. This is why you have to choose.

Yvanhoe:
True: some times I have found myself deep underground without a torch - I use Hardtorch, i.e. limited burning time - and a single stick would have permitted me to craft a torch and return to the surface.
Instead I died miserably in the darkness, losing my stuff, for the LOLs of the dungeon masters.
GitLab ContentDB VanessaE's Basic-plus Server (-1122.0, 19.5, -2438.0)

User avatar
texmex
Member
Posts: 1751
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex

Re: [Mod] Re-Cycle Age [0.1.0] [recycleage]

by texmex » Post

Btw, this mod would also be interesting in combination with the melterns mod (Tinker’s Construct conversion) as that mod brings the concept of tool heads.
Mods | Support Mesehub: bc1qluuests9rxmlnvpjrhsnyjg9ucwy6z3r0y3srw

User avatar
Hamlet
Member
Posts: 716
Joined: Sat Jul 29, 2017 21:09
GitHub: h4ml3t
IRC: H4mlet
In-game: Hamlet
Location: Lombardy, Italy

Re: [Mod] Re-Cycle Age [1.0.0] [recycleage]

by Hamlet » Post

Released v1.0.0 (no backward compatibility)

Added:
- Scrap materials that can be smelt into ingots, crystals and diamonds.

Changed:
- Broken tools will turn into wooden sticks and drop scrap materials.

Removed:
- Custom broken tools replacers.

See the first post for further informations.
GitLab ContentDB VanessaE's Basic-plus Server (-1122.0, 19.5, -2438.0)

User avatar
Hamlet
Member
Posts: 716
Joined: Sat Jul 29, 2017 21:09
GitHub: h4ml3t
IRC: H4mlet
In-game: Hamlet
Location: Lombardy, Italy

Re: [Mod] Re-Cycle Age [1.0.1] [recycleage]

by Hamlet » Post

Released v1.0.1

Changed:
- Overriders will not work if Toolranks is installed.


To those who might be interested, about compatibility with Toolranks.

Toolranks' toolranks.new_afteruse prevents compatibility because of this.
Translated: "if a tool is broken, make it disappear". Period.

The maintainer of Toolranks could change that by adding a condition, e.g. "if recycleage is installed then..." ...if the tool is broken take the scrap material from recycleage, etc. etc. more specifically: this.

On my side, I have added a condition that prevents recycleage's overriders to activate if Toolranks is installed; this prevents recycleage from wasting your tools' levels and records, making them behave as vanilla tools.

Long story short, at the moment there's no compatibility: do not use both mods, recycleage will not work as intended and you could possibly lose your toolranks' tools.
GitLab ContentDB VanessaE's Basic-plus Server (-1122.0, 19.5, -2438.0)

ThorfinnS
Member
Posts: 233
Joined: Mon Feb 25, 2019 22:05
GitHub: ThorfinnS

Re: [Mod] Re-Cycle Age [0.1.0] [recycleage]

by ThorfinnS » Post

Hamlet wrote:Chem871, Kurtzmusch:
The idea is to allow complete recycleage of an item, but the game does not allow to get both materials: you can't put a pickaxe in the crafting grid and get 2 sticks and 2 ingots in the output slot. The same goes for the replacement item. This is why you have to choose.
Look at the way clyde does paper in his cucina vegana. The recipe is two flax, 4 stone and one bucket of water, and it returns paper to inventory and puts 4 stone and one empty bucket in the crafting grid. Isn't that pretty much what you are trying to do?

User avatar
Hamlet
Member
Posts: 716
Joined: Sat Jul 29, 2017 21:09
GitHub: h4ml3t
IRC: H4mlet
In-game: Hamlet
Location: Lombardy, Italy

Re: [Mod] Re-Cycle Age [0.1.0] [recycleage]

by Hamlet » Post

ThorfinnS wrote:Look at the way clyde does paper in his cucina vegana. The recipe is two flax, 4 stone and one bucket of water, and it returns paper to inventory and puts 4 stone and one empty bucket in the crafting grid. Isn't that pretty much what you are trying to do?
Yes that was the initial idea, but it has been pointed out that the inventory could be full thus there should be an additional inventory-space-check in the code... overkill IMHO:
at the moment I am satisfied with the current version: the handle pieces "stay in your hand", i.e. the broken item's slot, and the item head's scraps fall on ground where you are standing.

However thank you for the hint: that could be handy in other situations. :)
GitLab ContentDB VanessaE's Basic-plus Server (-1122.0, 19.5, -2438.0)

User avatar
Hamlet
Member
Posts: 716
Joined: Sat Jul 29, 2017 21:09
GitHub: h4ml3t
IRC: H4mlet
In-game: Hamlet
Location: Lombardy, Italy

Re: [Mod] Re-Cycle Age [1.1.0] [recycleage]

by Hamlet » Post

Released v1.1.0

Added:
- Support for More Ores' tools

Changed:
- Fixed wrong conditional for Toolranks.
- Fixed wrong drop values for the default MTG's shovels.
GitLab ContentDB VanessaE's Basic-plus Server (-1122.0, 19.5, -2438.0)

User avatar
Hamlet
Member
Posts: 716
Joined: Sat Jul 29, 2017 21:09
GitHub: h4ml3t
IRC: H4mlet
In-game: Hamlet
Location: Lombardy, Italy

Re: [Mod] Re-Cycle Age [1.2.0] [recycleage]

by Hamlet » Post

Released v1.2.0

Added:
- Advanced options: scraps' cooktimes, scraps' amounts.
- Global function to allow third party mods' developers to add their own tools (see api.txt).
- Local variables and tables get flushed once used for memory saving.

Changed:
- Code entirely rewritten.
- Scraps get spawned 1 node higher than player's character position to prevent them being "eaten" by other nodes (e.g. snow, grass).
GitLab ContentDB VanessaE's Basic-plus Server (-1122.0, 19.5, -2438.0)

User avatar
Hamlet
Member
Posts: 716
Joined: Sat Jul 29, 2017 21:09
GitHub: h4ml3t
IRC: H4mlet
In-game: Hamlet
Location: Lombardy, Italy

Re: [Mod] Re-Cycle Age [1.3.0] [recycleage]

by Hamlet » Post

Released v1.3.0

Added:
- Default tool break sound.
GitLab ContentDB VanessaE's Basic-plus Server (-1122.0, 19.5, -2438.0)

User avatar
Hamlet
Member
Posts: 716
Joined: Sat Jul 29, 2017 21:09
GitHub: h4ml3t
IRC: H4mlet
In-game: Hamlet
Location: Lombardy, Italy

Re: [Mod] Re-Cycle Age [1.3.1] [recycleage]

by Hamlet » Post

Released v1.3.1

Changed:
- Fixed wrong stick drop (2 instead of 1) for Minetest Game and More Ores' swords.
GitLab ContentDB VanessaE's Basic-plus Server (-1122.0, 19.5, -2438.0)

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests