lua: added set_block_states
This commit is contained in:
@@ -115,6 +115,7 @@ void lua::LuaState::createFuncs() {
|
|||||||
addfunc("get_block_Y", lua_wrap_errors<l_get_block_y>);
|
addfunc("get_block_Y", lua_wrap_errors<l_get_block_y>);
|
||||||
addfunc("get_block_Z", lua_wrap_errors<l_get_block_z>);
|
addfunc("get_block_Z", lua_wrap_errors<l_get_block_z>);
|
||||||
addfunc("get_block_states", lua_wrap_errors<l_get_block_states>);
|
addfunc("get_block_states", lua_wrap_errors<l_get_block_states>);
|
||||||
|
addfunc("set_block_states", lua_wrap_errors<l_set_block_states>);
|
||||||
addfunc("get_block_user_bits", lua_wrap_errors<l_get_block_user_bits>);
|
addfunc("get_block_user_bits", lua_wrap_errors<l_get_block_user_bits>);
|
||||||
addfunc("set_block_user_bits", lua_wrap_errors<l_set_block_user_bits>);
|
addfunc("set_block_user_bits", lua_wrap_errors<l_set_block_user_bits>);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "../../../voxels/Block.h"
|
#include "../../../voxels/Block.h"
|
||||||
#include "../../../voxels/Chunks.h"
|
#include "../../../voxels/Chunks.h"
|
||||||
#include "../../../voxels/voxel.h"
|
#include "../../../voxels/voxel.h"
|
||||||
|
#include "../../../voxels/Chunk.h"
|
||||||
#include "../../../items/ItemDef.h"
|
#include "../../../items/ItemDef.h"
|
||||||
#include "../../../items/ItemStack.h"
|
#include "../../../items/ItemStack.h"
|
||||||
#include "../../../items/Inventory.h"
|
#include "../../../items/Inventory.h"
|
||||||
@@ -428,6 +429,22 @@ int l_get_block_states(lua_State* L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int l_set_block_states(lua_State* L) {
|
||||||
|
lua::luaint x = lua_tointeger(L, 1);
|
||||||
|
lua::luaint y = lua_tointeger(L, 2);
|
||||||
|
lua::luaint z = lua_tointeger(L, 3);
|
||||||
|
lua::luaint states = lua_tointeger(L, 4);
|
||||||
|
|
||||||
|
Chunk* chunk = scripting::level->chunks->getChunkByVoxel(x, y, z);
|
||||||
|
if (chunk == nullptr) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
voxel* vox = scripting::level->chunks->get(x, y, z);
|
||||||
|
vox->states = states;
|
||||||
|
chunk->setModified(true);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int l_get_block_user_bits(lua_State* L) {
|
int l_get_block_user_bits(lua_State* L) {
|
||||||
lua::luaint x = lua_tointeger(L, 1);
|
lua::luaint x = lua_tointeger(L, 1);
|
||||||
lua::luaint y = lua_tointeger(L, 2);
|
lua::luaint y = lua_tointeger(L, 2);
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ extern int l_get_block_x(lua_State* L);
|
|||||||
extern int l_get_block_y(lua_State* L);
|
extern int l_get_block_y(lua_State* L);
|
||||||
extern int l_get_block_z(lua_State* L);
|
extern int l_get_block_z(lua_State* L);
|
||||||
extern int l_get_block_states(lua_State* L);
|
extern int l_get_block_states(lua_State* L);
|
||||||
|
extern int l_set_block_states(lua_State* L);
|
||||||
extern int l_get_block_user_bits(lua_State* L);
|
extern int l_get_block_user_bits(lua_State* L);
|
||||||
extern int l_set_block_user_bits(lua_State* L);
|
extern int l_set_block_user_bits(lua_State* L);
|
||||||
extern int l_is_replaceable_at(lua_State* L);
|
extern int l_is_replaceable_at(lua_State* L);
|
||||||
|
|||||||
Reference in New Issue
Block a user