Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Everness sandstone compressor recipes #634

Conversation

gabriel1379
Copy link
Contributor

Hi,

As previously, I wanted to use more Everness stuff with Technic and would like to contribute this too. This time, it's about sand to sandstone and vice versa, using the compressor and the grinder.

I also did a minor refactoring to prevent unnecessary file bloating and preserve overviewability.

Lastly, I needed to add everness as an optional dependency after all, as without it, the default everness mineral_sandstone to mineral_sand recipe could not be cleared. (This should be OK though, as Everness is a more fundamental, world builder mod, while Technic is more for later game, so it shouldn't need to depend on Technic.)

@@ -8,6 +8,15 @@ function technic.register_compressor_recipe(data)
technic.register_recipe("compressing", data)
end

function technic.clear_sand_to_sandstone_craft(sand_name)
Copy link
Member

@SmallJoker SmallJoker Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make this function local. Any new technic API should be documented in doc/ and this one is not special enough to be part of the global technic namespace.

Suggestion: rename the function to what it does internally, such as clear_shaped_2x2_craft.

EDIT: Or just remove the function. You could inline this minetest.clear_craft into the loop below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed and inlined as suggested.

However, for the future, so I'll know, as I'm just getting to know Lua: how exactly do I make a function local? Just write it in front of it, like local function technic.clear_shaped_2x2_craft or just leave away the technic namespace, like function clear_shaped_2x2_craft?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local function mytable.myfunction() end is not valid. mytable is either local or global (default).
function myfunction() end is a function in the global namespace _G. It might overwrite or be overwritten by accident by another mod.
Local variables and functions ( local function myfunction() end) can only be seen and used within the current file. This is what I'd recommend for niche utility functions that are unlikely to be of much use outside the file.

Global variables can be shadowed by locals. luacheck can partially check against that to avoid side-effects.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Thanks for the explanation. 👍

@SmallJoker
Copy link
Member

Looks good; the sand recipes are (still) removed as intended.

Will merge in a few days unless anyone's got objections.

@SmallJoker SmallJoker merged commit d5ff69d into minetest-mods:master Mar 25, 2024
1 check passed
gabriel1379 added a commit to gabriel1379/technic that referenced this pull request Apr 7, 2024
Add Everness sandstone compressor recipes (minetest-mods#634)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants