forked from github/server
LUA: region.herbtype
This commit is contained in:
parent
9fd87309c7
commit
d72c0ab07e
1 changed files with 23 additions and 7 deletions
|
@ -70,6 +70,21 @@ lua_region_getowner(const region& r) {
|
||||||
return region_owner(&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
|
static void
|
||||||
region_setinfo(region& r, const char * info) {
|
region_setinfo(region& r, const char * info) {
|
||||||
set_string(&r.display, info);
|
set_string(&r.display, info);
|
||||||
|
@ -123,7 +138,7 @@ region_setflag(region& r, int bit, bool set)
|
||||||
static int
|
static int
|
||||||
region_getresource(const region& r, const char * type)
|
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!=NULL) {
|
||||||
if (rtype==rt_find("money")) return rmoney(&r);
|
if (rtype==rt_find("money")) return rmoney(&r);
|
||||||
if (rtype==rt_find("peasant")) return rpeasants(&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, "grave")==0) return deathcount(&r);
|
||||||
if (strcmp(type, "chaos")==0) return chaoscount(&r);
|
if (strcmp(type, "chaos")==0) return chaoscount(&r);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -301,6 +316,7 @@ bind_region(lua_State * L)
|
||||||
.property("name", ®ion_getname, ®ion_setname)
|
.property("name", ®ion_getname, ®ion_setname)
|
||||||
.property("info", ®ion_getinfo, ®ion_setinfo)
|
.property("info", ®ion_getinfo, ®ion_setinfo)
|
||||||
.property("owner", &lua_region_getowner, &lua_region_setowner)
|
.property("owner", &lua_region_getowner, &lua_region_setowner)
|
||||||
|
.property("herbtype", ®ion_getherbtype, ®ion_setherbtype)
|
||||||
.property("terrain", ®ion_getterrain)
|
.property("terrain", ®ion_getterrain)
|
||||||
.def("add_notice", ®ion_addnotice)
|
.def("add_notice", ®ion_addnotice)
|
||||||
.def("add_direction", ®ion_adddirection)
|
.def("add_direction", ®ion_adddirection)
|
||||||
|
|
Loading…
Add table
Reference in a new issue