forked from github/server
Einheit besitzt "-1 Sternenstaub"? lua interface benoetigt Zugriff auf den Regionspool um use_-Funktionen korrekt zu implementieren. Issue: 1045
This commit is contained in:
parent
a87cc547e1
commit
fb63929d81
2 changed files with 26 additions and 2 deletions
|
@ -16,6 +16,7 @@
|
||||||
#include <kernel/magic.h>
|
#include <kernel/magic.h>
|
||||||
#include <kernel/movement.h>
|
#include <kernel/movement.h>
|
||||||
#include <kernel/order.h>
|
#include <kernel/order.h>
|
||||||
|
#include <kernel/pool.h>
|
||||||
#include <kernel/race.h>
|
#include <kernel/race.h>
|
||||||
#include <kernel/region.h>
|
#include <kernel/region.h>
|
||||||
#include <kernel/ship.h>
|
#include <kernel/ship.h>
|
||||||
|
@ -127,7 +128,27 @@ unit_additem(unit& u, const char * iname, int number)
|
||||||
if (itype!=NULL) {
|
if (itype!=NULL) {
|
||||||
item * i = i_change(&u.items, itype, number);
|
item * i = i_change(&u.items, itype, number);
|
||||||
return i?i->number:0;
|
return i?i->number:0;
|
||||||
} // if (itype!=NULL)
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
unit_usepooled(unit& u, const char * iname, int number)
|
||||||
|
{
|
||||||
|
const resource_type * rtype = rt_find(iname);
|
||||||
|
if (rtype!=NULL) {
|
||||||
|
return use_pooled(&u, rtype, GET_DEFAULT, number);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
unit_getpooled(unit& u, const char * iname)
|
||||||
|
{
|
||||||
|
const resource_type * rtype = rt_find(iname);
|
||||||
|
if (rtype!=NULL) {
|
||||||
|
return get_pooled(&u, rtype, GET_DEFAULT, INT_MAX);
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,6 +596,9 @@ bind_unit(lua_State * L)
|
||||||
.def("add_item", &unit_additem)
|
.def("add_item", &unit_additem)
|
||||||
.property("items", &unit_items, return_stl_iterator)
|
.property("items", &unit_items, return_stl_iterator)
|
||||||
|
|
||||||
|
.def("get_pooled", &unit_getpooled)
|
||||||
|
.def("use_pooled", &unit_usepooled)
|
||||||
|
|
||||||
// skills:
|
// skills:
|
||||||
.def("get_skill", &unit_getskill)
|
.def("get_skill", &unit_getskill)
|
||||||
.def("eff_skill", &unit_effskill)
|
.def("eff_skill", &unit_effskill)
|
||||||
|
|
|
@ -11,7 +11,7 @@ function use_stardust(u, amount)
|
||||||
u.region:set_resource("peasant", p)
|
u.region:set_resource("peasant", p)
|
||||||
local msg = usepotion_message(u, "stardust")
|
local msg = usepotion_message(u, "stardust")
|
||||||
msg:send_region(u.region)
|
msg:send_region(u.region)
|
||||||
u:add_item("stardust", -amount)
|
u:use_pooled("stardust", amount)
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue