Event queue
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "LuaState.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include "lua_util.h"
|
||||
#include "api_lua.h"
|
||||
@@ -217,8 +218,8 @@ int lua::LuaState::pushnil() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool lua::LuaState::getfield(const std::string& name) {
|
||||
lua_getfield(L, -1, name.c_str());
|
||||
bool lua::LuaState::getfield(const std::string& name, int idx) {
|
||||
lua_getfield(L, idx, name.c_str());
|
||||
if (lua_isnil(L, -1)) {
|
||||
lua_pop(L, -1);
|
||||
return false;
|
||||
@@ -287,3 +288,28 @@ void lua::LuaState::removeEnvironment(int id) {
|
||||
lua_pushnil(L);
|
||||
setglobal(envName(id));
|
||||
}
|
||||
|
||||
void lua::LuaState::dumpStack() {
|
||||
int top = gettop();
|
||||
for (int i = 1; i <= top; i++) {
|
||||
std::cout << std::setw(3) << i << std::setw(20) << luaL_typename(L, i) << std::setw(30);
|
||||
switch (lua_type(L, i)) {
|
||||
case LUA_TNUMBER:
|
||||
std::cout << tonumber(i);
|
||||
break;
|
||||
case LUA_TSTRING:
|
||||
std::cout << tostring(i);
|
||||
break;
|
||||
case LUA_TBOOLEAN:
|
||||
std::cout << (toboolean(i) ? "true" : "false");
|
||||
break;
|
||||
case LUA_TNIL:
|
||||
std::cout << "nil";
|
||||
break;
|
||||
default:
|
||||
std::cout << lua_topointer(L, i);
|
||||
break;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ namespace lua {
|
||||
int pushnil();
|
||||
int pushglobals();
|
||||
void pop(int n=1);
|
||||
bool getfield(const std::string& name);
|
||||
void setfield(const std::string& name, int idx=-2);
|
||||
bool getfield(const std::string& name, int idx = -1);
|
||||
void setfield(const std::string& name, int idx = -2);
|
||||
bool toboolean(int idx);
|
||||
luaint tointeger(int idx);
|
||||
luanumber tonumber(int idx);
|
||||
@@ -61,6 +61,8 @@ namespace lua {
|
||||
int createEnvironment(int parent);
|
||||
void removeEnvironment(int id);
|
||||
const std::string storeAnonymous();
|
||||
|
||||
void dumpStack();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -228,6 +228,8 @@ const luaL_Reg blocklib [] = {
|
||||
{"get_Z", lua_wrap_errors<l_get_block_z>},
|
||||
{"get_states", lua_wrap_errors<l_get_block_states>},
|
||||
{"set_states", lua_wrap_errors<l_set_block_states>},
|
||||
{"get_rotation", lua_wrap_errors<l_get_block_rotation>},
|
||||
{"set_rotation", lua_wrap_errors<l_set_block_rotation>},
|
||||
{"get_user_bits", lua_wrap_errors<l_get_block_user_bits>},
|
||||
{"set_user_bits", lua_wrap_errors<l_set_block_user_bits>},
|
||||
{NULL, NULL}
|
||||
|
||||
Reference in New Issue
Block a user