test if a chunk is generated?
-
- Member
- Posts: 26
- Joined: Sat May 11, 2013 03:20
- GitHub: i1abnrk
- IRC: i1abnrk
- In-game: mervyncoll
- Location: Wisconsin
- Contact:
test if a chunk is generated?
Hi everyone. I'm working on a mapgen mod that adapts genmud (old text-based rpg) code to lua. I'm looking for a way to test if a chunk has generated. Is there a null or something if I try to get a node that hasn't been generated yet? Some of the features I'm adapting (such as connecting roads) will be easier a simple test like this for edge-finding.
Thanks for any ideas.
Thanks for any ideas.
- Casimir
- Member
- Posts: 1207
- Joined: Fri Aug 03, 2012 16:59
- GitHub: CasimirKaPazi
Here "pos" is one position in the area you want to check.
Code: Select all
if minetest.registered_nodes[minetest.get_node(pos).name] then
-- succes
end
- PilzAdam
- Member
- Posts: 4026
- Joined: Fri Jul 20, 2012 16:19
- GitHub: PilzAdam
- IRC: PilzAdam
- Location: Germany
This will always jump to "succes"; get_node() returns ignore for unloaded areas, and ignore is in the registered_nodes table.Casimir wrote:Here "pos" is one position in the area you want to check.Code: Select all
if minetest.registered_nodes[minetest.get_node(pos).name] then -- succes end
- Casimir
- Member
- Posts: 1207
- Joined: Fri Aug 03, 2012 16:59
- GitHub: CasimirKaPazi
Then...
Code: Select all
if minetest.get_node(pos).name ~= "ignore" then
-- succes
end
-
- Member
- Posts: 26
- Joined: Sat May 11, 2013 03:20
- GitHub: i1abnrk
- IRC: i1abnrk
- In-game: mervyncoll
- Location: Wisconsin
- Contact:
Code: Select all
local c_nil = minetest.get_content_id("ignore")
if minetest.get_node(pos)==c_nil then
--true
end
So am I right in assuming only asynchronous sqlite transactions are available to lua? (vm:get_data() and vm:write_to_map()) Using async means the edge-finding technique requires a full rewrite of voxeldata every time a client accesses a chunk. Synchronous writeback from client this way could strain the server so I'd best write genmud on server-side in C++ as a patch I think.
These are assumptions, does it sound right?
Genmud generates the full map and minetest uses event-based chunk generation. Using perlin prediction is possible in lua instead of server code. The logic switches would be more tedious and slow in lua, though.
Last edited by i1abnrk on Mon Mar 03, 2014 15:33, edited 1 time in total.
-
- Moderator
- Posts: 4095
- Joined: Wed Aug 24, 2011 09:44
- GitHub: sfan5
- IRC: sfan5
- Location: Germany
get_node returns a table, you can't compare that to a node id
Do it like this:
Do it like this:
Casimir wrote:Then...Code: Select all
if minetest.get_node(pos).name ~= "ignore" then -- success end
- PilzAdam
- Member
- Posts: 4026
- Joined: Fri Jul 20, 2012 16:19
- GitHub: PilzAdam
- IRC: PilzAdam
- Location: Germany
Thats like exaclty the same thing as I posted as first answer to this topic...Casimir wrote:Then...Code: Select all
if minetest.get_node(pos).name ~= "ignore" then -- succes end
Last edited by PilzAdam on Mon Mar 03, 2014 16:17, edited 1 time in total.
-
- Member
- Posts: 26
- Joined: Sat May 11, 2013 03:20
- GitHub: i1abnrk
- IRC: i1abnrk
- In-game: mervyncoll
- Location: Wisconsin
- Contact:
~='ignore' works for me. I think testing 'if loaded' the closest solution I'll get with the current lua API. I'll have to pick through github to see if I can expose a sqlite query to lua to test 'if generated'.
Last edited by i1abnrk on Mon Mar 03, 2014 16:49, edited 1 time in total.
Who is online
Users browsing this forum: dxt_73 and 37 guests