feat: Added Daedalus class

+ sqParseTable moved to nonut::CustomTypes as SqDict
+ fix: Removed Python constructors for ItemGround and DamageDescription classes (so it's unable to make new objects in the scripts)
This commit is contained in:
AURUMVORXX
2024-11-06 23:58:23 +03:00
parent fe0604d79c
commit f4ec811163
20 changed files with 141 additions and 98 deletions

View File

@@ -108,4 +108,33 @@ namespace nonut
GET_SLOT(y, Float);
GET_SLOT(z, Float);
}
void SqDict::convert(SQObject object)
{
Sqrat::Table tab = Sqrat::Table(object);
Sqrat::Object::iterator tabIterator;
int i = 0;
while (tab.Next(tabIterator))
{
HSQOBJECT key = tabIterator.getKey();
HSQOBJECT value = tabIterator.getValue();
if (key._type != OT_STRING)
continue;
if (value._type == OT_STRING)
data[sq_objtostring(&key)] = sq_objtostring(&value);
else if (value._type == OT_INTEGER)
data[sq_objtostring(&key)] = sq_objtointeger(&value);
else if (value._type == OT_FLOAT)
data[sq_objtostring(&key)] = sq_objtofloat(&value);
else if (value._type == OT_TABLE)
{
SqDict result = SqDict();
result.convert(object);
data[sq_objtostring(&key)] = result.data;
}
}
}
}

View File

@@ -2,9 +2,11 @@
#define NONUT_G2O_SHARED_CUSTOM_TYPES_H
#include <string>
#include <pybind11/embed.h>
#include "Utils.h"
namespace py = pybind11;
namespace nonut
{
struct GameTime : CustomType
@@ -164,5 +166,11 @@ namespace nonut
return std::make_tuple(name, x, y, z);
}
};
struct SqDict : CustomType
{
void convert(SQObject object) override;
py::dict data{};
};
}
#endif // NONUT_G2O_SHARED_CUSTOM_TYPES_H