summaryrefslogtreecommitdiffstats
path: root/src/Bindings/LuaState.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-01-11 17:39:43 +0100
committerGitHub <noreply@github.com>2021-01-11 17:39:43 +0100
commiteeb63b8901a9c049f1bb594abb9ce9b4a9c47620 (patch)
treeb07daae788f918b83eeb0bdbd51e49292f1c8d88 /src/Bindings/LuaState.cpp
parentFixed switch-ups regarding some slab and stair recipes (#5099) (diff)
downloadcuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.gz
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.bz2
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.lz
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.xz
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.zst
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.zip
Diffstat (limited to '')
-rw-r--r--src/Bindings/LuaState.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index c6042ac62..81dcb0e67 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -863,7 +863,7 @@ void cLuaState::Push(const AStringVector & a_Vector)
int index = 1;
for (AStringVector::const_iterator itr = a_Vector.begin(), end = a_Vector.end(); itr != end; ++itr, ++index)
{
- tolua_pushstring(m_LuaState, itr->c_str());
+ Push(*itr);
lua_rawseti(m_LuaState, newTable, index);
}
}
@@ -916,6 +916,17 @@ void cLuaState::Push(const cLuaState::cRef & a_Ref)
+void cLuaState::Push(const ContiguousByteBufferView a_Data)
+{
+ ASSERT(IsValid());
+
+ lua_pushlstring(m_LuaState, reinterpret_cast<const char *>(a_Data.data()), a_Data.size());
+}
+
+
+
+
+
void cLuaState::Push(const Vector3d & a_Vector)
{
ASSERT(IsValid());
@@ -1355,6 +1366,22 @@ bool cLuaState::GetStackValue(int a_StackPos, cTrackedRefSharedPtr & a_Ref)
+bool cLuaState::GetStackValue(int a_StackPos, ContiguousByteBuffer & a_Data)
+{
+ size_t Length = 0;
+ const char * const Data = lua_tolstring(m_LuaState, a_StackPos, &Length);
+ if (Data != nullptr)
+ {
+ a_Data.assign(reinterpret_cast<const std::byte *>(Data), Length);
+ return true;
+ }
+ return false;
+}
+
+
+
+
+
bool cLuaState::GetStackValue(int a_StackPos, double & a_ReturnedVal)
{
if (lua_isnumber(m_LuaState, a_StackPos))