MCPcopy Create free account
hub / github.com/DFHack/dfhack / dfhack_matinfo_matches

Function dfhack_matinfo_matches

library/LuaApi.cpp:566–595  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

564}
565
566static 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
597static const luaL_Reg dfhack_matinfo_funcs[] = {
598 { "find", dfhack_matinfo_find },

Callers

nothing calls this directly

Calls 7

decode_matinfoFunction · 0.85
luaL_argerrorFunction · 0.85
luaL_checkanyFunction · 0.85
lua_isuserdataFunction · 0.85
lua_pushbooleanFunction · 0.85
CheckDFAssignFunction · 0.85
matchesMethod · 0.45

Tested by

no test coverage detected