forked from github/server
allow clearing attributes from lua
This commit is contained in:
parent
f1132ca9f4
commit
17ba4e7746
|
@ -746,6 +746,15 @@ static int tolua_unit_get_curse(lua_State *L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_unit_clear_attribs(lua_State *L) {
|
||||
unit *u = (unit *)tolua_tousertype(L, 1, NULL);
|
||||
const char *name = tolua_tostring(L, 2, NULL);
|
||||
const attrib_type *at = name ? at_find(name) : NULL;
|
||||
|
||||
a_removeall(&u->attribs, at);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_unit_has_attrib(lua_State *L) {
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *name = tolua_tostring(L, 2, 0);
|
||||
|
@ -978,6 +987,7 @@ void tolua_unit_open(lua_State * L)
|
|||
tolua_function(L, TOLUA_CAST "add_order", tolua_unit_add_order);
|
||||
tolua_function(L, TOLUA_CAST "clear_orders", tolua_unit_clear_orders);
|
||||
tolua_function(L, TOLUA_CAST "get_curse", tolua_unit_get_curse);
|
||||
tolua_function(L, TOLUA_CAST "clear_attribs", tolua_unit_clear_attribs);
|
||||
tolua_function(L, TOLUA_CAST "has_attrib", tolua_unit_has_attrib);
|
||||
|
||||
/* key-attributes for named flags: */
|
||||
|
|
20
src/gmtool.c
20
src/gmtool.c
|
@ -441,16 +441,6 @@ static void paint_info_region(window * wnd, const state * st)
|
|||
r->land->trees[1] + r->land->trees[2]);
|
||||
}
|
||||
line++;
|
||||
if (r->ships && (st->info_flags & IFL_SHIPS)) {
|
||||
ship *sh;
|
||||
wattron(win, A_BOLD | COLOR_PAIR(COLOR_YELLOW));
|
||||
mvwaddnstr(win, line++, 1, "* ships:", size - 5);
|
||||
wattroff(win, A_BOLD | COLOR_PAIR(COLOR_YELLOW));
|
||||
for (sh = r->ships; sh && line < maxline; sh = sh->next) {
|
||||
mvwprintw(win, line, 1, "%.4s ", itoa36(sh->no));
|
||||
umvwaddnstr(win, line++, 6, (char *)sh->type->_name, size - 5);
|
||||
}
|
||||
}
|
||||
if (r->units && (st->info_flags & IFL_FACTIONS)) {
|
||||
unit *u;
|
||||
wattron(win, A_BOLD | COLOR_PAIR(COLOR_YELLOW));
|
||||
|
@ -477,6 +467,16 @@ static void paint_info_region(window * wnd, const state * st)
|
|||
umvwaddnstr(win, line++, 6, unit_getname(u), size - 5);
|
||||
}
|
||||
}
|
||||
if (r->ships && (st->info_flags & IFL_SHIPS)) {
|
||||
ship *sh;
|
||||
wattron(win, A_BOLD | COLOR_PAIR(COLOR_YELLOW));
|
||||
mvwaddnstr(win, line++, 1, "* ships:", size - 5);
|
||||
wattroff(win, A_BOLD | COLOR_PAIR(COLOR_YELLOW));
|
||||
for (sh = r->ships; sh && line < maxline; sh = sh->next) {
|
||||
mvwprintw(win, line, 1, "%.4s ", itoa36(sh->no));
|
||||
umvwaddnstr(win, line++, 6, (char *)sh->type->_name, size - 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue