mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-13 23:11:49 +00:00
add vc.is_headless, vc.is_client
This commit is contained in:
parent
ded3dd2046
commit
678e5db03d
6 changed files with 19 additions and 6 deletions
|
|
@ -25,7 +25,7 @@ function on_save()
|
||||||
SAVED_DATA.data = dropitem.data
|
SAVED_DATA.data = dropitem.data
|
||||||
end
|
end
|
||||||
|
|
||||||
if not VC_HEADLESS then
|
if vc.is_client() then
|
||||||
local scale = {1, 1, 1}
|
local scale = {1, 1, 1}
|
||||||
local rotation = mat4.rotate({
|
local rotation = mat4.rotate({
|
||||||
math.random(), math.random(), math.random()
|
math.random(), math.random(), math.random()
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ else
|
||||||
SAVED_DATA.states = blockstates
|
SAVED_DATA.states = blockstates
|
||||||
end
|
end
|
||||||
|
|
||||||
if not VC_HEADLESS then-- setup visuals
|
if vc.is_client() then-- setup visuals
|
||||||
local rig = entity.skeleton
|
local rig = entity.skeleton
|
||||||
local id = block.index(blockid)
|
local id = block.index(blockid)
|
||||||
local rotation = block.decompose_state(blockstates)[1]
|
local rotation = block.decompose_state(blockstates)[1]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
function on_block_broken(id, x, y, z, playerid)
|
function on_block_broken(id, x, y, z, playerid)
|
||||||
if not VC_HEADLESS then
|
if vc.is_client() then
|
||||||
local size = {block.get_size(id)}
|
local size = {block.get_size(id)}
|
||||||
gfx.particles.emit({
|
gfx.particles.emit({
|
||||||
x + size[1] * 0.5,
|
x + size[1] * 0.5,
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ function on_physics_update(delta)
|
||||||
local front = mat4.mul(rot, {0, 0, -1})
|
local front = mat4.mul(rot, {0, 0, -1})
|
||||||
local pos = tsf:get_pos()
|
local pos = tsf:get_pos()
|
||||||
|
|
||||||
if not VC_HEADLESS and pid == hud.get_player() then
|
if vc.is_client() and pid == hud.get_player() then
|
||||||
process_player_inputs(pid, rot, delta)
|
process_player_inputs(pid, rot, delta)
|
||||||
end
|
end
|
||||||
mob.look_at(vec3.add(pos, front))
|
mob.look_at(vec3.add(pos, front))
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,18 @@
|
||||||
|
local _vc_headless = __VC_HEADLESS
|
||||||
|
__VC_HEADLESS = nil
|
||||||
|
|
||||||
|
vc = {
|
||||||
|
is_headless = function()
|
||||||
|
return _vc_headless
|
||||||
|
end,
|
||||||
|
is_client = function ()
|
||||||
|
return not _vc_headless
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
local _ffi = ffi
|
local _ffi = ffi
|
||||||
local _debug_getinfo = debug.getinfo
|
local _debug_getinfo = debug.getinfo
|
||||||
|
local _crc32 = crc32
|
||||||
|
|
||||||
function crc32(bytes, chksum)
|
function crc32(bytes, chksum)
|
||||||
chksum = chksum or 0
|
chksum = chksum or 0
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ static void create_libs(State* L, StateType stateType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
addfunc(L, "print", lua::wrap<l_print>);
|
addfunc(L, "print", lua::wrap<l_print>);
|
||||||
addfunc(L, "_crc32", lua::wrap<l_crc32>);
|
addfunc(L, "crc32", lua::wrap<l_crc32>);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lua::init_state(State* L, StateType stateType) {
|
void lua::init_state(State* L, StateType stateType) {
|
||||||
|
|
@ -146,7 +146,7 @@ void lua::initialize(const EnginePaths& paths, const CoreParameters& params) {
|
||||||
lua::setglobal(main_thread, "__VC_SCRIPT_NAME");
|
lua::setglobal(main_thread, "__VC_SCRIPT_NAME");
|
||||||
|
|
||||||
lua::pushboolean(main_thread, params.headless);
|
lua::pushboolean(main_thread, params.headless);
|
||||||
lua::setglobal(main_thread, "VC_HEADLESS");
|
lua::setglobal(main_thread, "__VC_HEADLESS");
|
||||||
}
|
}
|
||||||
|
|
||||||
void lua::finalize() {
|
void lua::finalize() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue