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 an API function for synchronously activating areas #11609

Closed
wants to merge 2 commits into from

Conversation

TurkeyMcMac
Copy link
Contributor

Add compact, short information about your PR for easier understanding:

  • Goal of the PR
    • The goal is to add a way to synchronously check for objects in any area, mostly. The function could probably be used more generally as well.
  • How does the PR work?
    • I wrote some documentation for the function in lua_api.txt.
    • Internally it uses the method ServerEnvironment::activateBlock. This is used to activate the area for a short time, during which the API user can check for active objects and stuff.
    • The function does not create blocks that do not already exist. Hopefully this way the function can avoid triggering one-time LBMs before blocks are generated, for the most part.
  • Does it resolve any reported issue?
  • Does this relate to a goal in the roadmap?
    • I'm a modder, so this could count as taking feedback from a modder.
    • It might also count as an improvement to objects/entities.
  • If not a bug fix, why is this PR needed? What usecases does it solve?
    • I mentioned my usecase in the linked issue.
    • It's for the mod area_containers. I would like to be able to activate an area to detect objects there. The activation has to be synchronous (unlike with minetest.forceload_block) because I need to detect the objects immediately before the end of the can_dig callback.

To do

This PR is Ready for Review.

How to test

  1. Load a devtest world with this mod installed: test_activate_area.tar.gz
  2. Run the command make_platform (1000,1000,1000). This should make a platform at that position and put two objects on it.
  3. Now you can run the command check_platform (1000,1000,1000). This should find the two objects. It will tell you whether it had to activate the area to find the objects. If the area was not active before, it was activated using minetest.activate_area.

It still needs some tests.
@ElCeejo
Copy link

ElCeejo commented Sep 12, 2021

Very nice, as someone who works mostly with objects this will be very useful if it gets merged.

@TurkeyMcMac
Copy link
Contributor Author

Actually, I think there are some issues with this. I'm worried about script callbacks called within activateBlock. They could call minetest.activate_area on the same area, causing some worrying recursion. I'll try to figure out a new PR without this issue.

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.

Detection of objects in inactive areas
2 participants