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