mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
Lua on each mapgen thread (#13092)
This commit is contained in:
parent
d4b107e2e8
commit
3cac17d23e
32 changed files with 1329 additions and 193 deletions
|
@ -1,3 +1,6 @@
|
|||
core.register_mapgen_script(core.get_modpath(core.get_current_modname()) ..
|
||||
DIR_DELIM .. "inside_mapgen_env.lua")
|
||||
|
||||
local function test_pseudo_random()
|
||||
-- We have comprehensive unit tests in C++, this is just to make sure the API code isn't messing up
|
||||
local gen1 = PseudoRandom(13)
|
||||
|
@ -204,3 +207,30 @@ local function test_on_mapblocks_changed(cb, player, pos)
|
|||
end
|
||||
end
|
||||
unittests.register("test_on_mapblocks_changed", test_on_mapblocks_changed, {map=true, async=true})
|
||||
|
||||
local function test_gennotify_api()
|
||||
local DECO_ID = 123
|
||||
local UD_ID = "unittests:dummy"
|
||||
|
||||
-- the engine doesn't check if the id is actually valid, maybe it should
|
||||
core.set_gen_notify({decoration=true}, {DECO_ID})
|
||||
|
||||
core.set_gen_notify({custom=true}, nil, {UD_ID})
|
||||
|
||||
local flags, deco, custom = core.get_gen_notify()
|
||||
local function ff(flag)
|
||||
return (" " .. flags .. " "):match("[ ,]" .. flag .. "[ ,]") ~= nil
|
||||
end
|
||||
assert(ff("decoration"), "'decoration' flag missing")
|
||||
assert(ff("custom"), "'custom' flag missing")
|
||||
assert(table.indexof(deco, DECO_ID) > 0)
|
||||
assert(table.indexof(custom, UD_ID) > 0)
|
||||
|
||||
core.set_gen_notify({decoration=false, custom=false})
|
||||
|
||||
flags, deco, custom = core.get_gen_notify()
|
||||
assert(not ff("decoration") and not ff("custom"))
|
||||
assert(#deco == 0, "deco ids not empty")
|
||||
assert(#custom == 0, "custom ids not empty")
|
||||
end
|
||||
unittests.register("test_gennotify_api", test_gennotify_api)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue