Fix tangible scans to return tangible lists
This commit is contained in:
@@ -2,6 +2,21 @@
|
|||||||
#include "world.hpp"
|
#include "world.hpp"
|
||||||
#include "pprint.hpp"
|
#include "pprint.hpp"
|
||||||
|
|
||||||
|
static void tangible_getall(LuaStack &LS0, LuaSlot list, const util::IdVector &idv) {
|
||||||
|
LuaVar tangibles, tan;
|
||||||
|
LuaStack LS(LS0.state(), tangibles, tan);
|
||||||
|
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
||||||
|
assert(LS.istable(tangibles));
|
||||||
|
LS.set(list, LuaNewTable);
|
||||||
|
int index = 1;
|
||||||
|
for (int64_t id : idv) {
|
||||||
|
LS.rawget(tan, tangibles, id);
|
||||||
|
assert(LS.istable(tan));
|
||||||
|
LS.rawset(list, index++, tan);
|
||||||
|
}
|
||||||
|
LS.result();
|
||||||
|
}
|
||||||
|
|
||||||
LuaDefine(tangible_animstate, "c") {
|
LuaDefine(tangible_animstate, "c") {
|
||||||
LuaArg tanobj;
|
LuaArg tanobj;
|
||||||
LuaRet graphic, plane, x, y, z, facing;
|
LuaRet graphic, plane, x, y, z, facing;
|
||||||
@@ -208,9 +223,7 @@ LuaDefine(tangible_near, "c") {
|
|||||||
bool omit_self = LS.ckboolean(lomit_self);
|
bool omit_self = LS.ckboolean(lomit_self);
|
||||||
const AnimStep &aqback = tan->anim_queue_.back();
|
const AnimStep &aqback = tan->anim_queue_.back();
|
||||||
util::IdVector idv = w->plane_map_.scan_radius(aqback.plane(), aqback.xyz().x, aqback.xyz().y, radius, omit_nowhere, tan->id(), omit_self);
|
util::IdVector idv = w->plane_map_.scan_radius(aqback.plane(), aqback.xyz().x, aqback.xyz().y, radius, omit_nowhere, tan->id(), omit_self);
|
||||||
LS.set(list, LuaNewTable);
|
tangible_getall(LS, list, idv);
|
||||||
int index = 1;
|
|
||||||
for (int64_t id : idv) LS.rawset(list, index++, id);
|
|
||||||
return LS.result();
|
return LS.result();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,9 +238,7 @@ LuaDefine(tangible_scan, "c") {
|
|||||||
double radius = LS.cknumber(lradius);
|
double radius = LS.cknumber(lradius);
|
||||||
bool omit_nowhere = LS.ckboolean(lomit_nowhere);
|
bool omit_nowhere = LS.ckboolean(lomit_nowhere);
|
||||||
util::IdVector idv = w->plane_map_.scan_radius(plane, x, y, radius, omit_nowhere, 0, false);
|
util::IdVector idv = w->plane_map_.scan_radius(plane, x, y, radius, omit_nowhere, 0, false);
|
||||||
LS.set(list, LuaNewTable);
|
tangible_getall(LS, list, idv);
|
||||||
int index = 1;
|
|
||||||
for (int64_t id : idv) LS.rawset(list, index++, id);
|
|
||||||
return LS.result();
|
return LS.result();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user