Added a StringToMobType() function to the Lua API (patch contributed by STR_Warrior)
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1674 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
4fb771f3ff
commit
2fca0567bf
@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Lua binding: AllToLua
|
||||
** Generated automatically by tolua++-1.0.92 on 07/09/13 09:51:25.
|
||||
** Generated automatically by tolua++-1.0.92 on 07/12/13 22:26:52.
|
||||
*/
|
||||
|
||||
#ifndef __cplusplus
|
||||
@ -2561,6 +2561,36 @@ static int tolua_AllToLua_StringToBiome00(lua_State* tolua_S)
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* function: StringToMobType */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_StringToMobType00
|
||||
static int tolua_AllToLua_StringToMobType00(lua_State* tolua_S)
|
||||
{
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_iscppstring(tolua_S,1,0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,2,&tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
const AString a_MobString = ((const AString) tolua_tocppstring(tolua_S,1,0));
|
||||
{
|
||||
int tolua_ret = (int) StringToMobType(a_MobString);
|
||||
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
|
||||
tolua_pushcppstring(tolua_S,(const char*)a_MobString);
|
||||
}
|
||||
}
|
||||
return 2;
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'StringToMobType'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* function: StringToDimension */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_StringToDimension00
|
||||
static int tolua_AllToLua_StringToDimension00(lua_State* tolua_S)
|
||||
@ -28538,6 +28568,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
|
||||
tolua_function(tolua_S,"ItemTypeToString",tolua_AllToLua_ItemTypeToString00);
|
||||
tolua_function(tolua_S,"ItemToFullString",tolua_AllToLua_ItemToFullString00);
|
||||
tolua_function(tolua_S,"StringToBiome",tolua_AllToLua_StringToBiome00);
|
||||
tolua_function(tolua_S,"StringToMobType",tolua_AllToLua_StringToMobType00);
|
||||
tolua_function(tolua_S,"StringToDimension",tolua_AllToLua_StringToDimension00);
|
||||
tolua_function(tolua_S,"DamageTypeToString",tolua_AllToLua_DamageTypeToString00);
|
||||
tolua_function(tolua_S,"StringToDamageType",tolua_AllToLua_StringToDamageType00);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Lua binding: AllToLua
|
||||
** Generated automatically by tolua++-1.0.92 on 07/09/13 09:51:26.
|
||||
** Generated automatically by tolua++-1.0.92 on 07/12/13 22:26:52.
|
||||
*/
|
||||
|
||||
/* Exported function */
|
||||
|
@ -321,6 +321,56 @@ EMCSBiome StringToBiome(const AString & a_BiomeString)
|
||||
|
||||
|
||||
|
||||
int StringToMobType(const AString & a_MobString)
|
||||
{
|
||||
static struct {
|
||||
int m_MobType;
|
||||
const char * m_String;
|
||||
} MobMap [] =
|
||||
{
|
||||
{E_ENTITY_TYPE_CREEPER, "Creeper"},
|
||||
{E_ENTITY_TYPE_SKELETON, "Skeleton"},
|
||||
{E_ENTITY_TYPE_SPIDER, "Spider"},
|
||||
{E_ENTITY_TYPE_GIANT, "Giant"},
|
||||
{E_ENTITY_TYPE_ZOMBIE, "Zombie"},
|
||||
{E_ENTITY_TYPE_SLIME, "Slime"},
|
||||
{E_ENTITY_TYPE_GHAST, "Ghast"},
|
||||
{E_ENTITY_TYPE_ZOMBIE_PIGMAN, "ZombiePigman"},
|
||||
{E_ENTITY_TYPE_ENDERMAN, "Enderman"},
|
||||
{E_ENTITY_TYPE_CAVE_SPIDER, "CaveSpider"},
|
||||
{E_ENTITY_TYPE_SILVERFISH, "SilverFish"},
|
||||
{E_ENTITY_TYPE_BLAZE, "Blaze"},
|
||||
{E_ENTITY_TYPE_MAGMA_CUBE, "MagmaCube"},
|
||||
{E_ENTITY_TYPE_ENDER_DRAGON, "EnderDragon"},
|
||||
{E_ENTITY_TYPE_WITHER, "Wither"},
|
||||
{E_ENTITY_TYPE_BAT, "Bat"},
|
||||
{E_ENTITY_TYPE_WITCH, "Witch"},
|
||||
{E_ENTITY_TYPE_PIG, "Pig"},
|
||||
{E_ENTITY_TYPE_SHEEP, "Sheep"},
|
||||
{E_ENTITY_TYPE_COW, "Cow"},
|
||||
{E_ENTITY_TYPE_CHICKEN, "Chicken"},
|
||||
{E_ENTITY_TYPE_SQUID, "Squid"},
|
||||
{E_ENTITY_TYPE_WOLF, "Wolf"},
|
||||
{E_ENTITY_TYPE_MOOSHROOM, "Mushroom"},
|
||||
{E_ENTITY_TYPE_SNOW_GOLEM, "SnowGolem"},
|
||||
{E_ENTITY_TYPE_OCELOT, "Ocelot"},
|
||||
{E_ENTITY_TYPE_IRON_GOLEM, "IronGolem"},
|
||||
{E_ENTITY_TYPE_VILLAGER, "Villager"},
|
||||
};
|
||||
for (int i = 0; i < ARRAYCOUNT(MobMap); i++)
|
||||
{
|
||||
if (NoCaseCompare(MobMap[i].m_String, a_MobString) == 0)
|
||||
{
|
||||
return MobMap[i].m_MobType;
|
||||
}
|
||||
} // for i - MobMap[]
|
||||
return (int)-1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
eDimension StringToDimension(const AString & a_DimensionString)
|
||||
{
|
||||
// First try decoding as a number
|
||||
|
@ -688,6 +688,9 @@ extern AString ItemToFullString(const cItem & a_Item);
|
||||
/// Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns -1 on failure.
|
||||
extern EMCSBiome StringToBiome(const AString & a_BiomeString);
|
||||
|
||||
/// Translates a mob string ("ocelot") to mobtype (E_ENTITY_TYPE_OCELOT)
|
||||
extern int StringToMobType(const AString & a_MobString);
|
||||
|
||||
/// Translates a dimension string to dimension enum. Takes either a number or a dimension alias (built-in). Returns -1000 on failure
|
||||
extern eDimension StringToDimension(const AString & a_DimensionString);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user