| 564 | } |
| 565 | |
| 566 | static int dfhack_matinfo_matches(lua_State *state) |
| 567 | { |
| 568 | MaterialInfo info; |
| 569 | if (!decode_matinfo(state, &info)) |
| 570 | luaL_argerror(state, 1, "material info object expected"); |
| 571 | |
| 572 | luaL_checkany(state, 2); |
| 573 | |
| 574 | if (lua_isuserdata(state, 2)) |
| 575 | { |
| 576 | if (auto mc = Lua::GetDFObject<df::job_material_category>(state, 2)) |
| 577 | lua_pushboolean(state, info.matches(*mc)); |
| 578 | else if (auto mc = Lua::GetDFObject<df::dfhack_material_category>(state, 2)) |
| 579 | lua_pushboolean(state, info.matches(*mc)); |
| 580 | else if (auto mc = Lua::GetDFObject<df::job_item>(state, 2)) |
| 581 | lua_pushboolean(state, info.matches(*mc)); |
| 582 | else |
| 583 | luaL_argerror(state, 2, "material category object expected"); |
| 584 | } |
| 585 | else if (lua_istable(state, 2)) |
| 586 | { |
| 587 | df::dfhack_material_category tmp; |
| 588 | Lua::CheckDFAssign(state, &tmp, 2, false); |
| 589 | lua_pushboolean(state, info.matches(tmp)); |
| 590 | } |
| 591 | else |
| 592 | luaL_argerror(state, 2, "material category object expected"); |
| 593 | |
| 594 | return 1; |
| 595 | } |
| 596 | |
| 597 | static const luaL_Reg dfhack_matinfo_funcs[] = { |
| 598 | { "find", dfhack_matinfo_find }, |
nothing calls this directly
no test coverage detected