rename test library to app & rename app.name to app.script
This commit is contained in:
parent
deb85ba2d8
commit
ad6a6666da
@ -1,8 +1,8 @@
|
|||||||
test.set_setting("chunks.load-distance", 3)
|
app.set_setting("chunks.load-distance", 3)
|
||||||
test.set_setting("chunks.load-speed", 1)
|
app.set_setting("chunks.load-speed", 1)
|
||||||
|
|
||||||
test.reconfig_packs({"base"}, {})
|
app.reconfig_packs({"base"}, {})
|
||||||
test.new_world("demo", "2019", "core:default")
|
app.new_world("demo", "2019", "core:default")
|
||||||
|
|
||||||
local pid1 = player.create("Xerxes")
|
local pid1 = player.create("Xerxes")
|
||||||
assert(player.get_name(pid1) == "Xerxes")
|
assert(player.get_name(pid1) == "Xerxes")
|
||||||
@ -21,7 +21,7 @@ for i=1,25 do
|
|||||||
end
|
end
|
||||||
player.set_pos(pid1, math.random() * 100 - 50, 100, math.random() * 100 - 50)
|
player.set_pos(pid1, math.random() * 100 - 50, 100, math.random() * 100 - 50)
|
||||||
player.set_pos(pid2, math.random() * 200 - 100, 100, math.random() * 200 - 100)
|
player.set_pos(pid2, math.random() * 200 - 100, 100, math.random() * 200 - 100)
|
||||||
test.tick()
|
app.tick()
|
||||||
end
|
end
|
||||||
|
|
||||||
test.close_world(true)
|
app.close_world(true)
|
||||||
|
|||||||
@ -1,23 +1,23 @@
|
|||||||
-- Create/close/open/close world
|
-- Create/close/open/close world
|
||||||
|
|
||||||
-- Open
|
-- Open
|
||||||
test.new_world("demo", "2019", "core:default")
|
app.new_world("demo", "2019", "core:default")
|
||||||
assert(world.is_open())
|
assert(world.is_open())
|
||||||
assert(world.get_generator() == "core:default")
|
assert(world.get_generator() == "core:default")
|
||||||
test.sleep(1)
|
app.sleep(1)
|
||||||
assert(world.get_total_time() > 0.0)
|
assert(world.get_total_time() > 0.0)
|
||||||
print(world.get_total_time())
|
print(world.get_total_time())
|
||||||
|
|
||||||
-- Close
|
-- Close
|
||||||
test.close_world(true)
|
app.close_world(true)
|
||||||
assert(not world.is_open())
|
assert(not world.is_open())
|
||||||
|
|
||||||
-- Reopen
|
-- Reopen
|
||||||
test.open_world("demo")
|
app.open_world("demo")
|
||||||
assert(world.is_open())
|
assert(world.is_open())
|
||||||
assert(world.get_total_time() > 0.0)
|
assert(world.get_total_time() > 0.0)
|
||||||
assert(world.get_seed() == 2019)
|
assert(world.get_seed() == 2019)
|
||||||
test.tick()
|
app.tick()
|
||||||
|
|
||||||
-- Close
|
-- Close
|
||||||
test.close_world(true)
|
app.close_world(true)
|
||||||
|
|||||||
@ -22,21 +22,21 @@ function tb_frame_tostring(frame)
|
|||||||
return s
|
return s
|
||||||
end
|
end
|
||||||
|
|
||||||
if test then
|
if app then
|
||||||
test.sleep = sleep
|
app.sleep = sleep
|
||||||
test.name = __VC_TEST_NAME
|
app.script = __VC_SCRIPT_NAME
|
||||||
test.new_world = core.new_world
|
app.new_world = core.new_world
|
||||||
test.open_world = core.open_world
|
app.open_world = core.open_world
|
||||||
test.close_world = core.close_world
|
app.close_world = core.close_world
|
||||||
test.reopen_world = core.reopen_world
|
app.reopen_world = core.reopen_world
|
||||||
test.delete_world = core.delete_world
|
app.delete_world = core.delete_world
|
||||||
test.reconfig_packs = core.reconfig_packs
|
app.reconfig_packs = core.reconfig_packs
|
||||||
test.set_setting = core.set_setting
|
app.set_setting = core.set_setting
|
||||||
test.tick = coroutine.yield
|
app.tick = coroutine.yield
|
||||||
|
|
||||||
function test.quit()
|
function app.quit()
|
||||||
local tb = debug.get_traceback(1)
|
local tb = debug.get_traceback(1)
|
||||||
local s = "test.quit() traceback:"
|
local s = "app.quit() traceback:"
|
||||||
for i, frame in ipairs(tb) do
|
for i, frame in ipairs(tb) do
|
||||||
s = s .. "\n\t"..tb_frame_tostring(frame)
|
s = s .. "\n\t"..tb_frame_tostring(frame)
|
||||||
end
|
end
|
||||||
@ -45,11 +45,11 @@ if test then
|
|||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
end
|
end
|
||||||
|
|
||||||
function test.sleep_until(predicate, max_ticks)
|
function app.sleep_until(predicate, max_ticks)
|
||||||
max_ticks = max_ticks or 1e9
|
max_ticks = max_ticks or 1e9
|
||||||
local ticks = 0
|
local ticks = 0
|
||||||
while ticks < max_ticks and not predicate() do
|
while ticks < max_ticks and not predicate() do
|
||||||
test.tick()
|
app.tick()
|
||||||
end
|
end
|
||||||
if ticks == max_ticks then
|
if ticks == max_ticks then
|
||||||
error("max ticks exceed")
|
error("max ticks exceed")
|
||||||
|
|||||||
@ -37,7 +37,7 @@ extern const luaL_Reg packlib[];
|
|||||||
extern const luaL_Reg particleslib[]; // gfx.particles
|
extern const luaL_Reg particleslib[]; // gfx.particles
|
||||||
extern const luaL_Reg playerlib[];
|
extern const luaL_Reg playerlib[];
|
||||||
extern const luaL_Reg quatlib[];
|
extern const luaL_Reg quatlib[];
|
||||||
extern const luaL_Reg testlib[];
|
extern const luaL_Reg applib[];
|
||||||
extern const luaL_Reg text3dlib[]; // gfx.text3d
|
extern const luaL_Reg text3dlib[]; // gfx.text3d
|
||||||
extern const luaL_Reg timelib[];
|
extern const luaL_Reg timelib[];
|
||||||
extern const luaL_Reg tomllib[];
|
extern const luaL_Reg tomllib[];
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#include "api_lua.hpp"
|
#include "api_lua.hpp"
|
||||||
|
|
||||||
const luaL_Reg testlib[] = {
|
const luaL_Reg applib[] = {
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
@ -58,10 +58,10 @@ static void create_libs(State* L, StateType stateType) {
|
|||||||
openlib(L, "vec3", vec3lib);
|
openlib(L, "vec3", vec3lib);
|
||||||
openlib(L, "vec4", vec4lib);
|
openlib(L, "vec4", vec4lib);
|
||||||
|
|
||||||
if (stateType == StateType::TEST) {
|
if (stateType == StateType::SCRIPT) {
|
||||||
openlib(L, "test", testlib);
|
openlib(L, "app", applib);
|
||||||
}
|
}
|
||||||
if (stateType == StateType::BASE || stateType == StateType::TEST) {
|
if (stateType == StateType::BASE || stateType == StateType::SCRIPT) {
|
||||||
openlib(L, "gui", guilib);
|
openlib(L, "gui", guilib);
|
||||||
openlib(L, "input", inputlib);
|
openlib(L, "input", inputlib);
|
||||||
openlib(L, "inventory", inventorylib);
|
openlib(L, "inventory", inventorylib);
|
||||||
@ -119,10 +119,10 @@ void lua::initialize(const EnginePaths& paths, const CoreParameters& params) {
|
|||||||
logger.info() << LUAJIT_VERSION;
|
logger.info() << LUAJIT_VERSION;
|
||||||
|
|
||||||
main_thread = create_state(
|
main_thread = create_state(
|
||||||
paths, params.headless ? StateType::TEST : StateType::BASE
|
paths, params.headless ? StateType::SCRIPT : StateType::BASE
|
||||||
);
|
);
|
||||||
lua::pushstring(main_thread, params.scriptFile.stem().u8string());
|
lua::pushstring(main_thread, params.scriptFile.stem().u8string());
|
||||||
lua::setglobal(main_thread, "__VC_TEST_NAME");
|
lua::setglobal(main_thread, "__VC_SCRIPT_NAME");
|
||||||
}
|
}
|
||||||
|
|
||||||
void lua::finalize() {
|
void lua::finalize() {
|
||||||
|
|||||||
@ -13,7 +13,7 @@ struct CoreParameters;
|
|||||||
namespace lua {
|
namespace lua {
|
||||||
enum class StateType {
|
enum class StateType {
|
||||||
BASE,
|
BASE,
|
||||||
TEST,
|
SCRIPT,
|
||||||
GENERATOR,
|
GENERATOR,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user