The-Architect-Crew / the-architect-game

Minetest subgame, for stability, consistency and fun
GNU Lesser General Public License v2.1
6 stars 0 forks source link

Workbench rewrite and shapes improvements #83

Closed neinwhal closed 2 years ago

neinwhal commented 2 years ago

Update: As of 2210bd2940321f214e512ccef56a75d89d705840 ; I have rewritten the data structure and created one to support easily obtaining recipes with multiple outputs. Combined with optimization of the existing code (- much thanks to Amaz for some suggestions); The result of this is a cut of half the time and more for the crafting process, making the process feel instantaneous as intended. There is also so minor changes, that are reflected in api.txt

Shapes Improvements

For more extensive documentation, refer to shapes/api.txt

Workbench

For those that haven't been following, the new workbench is completely different from the old one. Rather than creating a system to create crafting tables, workbench now provides a custom crafting API and a custom fuel API. These API can then be further used by other mods to create your own custom crafting tables and crafts with a lot of flexibility.

Workbench Crafting API

So why a new crafting API, doesn't minetest already provides one? Yes, but this provides much more features and flexibility. New features include;

Most old features are supported as well, this includes;

To note; minetest.register_craft is NOT forward-compatible with workbench crafting. This means if you are using the workbench API to register a new custom craft; functions like minetest.register_craft, minetest.register_on_craft, minetest.register_craft_predict, minetest.get_craft_result, minetest.get_craft_recipe, minetest.get_all_craft_recipes are NO longer usable.

But who needs those when workbench itself exposes a lot more data, which you can easily use to add your own modifications directly. (See api.txt for more info) This includes;

For future crafting registrations;

Workbench Fuel API

As noted, this current API is very basic rn, and isn't that different from what the old workbench has. For this reason, I don't suggest anyone use it yet, there will likely be major changes to it later, and I'm releasing it in its current form now because I don't think anyone would use this much for now - default fuel should suffice. For anyone that wants to use it to create custom fuel, contact me.

Showcase of API features

A new furnace and craftbench (crafting table) has been added using all these features. See workbench/furnace.lua and workbench/craftbench.lua for examples on all this features are utilized. Additionally, the tablesaw and CNC machine uses them as well, see shapes/crafting.lua There's an API documentation as well, see workbench/api/api.txt Additionally, feel free to directly contact me on discord to explain how to use it.

Other changes

TODO

neinwhal commented 2 years ago

I added an api.txt for locks in ccore. The locks API presently serve as an easy way for me to apply various lock status on a single node (rather than having multiple locked, unlocked variants etc) It is in used by the storage API as present in crates, and for the various work stations built with workbench API.

It is a bit more complicated than other APIs in the sense it's supposed to be used in conjunction with several factors and requirements. I don't think the API docs are fully adequate in explaining it, if you want a very simple example, look up how workbench/craftbench.lua handles the various functions.

neinwhal commented 2 years ago

I'm changing this back to WIP status. Trying for faster ways to handle the data.

neinwhal commented 2 years ago

This is ready for review. No major changes in features from first version, apart from some minor added features - mainly to support an easy way of getting multiple outputs from a single recipe/input.

Code wise, the delay was for an optimization of the code, as well as rewrite of the data structure. Both of which has been successful, and led to a decrease of nearly half the time and more, to obtain the output variables. Notably, this should allow the crafting process to find instantaneous.

lumberjackgames commented 2 years ago

This is ready for review.

Gave workbench a good overall scan for organization and sampled a few of the commits. I feel good about the code and error handling so no concerns here. Good work on those optimization tweaks!