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

@@ -22,7 +22,7 @@ LuaDefine(tangible_xyz, "tan",
"|Returns four values: x, y, z, plane") {
LuaArg tanobj;
LuaRet x, y, z, plane;
LuaDefStack LS(L, tanobj, x, y, z);
LuaDefStack LS(L, tanobj, x, y, z, plane);
World *w = World::fetch_global_pointer(L);
Tangible *tan = w->tangible_get(LS, tanobj, false);
AnimCoreState pos = tan->anim_queue_.get_final_core_state();
@@ -212,9 +212,11 @@ LuaDefine(tangible_animate, "tan,options,config",
LuaDefine(tangible_setclass, "tan,class",
"|Set the class of the tangible."
"|"
"|The class can be a 'class table' (ie, a table of methods), "
"|or it can be a string that names a class. The tangible is "
"|given an __index metamethod that points at the class table.") {
"|given an __index metamethod that points at the class table."
"|") {
LuaArg tanobj, classname;
LuaVar classtab, mt;
LuaDefStack LS(L, tanobj, classname, classtab, mt);
@@ -231,8 +233,10 @@ LuaDefine(tangible_setclass, "tan,class",
LuaDefine(tangible_getclass, "tan",
"|Get the class of the tangible, if any."
"|"
"|The return value is a string, the class name, not"
"|the class table.") {
"|the class table."
"|") {
LuaArg tanobj;
LuaVar classtab;
LuaRet classname;
@@ -251,6 +255,7 @@ LuaDefine(tangible_getclass, "tan",
LuaDefine(tangible_delete, "tan",
"|Delete the specified tangible."
"|"
"|This cannot be used to delete player tangibles,"
"|To delete a player, use tangible.redirect") {
LuaArg tanobj;
@@ -399,46 +404,6 @@ LuaDefine(tangible_place, "",
return LS.result();
}
LuaDefine(tangible_near, "tan,radius,omit_nowhere,omit_self",
"|Deprecated. Use tangible.find instead.") {
LuaArg ltan, lradius, lomit_nowhere, lomit_self;
LuaRet list;
LuaDefStack LS(L, ltan, lradius, lomit_nowhere, lomit_self, list);
World *w = World::fetch_global_pointer(L);
Tangible *tan = w->tangible_get(LS, ltan, false);
PlaneScan scan;
scan.set_radius(LS.cknumber(lradius));
scan.set_shape(PlaneScan::SPHERE);
scan.set_sorted(true);
scan.set_near(tan->id(), !LS.ckboolean(lomit_self));
scan.set_omit_nowhere(LS.ckboolean(lomit_nowhere));
util::IdVector idv;
w->get_near(scan, &idv);
tangible_getall(LS, list, idv);
return LS.result();
}
LuaDefine(tangible_scan, "plane,x,y,radius,omit_nowhere",
"|Deprecated. Use tangible.find instead.") {
LuaArg lplane, lx, ly, lradius, lomit_nowhere;
LuaRet list;
LuaDefStack LS(L, lplane, lx, ly, lradius, lomit_nowhere, list);
World *w = World::fetch_global_pointer(L);
PlaneScan scan;
scan.set_plane(LS.ckstring(lplane));
scan.set_center_and_radius(util::XYZ(LS.cknumber(lx), LS.cknumber(ly), 0), LS.cknumber(lradius));
scan.set_shape(PlaneScan::SPHERE);
scan.set_sorted(true);
scan.set_omit_nowhere(LS.ckboolean(lomit_nowhere));
util::IdVector idv;
w->get_near(scan, &idv);
tangible_getall(LS, list, idv);
return LS.result();
}
LuaDefine(tangible_find, "config",
"|Find tangibles by their location."
"|"
@@ -447,25 +412,16 @@ LuaDefine(tangible_find, "config",
"|include these parameters in the table:"
"|"
"| plane : the plane to search (a string)"
"| centerx : x-coordinate of the center of the search"
"| centery : y-coordinate of the center of the search"
"| centerz : z-coordinate of the center of the search"
"| radius : the radius of the search"
"| center : xyz of the center of the search (a vector)"
"| radius : the radius of the search (a vector or number)"
"| shape : 'box', 'sphere', or 'cylinder'"
"|"
"|Shape has a default: 'sphere'. The other parameters do"
"|not have default values."
"|"
"|Instead of specifying the radius as a single float,"
"|you may optionally specify separate radii for each dimension."
"|"
"| radiusx : the radius in the x-dimension."
"| radiusy : the radius in the y-dimension."
"| radiusz : the radius in the z-dimension."
"|"
"|If you specify different radii in each dimension, then the"
"|'sphere' shape will actually be a spheroid, and the 'cylinder'"
"|shape will actually be a cylindroid."
"|If you specify the radius as a vector, ie, different radii in"
"|each dimension, then the 'sphere' shape will actually be a"
"|spheroid, and the 'cylinder' shape will actually be a cylindroid."
"|"
"|Instead of specifying the center and plane, you can specify"
"|a tangible to search near:"