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 commands to replace destructible nodes with their indestructible variants and vice versa (if a variant exists) #1255

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

src4026
Copy link
Contributor

@src4026 src4026 commented Dec 10, 2023

This PR aims to add the commands /destructify and /indestructify which replace indestructible nodes with their destructible variants and vice versa respectively.

@LoneWolfHT
Copy link
Member

Instead of looping through nodes manually try using minetest.find_nodes_in_area(pos1, pos2, nodenames, [grouped]). It might push some things over to the C++, and is easier to comprehend

@src4026
Copy link
Contributor Author

src4026 commented Dec 17, 2023

Instead of looping through nodes manually try using minetest.find_nodes_in_area(pos1, pos2, nodenames, [grouped]). It might push some things over to the C++, and is easier to comprehend

If you're talking about the code from line number 256-258, I am not able to understand what I will need to put in the nodenames parameter in this case.

@LoneWolfHT
Copy link
Member

If you're talking about the code from line number 256-258, I am not able to understand what I will need to put in the nodenames parameter in this case.

I copied that line from the lua_api.txt, did you check there?

@src4026
Copy link
Contributor Author

src4026 commented Dec 19, 2023

If you're talking about the code from line number 256-258, I am not able to understand what I will need to put in the nodenames parameter in this case.

I copied that line from the lua_api.txt, did you check there?

Yes, but since I have to enter either a node name (the example I saw in the API was "default:dirt") or a group of nodes (the example in the API was "group:tree"). For the command, I'm looping through all the nodes and then checking if they start with ctf_map:; so, by your suggestion, I am not able to realise how I would go about doing it for only finding blocks that are of that item string -> the group: "method" for nodename?
Hmm, is there a group: for indestructible blocks? 🤔 Checking right now

@src4026
Copy link
Contributor Author

src4026 commented Dec 19, 2023

Edit: Looks like I've also missed some cases, I'll make a commit for it after you reply to get it all together.

@src4026 src4026 marked this pull request as draft December 19, 2023 11:27
@src4026
Copy link
Contributor Author

src4026 commented Dec 19, 2023

Hmm, is there a group: for indestructible blocks?

I've tried searching for this and am unsure if I've found it. Sorry if it is obvious, and I'm just not able to see it

@LoneWolfHT
Copy link
Member

Hmm, is there a group: for indestructible blocks?

I've tried searching for this and am unsure if I've found it. Sorry if it is obvious, and I'm just not able to see it

immortal is the group you're looking for

local groups = {immortal = 1}

@src4026
Copy link
Contributor Author

src4026 commented Jan 9, 2024

Ah, I wasn't sure if it was that exactly but I did notice it in the node definitions. Thanks a lot!

@src4026
Copy link
Contributor Author

src4026 commented Jan 21, 2024

Hey there, just letting you know that I can work on this after 26th Jan only; a bit delayed

@src4026
Copy link
Contributor Author

src4026 commented Mar 22, 2024

So I've got minetest.find_nodes_in_area(pos1, pos2, nodenames, [grouped]) working for the /destructify command in which I find all the immortal group blocks. I'll still have to resort to manual looping for the "non-immortal" nodes, isn't it? (or VoxelManip, but I don't think that might be needed?).

In the meanwhile, I'll try optimising my mod prefix fixes using the local mod_prefixes table provided in nodes.lua

@src4026
Copy link
Contributor Author

src4026 commented Mar 22, 2024

I fixed the /indestructify command's "indestructification" process by using the mod_prefixes table. But I'm finding the process to achieve the opposite mapping of mods to prefixes for the /destructify command unnecessarily long. Do you think I should leave it hardcoded or is a simpler way to use the mod_prefixes table to do this?

@LoneWolfHT
Copy link
Member

I fixed the /indestructify command's "indestructification" process by using the mod_prefixes table. But I'm finding the process to achieve the opposite mapping of mods to prefixes for the /destructify command unnecessarily long. Do you think I should leave it hardcoded or is a simpler way to use the mod_prefixes table to do this?

I would maybe change how things work so that the mod_prefixes table works both ways

@LoneWolfHT
Copy link
Member

So I've got minetest.find_nodes_in_area(pos1, pos2, nodenames, [grouped]) working for the /destructify command in which I find all the immortal group blocks. I'll still have to resort to manual looping for the "non-immortal" nodes, isn't it? (or VoxelManip, but I don't think that might be needed?).

In the meanwhile, I'll try optimising my mod prefix fixes using the local mod_prefixes table provided in nodes.lua

The manual method via voxelmanip might be best in the future, can wait and see how things go though

@src4026
Copy link
Contributor Author

src4026 commented Jun 5, 2024

Alright. I forgot to commit my previous changes before my vacations. Now I'll make a comitt with all the changes later

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