| 2449 | } |
| 2450 | |
| 2451 | int32_t units_getFocusPenalty(lua_State *L) { |
| 2452 | auto unit = Lua::GetDFObject<df::unit>(L, 1); |
| 2453 | Units::need_type_set needs; |
| 2454 | auto top = lua_gettop(L); |
| 2455 | if (top < 2) { |
| 2456 | luaL_argerror(L, 2, "Expected at least one need type"); |
| 2457 | } else { |
| 2458 | for (int i = 2; i <= top; ++i) { |
| 2459 | try { |
| 2460 | needs.set(luaL_checkint(L, i)); |
| 2461 | } catch ([[maybe_unused]] const std::out_of_range &e) { |
| 2462 | luaL_argerror(L, i, "Expected a need type"); |
| 2463 | } |
| 2464 | } |
| 2465 | Lua::Push(L, Units::getFocusPenalty(unit, needs)); |
| 2466 | } |
| 2467 | return 1; |
| 2468 | } |
| 2469 | |
| 2470 | static const luaL_Reg dfhack_units_funcs[] = { |
| 2471 | { "getPosition", units_getPosition }, |
nothing calls this directly
no test coverage detected