Merge branch 'main' into item-models
This commit is contained in:
@@ -45,6 +45,7 @@ static int l_load_fragment(lua::State* L) {
|
||||
|
||||
auto fragment = std::make_shared<VoxelFragment>();
|
||||
fragment->deserialize(map);
|
||||
fragment->prepare(*content);
|
||||
return lua::newuserdata<lua::LuaVoxelFragment>(L, std::move(fragment));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "world/generator/VoxelFragment.hpp"
|
||||
#include "util/stringutil.hpp"
|
||||
#include "world/Level.hpp"
|
||||
|
||||
using namespace lua;
|
||||
|
||||
@@ -20,8 +21,20 @@ static int l_crop(lua::State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_place(lua::State* L) {
|
||||
if (auto fragment = touserdata<LuaVoxelFragment>(L, 1)) {
|
||||
auto offset = tovec3(L, 2);
|
||||
int rotation = tointeger(L, 3) & 0b11;
|
||||
fragment->getFragment()->place(
|
||||
*scripting::level->chunks, offset, rotation
|
||||
);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static std::unordered_map<std::string, lua_CFunction> methods {
|
||||
{"crop", lua::wrap<l_crop>},
|
||||
{"place", lua::wrap<l_place>},
|
||||
};
|
||||
|
||||
static int l_meta_tostring(lua::State* L) {
|
||||
|
||||
Reference in New Issue
Block a user