Check harvester protection for each node it attempts to harvest#59
Merged
joe7575 merged 2 commits intojoe7575:masterfrom Dec 15, 2020
Merged
Check harvester protection for each node it attempts to harvest#59joe7575 merged 2 commits intojoe7575:masterfrom
joe7575 merged 2 commits intojoe7575:masterfrom
Conversation
Owner
|
But you could do the check a few lines later: for y_pos = start_y_pos,stop_y_pos,-1 do
pos.y = y_pos
local node = minetest.get_node_or_nil(pos)
if node and node.name ~= "air" then
local order = tubelib_addons1.FarmingNodes[node.name] or tubelib_addons1.Flowers[node.name]
if order and not minetest.is_protected(pos, this.owner) then
....This would be not that time consuming and would allow to harvest nodes below that protected area. |
Contributor
Author
|
Thanks @joe7575 I'll give that a go in a minute |
Contributor
Author
|
@joe7575 "would allow to harvest nodes below that protected area" I don't think that's true actually, the else on that condition is However, I think if I put this on the next line it would skip, like: I'll give it a test, but as long as lua works like other languages the condition should exit before running |
… but do not exit if protected
Contributor
Author
|
@joe7575 That's working now, take another look |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes BLS issue 186 BlockySurvival/issue-tracker#186
Performs protection check for each node it attempts to harvest, and exits as soon as it sees a protected node.
Considering there is a protection check outside of the for loop, I have a feeling this wasn't done for efficiency reasons. It would be nice if we could ask if a volume is protected, not just a node, but currently this code is required for security reasons.
One odd feature of this change is that nodes above a protected area will be harvested, but nodes below that protected area will not. I don't think that's such an issue, but we could: