Make tangible.find use center={x,y,z} instead of centerx= etc

This commit is contained in:
2024-03-13 15:39:09 -04:00
parent 357e3766fb
commit fd8166f09c
7 changed files with 81 additions and 115 deletions

View File

@@ -5,15 +5,12 @@
#include "wrap-string.hpp"
#include "wrap-set.hpp"
#include "wrap-sstream.hpp"
#include "util.hpp"
LuaSpecial LuaRegistry(LUA_REGISTRYINDEX);
LuaNilMarker LuaNil;
LuaNewTableMarker LuaNewTable;
inline bool ascii_islower(char c) { return (c >= 'a') && (c <= 'z'); }
inline bool ascii_isupper(char c) { return (c >= 'A') && (c <= 'Z'); }
inline bool ascii_isdigit(char c) { return (c >= '0') && (c <= '9'); }
LuaFunctionReg::LuaFunctionReg(const char *n, const char *a, const char *d, bool s, lua_CFunction f) {
name_ = n;
args_ = a;
@@ -115,6 +112,21 @@ bool LuaCoreStack::isint(LuaSlot s) const {
return false;
}
bool LuaCoreStack::isxyz(LuaSlot s) const {
if (lua_istable(L_, s) && (lua_nkeys(L_, s) == 3)) {
int top = lua_gettop(L_);
lua_rawgeti(L_, s, 3);
lua_rawgeti(L_, s, 2);
lua_rawgeti(L_, s, 1);
if (lua_isnumber(L_, -1) && lua_isnumber(L_, -2) && lua_isnumber(L_, -3)) {
lua_settop(L_, top);
return true;
}
lua_settop(L_, top);
}
return false;
}
bool LuaCoreStack::ckboolean(LuaSlot s) const {
checkboolean(s, "value");
return lua_toboolean(L_, s) ? true:false;
@@ -172,6 +184,26 @@ LuaToken LuaCoreStack::cktoken(LuaSlot s) const {
return LuaToken(lua_touserdata(L_, s));
}
util::DXYZ LuaCoreStack::ckxyz(LuaSlot s) const {
if (lua_istable(L_, s) && (lua_nkeys(L_, s) == 3)) {
int top = lua_gettop(L_);
lua_rawgeti(L_, s, 3);
lua_rawgeti(L_, s, 2);
lua_rawgeti(L_, s, 1);
if (lua_isnumber(L_, -1) && lua_isnumber(L_, -2) && lua_isnumber(L_, -3)) {
util::DXYZ result;
result.x = lua_tonumber(L_, -1);
result.y = lua_tonumber(L_, -2);
result.z = lua_tonumber(L_, -3);
lua_settop(L_, top);
return result;
}
lua_settop(L_, top);
}
argerr("argument", "vector");
return util::DXYZ();
}
void LuaCoreStack::clearmetatable(LuaSlot tab) const {
lua_pushnil(L_);
lua_setmetatable(L_, tab);
@@ -225,14 +257,7 @@ lua_State *LuaCoreStack::newthread(LuaSlot target) const {
}
bool LuaCoreStack::valididentifier(std::string_view str) {
if (str.size() == 0) return false;
char c=str[0];
if ((!ascii_islower(c)) && (!ascii_isupper(c)) && (c!='_')) return false;
for (int i = 1; i < int(str.size()); i++) {
char c = str[i];
if ((!ascii_islower(c)) && (!ascii_isupper(c)) && (!ascii_isdigit(c)) && (c!='_')) return false;
}
return true;
return sv::is_lua_id(str);
}
bool LuaCoreStack::validint64(int64_t value) {