Lua code. The code will be replaced with its return value before being displayed to the user. The Lua code has no access to the thing being described, and so can only rely on global data.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3011 c06c8d41-db1a-0410-9941-cceddc491573
RN2DSYJRJ55J7S2VBEYCOAINFU4VDBMWDJIYJG326BSLYOFDNHGAC
BLAUMDRDEVFYDCBHIHX72IEZ35K3B426MUL6SBAZCRWZQMYOFAGAC
VCG3BRIYRTNNWYC3LOXD6KFGXOX37HAFW2HNV7WXVG2V7EUHLDZQC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
KR655YT3I3U5DMN5NS3FPUGMDNT4BI56K3SFF2FNJ77C45NFKL5AC
Y56C5OMUQ5XF2G6DKDV4R5MED44UOIUPTBBQVWQBUHYIXYA5MOZAC
J6APXOT4QOGQFONWB7G546VTVF6QG42HVOROMHF7YBDJPR4K26OAC
ZIFFVCQ72K35WGIUMZYN3KOXIUXF2CNXWKG6ZWEZ6LT3NSF3XOQAC
I7QLYOTE6DLQZM7YWUWYLKHRJRB2A3STQ42ALSRGQICEWKD2QTEQC
AUXVWXWIFSTWFA6VZXN2FMG7FQEKRZVV6MD32VQQ7J2RKCXHAVGAC
SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC
// either the wand "no charges left", the meat chunk
// "unpleasent", or the large shield "cumbersome"
// description can follow on the same line.
// either the wand "no charges left" or the meat chunk
// "unpleasent" description can follow on the same line.
if (item.sub_type == ARM_LARGE_SHIELD)
{
if (you.species == SP_TROLL || you.species == SP_OGRE
|| you.species == SP_OGRE_MAGE
|| player_genus(GENPC_DRACONIAN))
{
description << "It looks like it would fit you well. ";
}
else
{
description << "It is very cumbersome to wear, and "
"slows the rate at which you may attack. ";
}
}
static void execute_embedded_lua(std::string &str)
{
// Execute any lua code found between "{{" and "}}". The lua code
// is expected to return a string, with which the lua code and braces
// will be replaced.
std::string::size_type pos = str.find("{{");
while (pos != std::string::npos)
{
std::string::size_type end = str.find("}}", pos + 2);
if (end == std::string::npos)
{
mpr("Unbalanced {{, bailing.", MSGCH_DIAGNOSTICS);
break;
}
std::string lua_full = str.substr(pos, end - pos + 2);
std::string lua = str.substr(pos + 2, end - pos - 2);
if (clua.execstring(lua.c_str(), "db_embedded_lua", 1))
{
std::string err = "{{" + clua.error;
err += "}}";
str.replace(pos, lua_full.length(), err);
return;
}
std::string result;
clua.fnreturns(">s", &result);
str.replace(pos, lua_full.length(), result);
pos = str.find("{{", pos + result.length());
} // while (pos != std::string::npos)
}
Like a normal shield, only larger.
Like a normal shield, only larger. {{
if string.find(you.race(), "Ogre")
or string.find(you.race(), "Draconian")
or you.race() == "Troll"
then
return "It looks like it would fit you well."
else
return "It is very cumbersome to wear, and slows the rate at " ..
"which you may attack. "
end
}}
The slimy skin of a swamp-dwelling dragon. I suppose you could wear it
if you really wanted to.
The slimy{{
if you.can_smell() then
return ", smelly"
else
return ""
end
}} skin of a swamp-dwelling dragon. I suppose you could wear it if you really wanted to.