#include "classes.h" #include "entity/pickup/item_config.h" #include "lua/api.h" // Registers ItemConfig.Item, a collectible, trinket or null item, and ItemConfig.Costume. static void item_register(lua_State* state) { lua_class_begin(state, "Item", LUA_CLASS_ITEM_CONFIG_ITEM); lua_method(state, "IsCollectible", [](ItemConfig_Item& item) { return item.IsCollectible(); }); lua_method(state, "IsTrinket", [](ItemConfig_Item& item) { return item.IsTrinket(); }); lua_method(state, "IsNull", [](ItemConfig_Item& item) { return item.IsNull(); }); lua_method(state, "HasTags", [](ItemConfig_Item& item, uint64_t tags) { return item.HasTags(tags); }); lua_method(state, "IsAvailable", [](ItemConfig_Item& item, bool isIgnoreUnlock) { return item.IsAvailable(isIgnoreUnlock ? UNLOCK_IGNORED : UNLOCK_CHECKED); }); lua_field<&ItemConfig_Item::type>(state, "Type"); lua_field<&ItemConfig_Item::id>(state, "ID"); lua_field<&ItemConfig_Item::name>(state, "Name"); lua_field<&ItemConfig_Item::desc>(state, "Description"); lua_field<&ItemConfig_Item::gfxFilename>(state, "GfxFileName"); lua_field<&ItemConfig_Item::achievementId>(state, "AchievementID"); lua_field<&ItemConfig_Item::cacheFlags>(state, "CacheFlags"); lua_field<&ItemConfig_Item::addMaxHearts>(state, "AddMaxHearts"); lua_field<&ItemConfig_Item::addHearts>(state, "AddHearts"); lua_field<&ItemConfig_Item::addSoulHearts>(state, "AddSoulHearts"); lua_field<&ItemConfig_Item::addBlackHearts>(state, "AddBlackHearts"); lua_field<&ItemConfig_Item::addBombs>(state, "AddBombs"); lua_field<&ItemConfig_Item::addKeys>(state, "AddKeys"); lua_field<&ItemConfig_Item::addCoins>(state, "AddCoins"); lua_field<&ItemConfig_Item::maxCharges>(state, "MaxCharges"); lua_field<&ItemConfig_Item::maxCooldown>(state, "MaxCooldown"); lua_field<&ItemConfig_Item::isSpecial>(state, "Special"); lua_field<&ItemConfig_Item::devilPrice>(state, "DevilPrice"); lua_field<&ItemConfig_Item::initCharge>(state, "InitCharge"); lua_field<&ItemConfig_Item::chargeType>(state, "ChargeType"); lua_field<&ItemConfig_Item::shopPrice>(state, "ShopPrice"); lua_field<&ItemConfig_Item::isPassiveCache>(state, "PassiveCache"); lua_field<&ItemConfig_Item::isAddCostumeOnPickup>(state, "AddCostumeOnPickup"); lua_field<&ItemConfig_Item::isHidden>(state, "Hidden"); lua_field<&ItemConfig_Item::isPersistentEffect>(state, "PersistentEffect"); lua_field<&ItemConfig_Item::isClearEffectsOnRemove>(state, "ClearEffectsOnRemove"); lua_field<&ItemConfig_Item::tags>(state, "Tags"); lua_field<&ItemConfig_Item::quality>(state, "Quality"); lua_field<&ItemConfig_Item::craftingQuality>(state, "CraftingQuality"); lua_property(state, "Costume", [](ItemConfig_Item& item) -> ItemConfig_Costume& { return item.costume; }); lua_class_end(state, LUA_SCOPE_NAMESPACE); lua_class_begin(state, "Costume", LUA_CLASS_ITEM_CONFIG_COSTUME); lua_field<&ItemConfig_Costume::id>(state, "ID"); lua_field<&ItemConfig_Costume::anm2Path>(state, "Anm2Path"); lua_field<&ItemConfig_Costume::priority>(state, "Priority"); lua_field<&ItemConfig_Costume::isHasOverlay>(state, "HasOverlay"); lua_field<&ItemConfig_Costume::isFlying>(state, "IsFlying"); lua_field<&ItemConfig_Costume::isHasSkinAlt>(state, "HasSkinAlt"); lua_field<&ItemConfig_Costume::skinColor>(state, "SkinColor"); lua_field<&ItemConfig_Costume::isOverwriteColor>(state, "OverwriteColor"); lua_class_end(state, LUA_SCOPE_NAMESPACE); } // Registers ItemConfig.Card and ItemConfig.PillEffect, the pocket items pocketitems.xml describes. static void pocket_items_register(lua_State* state) { lua_class_begin(state, "Card", LUA_CLASS_ITEM_CONFIG_CARD); lua_field<&ItemConfig_Card::id, ItemConfig_Card>(state, "ID"); lua_field<&ItemConfig_Card::achievementId, ItemConfig_Card>(state, "AchievementID"); lua_field<&ItemConfig_Card::name, ItemConfig_Card>(state, "Name"); lua_field<&ItemConfig_Card::desc, ItemConfig_Card>(state, "Description"); lua_field<&ItemConfig_Card::hudAnim>(state, "HudAnim"); lua_field<&ItemConfig_Card::isGreedModeAllowed, ItemConfig_Card>(state, "GreedModeAllowed"); lua_field<&ItemConfig_Card::pickupSubtype>(state, "PickupSubtype"); lua_field<&ItemConfig_Card::cardType>(state, "CardType"); lua_field<&ItemConfig_Card::announcerVoice, ItemConfig_Card>(state, "AnnouncerVoice"); lua_field<&ItemConfig_Card::announcerDelay, ItemConfig_Card>(state, "AnnouncerDelay"); lua_field<&ItemConfig_Card::mimicCharge, ItemConfig_Card>(state, "MimicCharge"); lua_method(state, "IsCard", [](ItemConfig_Card& card) { return card.IsCard(); }); lua_method(state, "IsRune", [](ItemConfig_Card& card) { return card.IsRune(); }); lua_method(state, "IsAvailable", [](ItemConfig_Card& card) { return card.IsAvailable(); }); lua_class_end(state, LUA_SCOPE_NAMESPACE); lua_class_begin(state, "PillEffect", LUA_CLASS_ITEM_CONFIG_PILL); lua_field<&ItemConfig_Pill::id, ItemConfig_Pill>(state, "ID"); lua_field<&ItemConfig_Pill::achievementId, ItemConfig_Pill>(state, "AchievementID"); lua_field<&ItemConfig_Pill::name, ItemConfig_Pill>(state, "Name"); lua_field<&ItemConfig_Pill::isGreedModeAllowed, ItemConfig_Pill>(state, "GreedModeAllowed"); lua_field<&ItemConfig_Pill::announcerVoice, ItemConfig_Pill>(state, "AnnouncerVoice"); lua_field<&ItemConfig_Pill::announcerVoiceSuper>(state, "AnnouncerVoiceSuper"); lua_field<&ItemConfig_Pill::announcerDelay, ItemConfig_Pill>(state, "AnnouncerDelay"); lua_field<&ItemConfig_Pill::mimicCharge, ItemConfig_Pill>(state, "MimicCharge"); lua_field<&ItemConfig_Pill::effectClass>(state, "EffectClass"); lua_field<&ItemConfig_Pill::effectSubClass>(state, "EffectSubClass"); lua_method(state, "IsAvailable", [](ItemConfig_Pill& pill) { return pill.IsAvailable(); }); lua_class_end(state, LUA_SCOPE_NAMESPACE); } // Registers the ItemConfig namespace: the config classes, their lists, and Config, which Isaac.GetItemConfig returns. void lua_api_item_config_register(lua_State* state) { lua_namespace_begin(state, "ItemConfig"); item_register(state); pocket_items_register(state); lua_list_register>>(state, "ItemConfigList"); lua_list_register>>(state, "CardConfigList"); lua_list_register>>(state, "PillConfigList"); lua_class_begin(state, "Config", LUA_CLASS_ITEM_CONFIG); lua_method(state, "GetCollectible", [](ItemConfig& config, int id) { return config.GetCollectible(id); }); lua_method(state, "GetTrinket", [](ItemConfig& config, uint32_t id) { return config.GetTrinket(id); }); lua_method(state, "GetNullItem", [](ItemConfig& config, int id) { return config.GetNullItem(id); }); lua_method(state, "GetCard", [](ItemConfig& config, int id) { return config.GetCard(id); }); lua_method(state, "GetPillEffect", [](ItemConfig& config, int id) { return config.GetPillEffect(id); }); lua_method(state, "GetCollectibles", [](ItemConfig& config) -> auto& { return config.collectibles; }); lua_method(state, "GetTrinkets", [](ItemConfig& config) -> auto& { return config.trinkets; }); lua_method(state, "GetNullItems", [](ItemConfig& config) -> auto& { return config.nullItems; }); lua_method(state, "GetCards", [](ItemConfig& config) -> auto& { return config.cards; }); lua_method(state, "GetPillEffects", [](ItemConfig& config) -> auto& { return config.pillEffects; }); lua_static(state, "IsValidCollectible", [](int id) { return ItemConfig::IsValidCollectible(id); }); lua_static(state, "ShouldAddCostumeOnPickup", [](ItemConfig_Item* item) { return ItemConfig::ShouldAddCostumeOnPickup(item); }); lua_class_end(state, LUA_SCOPE_NAMESPACE); lua_class_end(state); }