1 local mode = core.settings:get("helper_mode")
3 if mode == "devtest" then
5 -- Provide feedback to script by creating files in world path
6 core.after(0, function()
7 io.close(io.open(core.get_worldpath() .. "/startup", "w"))
9 local function callback(test_ok)
11 io.close(io.open(core.get_worldpath() .. "/test_failure", "w"))
13 io.close(io.open(core.get_worldpath() .. "/done", "w"))
14 core.request_shutdown("", false, 2)
16 -- If tests are enabled exit when they're done, otherwise exit on player join
17 if core.settings:get_bool("devtest_unittests_autostart") and core.global_exists("unittests") then
18 unittests.on_finished = callback
20 core.register_on_joinplayer(function() callback(true) end)
23 elseif mode == "mapgen" then
25 -- Stress-test mapgen by constantly generating new area
26 local csize = tonumber(core.settings:get("chunksize")) * core.MAP_BLOCKSIZE
27 local MINP, MAXP = vector.new(0, -csize, 0), vector.new(csize*3, csize*2, csize)
29 local pstart = vector.new(0, 0, 0)
32 print("emerging " .. core.pos_to_string(pstart))
34 vector.add(pstart, MINP), vector.add(pstart, MAXP),
39 callback = function(blockpos, action, calls_rem, n)
40 if action == core.EMERGE_CANCELLED or action == core.EMERGE_ERRORED then
43 if calls_rem <= 20 and not trig[n] then
45 pstart[DIR] = pstart[DIR] + (MAXP[DIR] - MINP[DIR])
49 core.after(0, next_, 1)