A function to detect if a node is inside the active block radius?
- Hume2
- Member
- Posts: 710
- Joined: Tue Jun 19, 2018 08:24
- GitHub: Hume2
- In-game: Hume2
- Location: Czech Republic
A function to detect if a node is inside the active block radius?
Is there any such function to do this? Of course that I can iterate over all players and check the distance ... but ... there should be a better option. Minetest should somehow know which chunks are active and which aren't so I shouldn't need to calculate it myself.
If you lack the reality, go on a trip or find a job.
-
- Member
- Posts: 407
- Joined: Sat Dec 29, 2018 19:21
- GitHub: KaylebJay
- IRC: KaylebJay
- In-game: CalebJ
- Location: Tunnelers' Abyss
Re: A function to detect if a node is inside the active block radius?
You can use an Active Block Modifier? Maybe I'm misunderstanding.
- Hume2
- Member
- Posts: 710
- Joined: Tue Jun 19, 2018 08:24
- GitHub: Hume2
- In-game: Hume2
- Location: Czech Republic
Re: A function to detect if a node is inside the active block radius?
No, I have a postion and I want to check if the node at the position is active, regardless of what kind of node it is.
If you lack the reality, go on a trip or find a job.
-
- Member
- Posts: 407
- Joined: Sat Dec 29, 2018 19:21
- GitHub: KaylebJay
- IRC: KaylebJay
- In-game: CalebJ
- Location: Tunnelers' Abyss
Re: A function to detect if a node is inside the active block radius?
Ah, to check if it is *inside* the active block range. Not sure there :/
- sorcerykid
- Member
- Posts: 1847
- Joined: Fri Aug 26, 2016 15:36
- GitHub: sorcerykid
- In-game: Nemo
- Location: Illinois, USA
Re: A function to detect if a node is inside the active block radius?
It might be best to just check minetest.get_node_or_nil(). That won't tell if the mapblock is in the active block radius, but it will at least tell if the mapblock is loaded which is usually the same thing iirc.
- Hume2
- Member
- Posts: 710
- Joined: Tue Jun 19, 2018 08:24
- GitHub: Hume2
- In-game: Hume2
- Location: Czech Republic
Re: A function to detect if a node is inside the active block radius?
It's not quite the same. The default radius of loaded chunks is 10 while the radius of active chunks is 3.
If you lack the reality, go on a trip or find a job.
Re: A function to detect if a node is inside the active block radius?
You could iterate over connected players and return true on the first found within 3 block radius.
- Hume2
- Member
- Posts: 710
- Joined: Tue Jun 19, 2018 08:24
- GitHub: Hume2
- In-game: Hume2
- Location: Czech Republic
Re: A function to detect if a node is inside the active block radius?
That's what I wrote in the OP. I'm asking if there is a better solution because Minetest somehow has to know that anyway so I see no point of calculating it myself.
If you lack the reality, go on a trip or find a job.
- sirrobzeroone
- Member
- Posts: 593
- Joined: Mon Jul 16, 2018 07:56
- GitHub: sirrobzeroone
- Contact:
Re: A function to detect if a node is inside the active block radius?
I googled into this thread as I had a similar question. Just spent a bit of time trawling the API and I think this may tell you if a pos is "active" inside a mapblock.
Info may go out of date over time but at least the next person who stumbles on this thread will have somewhere to look :).
Code: Select all
minetest.compare_block_status(pos, condition)
Checks whether the mapblock at positition pos is in the wanted condition.
condition may be one of the following values:
"unknown": not in memory
"emerging": in the queue for loading from disk or generating
"loaded": in memory but inactive (no ABMs are executed)
"active": in memory and active
Other values are reserved for future functionality extensions
Return value, the comparison status:
false: Mapblock does not fulfil the wanted condition
true: Mapblock meets the requirement
nil: Unsupported condition value
-
- Member
- Posts: 155
- Joined: Mon Dec 28, 2020 01:19
- GitHub: loosewheel
- In-game: loosewheel
Re: A function to detect if a node is inside the active block radius?
Thanks for that @sirrobzeroone. I was looking for this a little while ago. I found a work-around, but its handy to know.
- Hume2
- Member
- Posts: 710
- Joined: Tue Jun 19, 2018 08:24
- GitHub: Hume2
- In-game: Hume2
- Location: Czech Republic
Re: A function to detect if a node is inside the active block radius?
I'm surprised that this function exists, thanks!
If you lack the reality, go on a trip or find a job.
Who is online
Users browsing this forum: No registered users and 4 guests