Initial revision of lua 'doc' function
This commit is contained in:
@@ -17,7 +17,7 @@ static void tangible_getall(LuaStack &LS0, LuaSlot list, const util::IdVector &i
|
||||
LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(tangible_animstate, "c") {
|
||||
LuaDefine(tangible_animstate, "tan", "get the final animation state of the tangible") {
|
||||
LuaArg tanobj;
|
||||
LuaRet graphic, plane, x, y, z, facing;
|
||||
LuaStack LS(L, tanobj, graphic, plane, x, y, z, facing);
|
||||
@@ -33,7 +33,7 @@ LuaDefine(tangible_animstate, "c") {
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(tangible_animate, "c") {
|
||||
LuaDefine(tangible_animate, "tan,configtable", "add an animation step to the tangible") {
|
||||
LuaArg tanobj, config;
|
||||
LuaStack LS(L, tanobj, config);
|
||||
World *w = World::fetch_global_pointer(L);
|
||||
@@ -50,7 +50,7 @@ LuaDefine(tangible_animate, "c") {
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(tangible_setclass, "c") {
|
||||
LuaDefine(tangible_setclass, "tan,classname", "set the class of the tangible") {
|
||||
LuaArg tanobj, classname;
|
||||
LuaVar classtab, mt;
|
||||
LuaStack LS(L, tanobj, classname, classtab, mt);
|
||||
@@ -66,7 +66,7 @@ LuaDefine(tangible_setclass, "c") {
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(tangible_getclass, "c") {
|
||||
LuaDefine(tangible_getclass, "tan", "get the class of the tangible, if any") {
|
||||
LuaArg tanobj;
|
||||
LuaVar mt, classtab;
|
||||
LuaRet classname;
|
||||
@@ -84,7 +84,7 @@ LuaDefine(tangible_getclass, "c") {
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(tangible_delete, "c") {
|
||||
LuaDefine(tangible_delete, "tan", "delete the specified tangible") {
|
||||
LuaArg tanobj;
|
||||
LuaStack LS(L, tanobj);
|
||||
World *w = World::fetch_global_pointer(L);
|
||||
@@ -98,7 +98,7 @@ LuaDefine(tangible_delete, "c") {
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(tangible_build, "c") {
|
||||
LuaDefine(tangible_build, "configtable", "build a new tangible object") {
|
||||
LuaArg config;
|
||||
LuaVar classname, classtab, mt;
|
||||
LuaRet database;
|
||||
@@ -148,7 +148,7 @@ LuaDefine(tangible_build, "c") {
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(tangible_get, "c") {
|
||||
LuaDefine(tangible_get, "id", "get the tangible with the specified id (debugging only)") {
|
||||
LuaArg id;
|
||||
LuaVar tangibles;
|
||||
LuaRet database;
|
||||
@@ -162,7 +162,7 @@ LuaDefine(tangible_get, "c") {
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(tangible_redirect, "c") {
|
||||
LuaDefine(tangible_redirect, "tan1,tan2,bulldozetan1", "redirect is not working yet") {
|
||||
LuaArg actor1, actor2, bldz;
|
||||
LuaStack LS(L, actor1, actor2, bldz);
|
||||
World *w = World::fetch_global_pointer(L);
|
||||
@@ -184,7 +184,7 @@ LuaDefine(tangible_redirect, "c") {
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(tangible_id, "c") {
|
||||
LuaDefine(tangible_id, "tan", "return the tangible's id number (debugging only)") {
|
||||
LuaArg tanobj;
|
||||
LuaRet id;
|
||||
LuaStack LS(L, tanobj, id);
|
||||
@@ -196,7 +196,7 @@ LuaDefine(tangible_id, "c") {
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(tangible_actor, "c") {
|
||||
LuaDefine(tangible_actor, "", "return the current actor") {
|
||||
LuaRet actor;
|
||||
LuaVar tangibles;
|
||||
LuaStack LS(L, tangibles, actor);
|
||||
@@ -206,7 +206,7 @@ LuaDefine(tangible_actor, "c") {
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(tangible_place, "c") {
|
||||
LuaDefine(tangible_place, "", "return the current place") {
|
||||
LuaRet place;
|
||||
LuaVar tangibles;
|
||||
LuaStack LS(L, tangibles, place);
|
||||
@@ -216,7 +216,7 @@ LuaDefine(tangible_place, "c") {
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(tangible_near, "c") {
|
||||
LuaDefine(tangible_near, "tan,radius,omit_nowhere,omit_self", "scan near the specified tangible") {
|
||||
LuaArg ltan, lradius, lomit_nowhere, lomit_self;
|
||||
LuaRet list;
|
||||
LuaStack LS(L, ltan, lradius, lomit_nowhere, lomit_self, list);
|
||||
@@ -231,7 +231,7 @@ LuaDefine(tangible_near, "c") {
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(tangible_scan, "c") {
|
||||
LuaDefine(tangible_scan, "plane,x,y,radius,omit_nowhere", "scan the specified plane") {
|
||||
LuaArg lplane, lx, ly, lradius, lomit_nowhere;
|
||||
LuaRet list;
|
||||
LuaStack LS(L, lplane, lx, ly, lradius, lomit_nowhere, list);
|
||||
@@ -246,14 +246,14 @@ LuaDefine(tangible_scan, "c") {
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(world_wait, "f") {
|
||||
LuaDefine(wait, "nticks", "wait the specified number of ticks") {
|
||||
if ((lua_gettop(L) != 1) || (lua_type(L, -1) != LUA_TNUMBER)) {
|
||||
luaL_error(L, "Argument to wait must be a number.");
|
||||
}
|
||||
return lua_yield(L, 1);
|
||||
}
|
||||
|
||||
LuaDefine(tangible_nopredict, "c") {
|
||||
LuaDefine(tangible_nopredict, "", "stop predictive execution of this thread") {
|
||||
if (lua_gettop(L) != 0) {
|
||||
luaL_error(L, "tangible.nopredict takes no arguments");
|
||||
}
|
||||
@@ -265,35 +265,7 @@ LuaDefine(tangible_nopredict, "c") {
|
||||
}
|
||||
}
|
||||
|
||||
LuaDefine(world_getregistry, "f") {
|
||||
lua_pushvalue(L, LUA_REGISTRYINDEX);
|
||||
return 1;
|
||||
}
|
||||
|
||||
LuaDefine(world_xtype, "f") {
|
||||
LuaArg tab;
|
||||
LuaRet rtype;
|
||||
LuaStack LS(L, tab, rtype);
|
||||
int xt = LS.xtype(tab);
|
||||
LS.set(rtype, xt);
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(world_settabletype, "f") {
|
||||
LuaArg tab, ttype;
|
||||
LuaStack LS(L, tab, ttype);
|
||||
if (!LS.istable(tab)) {
|
||||
luaL_error(L, "Not a table");
|
||||
}
|
||||
int tt = LS.ckinteger(ttype);
|
||||
if ((tt < LUA_TT_GENERAL) || (tt > LUA_TT_CLASS)) {
|
||||
luaL_error(L, "table type out of range");
|
||||
}
|
||||
LS.settabletype(tab, tt);
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(world_pprint, "f") {
|
||||
LuaDefine(pprint, "obj1,obj2,...", "pretty-print all the objects") {
|
||||
World *w = World::fetch_global_pointer(L);
|
||||
std::ostream *ostream = w->lthread_print_stream();
|
||||
LuaStack LS(L);
|
||||
@@ -305,14 +277,27 @@ LuaDefine(world_pprint, "f") {
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(world_print, "f") {
|
||||
LuaDefine(print, "obj1,obj2,...", "print all the objects") {
|
||||
World *w = World::fetch_global_pointer(L);
|
||||
std::ostream *ostream = w->lthread_print_stream();
|
||||
LuaStack LS(L);
|
||||
for (int i = 1; i <= lua_gettop(L); i++) {
|
||||
LuaSpecial root(i);
|
||||
atomic_print(LS, root, ostream);
|
||||
atomic_print(LS, root, false, ostream);
|
||||
(*ostream) << std::endl;
|
||||
}
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(doc, "function", "print documentation for specified function") {
|
||||
World *w = World::fetch_global_pointer(L);
|
||||
std::ostream *ostream = w->lthread_print_stream();
|
||||
LuaArg func;
|
||||
LuaStack LS(L, func);
|
||||
std::string doc = SourceDB::function_docs(LS, func);
|
||||
if (doc == "") {
|
||||
(*ostream) << "no doc found" << std::endl;
|
||||
}
|
||||
(*ostream) << doc;
|
||||
return LS.result();
|
||||
}
|
||||
Reference in New Issue
Block a user