Got the whole look-at demo up and running.

This commit is contained in:
2025-04-07 19:29:47 -04:00
parent 865297331a
commit c060b87556
8 changed files with 166 additions and 149 deletions

View File

@@ -234,20 +234,17 @@ LuaDefine(tangible_setclass, "tan,class",
return LS.result();
}
LuaDefine(tangible_getclass, "tan",
"|Get the class of the tangible, if any."
LuaDefine(tangible_getclassname, "tan",
"|Get the classname of the tangible, if any."
"|"
"|The return value is a string, the class name, not"
"|the class table."
"|The return value is a string (or nil)."
"|") {
LuaArg tanobj;
LuaVar classtab;
LuaRet classname;
LuaDefStack LS(L, tanobj, classtab, classname);
LuaDefStack LS(L, tanobj, classname);
World *w = World::fetch_global_pointer(L);
w->tangible_get(LS, tanobj, false);
LS.tangetclass(classtab, tanobj);
eng::string name = LS.classname(classtab);
eng::string name = LS.classname(tanobj);
if (name == "") {
LS.set(classname, LuaNil);
} else {
@@ -256,6 +253,20 @@ LuaDefine(tangible_getclass, "tan",
return LS.result();
}
LuaDefine(tangible_getclass, "tan",
"|Get the class of the tangible, if any."
"|"
"|The return value is a class table (or nil)."
"|") {
LuaArg tanobj;
LuaRet classtab;
LuaDefStack LS(L, tanobj, classtab);
World *w = World::fetch_global_pointer(L);
w->tangible_get(LS, tanobj, false);
LS.tangetclass(classtab, tanobj);
return LS.result();
}
LuaDefine(tangible_delete, "tan",
"|Delete the specified tangible."
"|"

View File

@@ -27,8 +27,13 @@ function sphere.getlookat()
end
function engio.getlookat()
local place = tangible.place()
local class = tangible.getclass(place)
return class.getlookat()
local class = tangible.getclass(tangible.place())
if class ~= nil then
local getlookat = class.getlookat
if getlookat ~= nil then
return getlookat()
end
end
return ""
end