utils.c
lpmoo-1.2/mudlib/lpc/utils.c · 895 B
From the archive lpmoo-1.2.tar.gz
Download the archive « Back to the archive contents
/*
* NAME: utils.c
* DESCRIPTION: minimal LPC primitives useful to call from MOO
*/
/*
* NAME: update()
* DESCRIPTION: destroy an object so it can be reloaded
*/
int update(string name)
{
object obj;
obj = find_object(name);
if (obj != 0)
{
destruct_object(obj);
return 1;
}
else
return 0;
}
/*
* NAME: eval()
* DESCRIPTION: evaluate arbitrary LPC code and return the result (if any)
*/
mixed eval(string code)
{
object obj;
mixed result;
string err;
obj = compile_object("# include <objects.h>\n" +
"mixed main(void) { " + code + "; }\n");
if (obj == 0)
error("LPC syntax error");
err = catch(result = obj->main());
destruct_object(obj);
if (err)
error(err);
return result;
}
/*
* NAME: cost_left()
* DESCRIPTION: return the remaining DGD execution cost
*/
int cost_left(void)
{
return get_exec_cost();
}