LUA: region.herbtype

This commit is contained in:
Enno Rehling 2006-05-08 20:28:53 +00:00
parent 9fd87309c7
commit d72c0ab07e

View file

@ -70,6 +70,21 @@ lua_region_getowner(const region& r) {
return region_owner(&r);
}
static void
region_setherbtype(region& r, const char * str) {
const struct resource_type * rtype = rt_find(str);
if (rtype!=NULL && rtype->itype!=NULL) {
rsetherbtype(&r, rtype->itype);
}
}
static const char *
region_getherbtype(const region& r) {
const struct item_type * itype = rherbtype(&r);
if (itype==NULL) return NULL;
return itype->rtype->_name[0];
}
static void
region_setinfo(region& r, const char * info) {
set_string(&r.display, info);
@ -123,7 +138,7 @@ region_setflag(region& r, int bit, bool set)
static int
region_getresource(const region& r, const char * type)
{
const resource_type * rtype = rt_find(type);
const resource_type * rtype = rt_find(type);
if (rtype!=NULL) {
if (rtype==rt_find("money")) return rmoney(&r);
if (rtype==rt_find("peasant")) return rpeasants(&r);
@ -134,7 +149,7 @@ region_getresource(const region& r, const char * type)
if (strcmp(type, "grave")==0) return deathcount(&r);
if (strcmp(type, "chaos")==0) return chaoscount(&r);
}
return 0;
return 0;
}
static void
@ -301,6 +316,7 @@ bind_region(lua_State * L)
.property("name", &region_getname, &region_setname)
.property("info", &region_getinfo, &region_setinfo)
.property("owner", &lua_region_getowner, &lua_region_setowner)
.property("herbtype", &region_getherbtype, &region_setherbtype)
.property("terrain", &region_getterrain)
.def("add_notice", &region_addnotice)
.def("add_direction", &region_adddirection)