mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 19:41:51 +00:00
migrate blocks interaction (scripting) to global chunks storage (WIP)
This commit is contained in:
parent
53cc8d3c7b
commit
e0b3425eff
16 changed files with 228 additions and 145 deletions
|
|
@ -7,6 +7,7 @@
|
|||
#include "voxels/Chunk.hpp"
|
||||
#include "voxels/Chunks.hpp"
|
||||
#include "voxels/voxel.hpp"
|
||||
#include "voxels/ChunksStorage.hpp"
|
||||
#include "world/Level.hpp"
|
||||
#include "maths/voxmaths.hpp"
|
||||
#include "data/StructLayout.hpp"
|
||||
|
|
@ -114,6 +115,15 @@ static int l_get(lua::State* L) {
|
|||
return lua::pushinteger(L, id);
|
||||
}
|
||||
|
||||
static int l_get_slow(lua::State* L) {
|
||||
auto x = lua::tointeger(L, 1);
|
||||
auto y = lua::tointeger(L, 2);
|
||||
auto z = lua::tointeger(L, 3);
|
||||
auto vox = level->chunksStorage->get(x, y, z);
|
||||
int id = vox == nullptr ? -1 : vox->id;
|
||||
return lua::pushinteger(L, id);
|
||||
}
|
||||
|
||||
static int l_get_x(lua::State* L) {
|
||||
auto x = lua::tointeger(L, 1);
|
||||
auto y = lua::tointeger(L, 2);
|
||||
|
|
@ -598,6 +608,7 @@ const luaL_Reg blocklib[] = {
|
|||
{"is_replaceable_at", lua::wrap<l_is_replaceable_at>},
|
||||
{"set", lua::wrap<l_set>},
|
||||
{"get", lua::wrap<l_get>},
|
||||
{"get_slow", lua::wrap<l_get_slow>},
|
||||
{"get_X", lua::wrap<l_get_x>},
|
||||
{"get_Y", lua::wrap<l_get_y>},
|
||||
{"get_Z", lua::wrap<l_get_z>},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue