Merge pull request #317 from Buurazu/master

Flip improvements + etc
This commit is contained in:
wofsauge authored and GitHub committed 2022-01-16 02:09:17 +01:00
commit 3fd79fde59
5 files changed
+118 -57

No files matched your search

+5 -3
View File
@@ -484,6 +484,7 @@ end
function EID:getXMLDescription(Type, Variant, SubType) function EID:getXMLDescription(Type, Variant, SubType)
local tableName = EID:getTableName(Type, Variant, SubType) local tableName = EID:getTableName(Type, Variant, SubType)
local desc= nil local desc= nil
if SubType == 0 then return "(no description available)" end
if tableName == "collectibles" then if tableName == "collectibles" then
desc = EID.itemConfig:GetCollectible(SubType).Description desc = EID.itemConfig:GetCollectible(SubType).Description
elseif tableName == "trinkets" then elseif tableName == "trinkets" then
@@ -507,7 +508,7 @@ function EID:hasDescription(entity)
isAllowed = isAllowed or (entity.Variant == PickupVariant.PICKUP_TRINKET and EID.Config["DisplayTrinketInfo"]) isAllowed = isAllowed or (entity.Variant == PickupVariant.PICKUP_TRINKET and EID.Config["DisplayTrinketInfo"])
isAllowed = isAllowed or (entity.Variant == PickupVariant.PICKUP_TAROTCARD and EID.Config["DisplayCardInfo"]) isAllowed = isAllowed or (entity.Variant == PickupVariant.PICKUP_TAROTCARD and EID.Config["DisplayCardInfo"])
isAllowed = isAllowed or (entity.Variant == PickupVariant.PICKUP_PILL and EID.Config["DisplayPillInfo"]) isAllowed = isAllowed or (entity.Variant == PickupVariant.PICKUP_PILL and EID.Config["DisplayPillInfo"])
return isAllowed and entity.SubType > 0 return isAllowed and (entity.SubType > 0 or EID:getEntityData(entity, "EID_FlipItemID"))
end end
if entity.Type == 6 and entity.Variant == 16 and EID.Config["DisplayCraneInfo"] and REPENTANCE then if entity.Type == 6 and entity.Variant == 16 and EID.Config["DisplayCraneInfo"] and REPENTANCE then
isAllowed = not entity:GetSprite():IsPlaying("Broken") and not entity:GetSprite():IsPlaying("Prize") and EID.CraneItemType[tostring(entity.InitSeed)] isAllowed = not entity:GetSprite():IsPlaying("Broken") and not entity:GetSprite():IsPlaying("Prize") and EID.CraneItemType[tostring(entity.InitSeed)]
@@ -905,8 +906,9 @@ function EID:isCollectibleUnlocked(collectibleID, itemPoolOfItem)
end end
function EID:isCollectibleUnlockedAnyPool(collectibleID) function EID:isCollectibleUnlockedAnyPool(collectibleID)
--THIS FUNCTION IS FOR REPENTANCE ONLY due to using Repentance XML data; currently used by the Achievement Check, Spindown Dice, and Bag of Crafting --THIS FUNCTION IS FOR REPENTANCE ONLY due to using Repentance XML data
if not REPENTANCE then return true end --Currently used by the Achievement Check, Spindown Dice, and Bag of Crafting
if not REPENTANCE or EID:PlayersHaveCollectible(CollectibleType.COLLECTIBLE_TMTRAINER) then return true end
local item = EID.itemConfig:GetCollectible(collectibleID) local item = EID.itemConfig:GetCollectible(collectibleID)
if item == nil then return false end if item == nil then return false end
if EID.itemUnlockStates[collectibleID] == nil then if EID.itemUnlockStates[collectibleID] == nil then
+9 -2
View File
@@ -834,14 +834,21 @@ function EID:handleBagOfCraftingRendering()
--Display the result of the 8 items in our bag --Display the result of the 8 items in our bag
if (showCraftingResult or EID.Config["BagOfCraftingDisplayMode"] == "Preview Only") and #EID.BagItems >= 8 then if (showCraftingResult or EID.Config["BagOfCraftingDisplayMode"] == "Preview Only") and #EID.BagItems >= 8 then
local craftingResult, backupResult = EID:calculateBagOfCrafting(EID.BagItems) local craftingResult, backupResult = EID:calculateBagOfCrafting(EID.BagItems)
if Input.IsActionPressed(ButtonAction.ACTION_MAP, EID.player.ControllerIndex) then
local descriptionObj = EID:getDescriptionObj(5, 100, backupResult)
descriptionObj.Description = getHotkeyString() .. descriptionObj.Description
EID:printDescription(descriptionObj)
return true
end
local descriptionObj = EID:getDescriptionObj(5, 100, craftingResult) local descriptionObj = EID:getDescriptionObj(5, 100, craftingResult)
local infoText = EID:getDescriptionEntry("FlipItemToggleInfo")
--prepend the Hide/Preview hotkeys to the description --prepend the Hide/Preview hotkeys to the description
descriptionObj.Description = getHotkeyString() .. descriptionObj.Description descriptionObj.Description = getHotkeyString() .. descriptionObj.Description
local backupObj = EID:getDescriptionObj(5, 100, backupResult) local backupObjName = EID:getObjectName(5, 100, backupResult)
if (backupResult ~= craftingResult) then if (backupResult ~= craftingResult) then
local backupDesc = EID:getDescriptionEntry("CraftingPreviewBackup") local backupDesc = EID:getDescriptionEntry("CraftingPreviewBackup")
EID:appendToDescription(descriptionObj,"#" .. backupDesc .. "#{{Collectible" .. backupResult .. "}} " .. EID:appendToDescription(descriptionObj,"#" .. backupDesc .. "#{{Collectible" .. backupResult .. "}} " ..
EID:getObjectName(5, 100, backupResult) .. "#" .. backupObj.Description) backupObjName .. "#{{Blank}} " .. infoText)
end end
EID:printDescription(descriptionObj) EID:printDescription(descriptionObj)
return true return true
+2 -1
View File
@@ -408,7 +408,8 @@ local game = Game()
local function FlipCallback(descObj) local function FlipCallback(descObj)
local flipItemID = EID:getEntityData(descObj.Entity, "EID_FlipItemID") local flipItemID = EID:getEntityData(descObj.Entity, "EID_FlipItemID")
if Input.IsActionPressed(ButtonAction.ACTION_MAP, EID.player.ControllerIndex) then if flipItemID <= 0 then return descObj end
if descObj.ObjSubType == 0 or Input.IsActionPressed(ButtonAction.ACTION_MAP, EID.player.ControllerIndex) then
local descEntry = EID:getDescriptionObj(5, 100, flipItemID) local descEntry = EID:getDescriptionObj(5, 100, flipItemID)
return descEntry return descEntry
end end
+78 -29
View File
@@ -65,10 +65,10 @@ EID.ModIndicator = { }
-- Useful to associate items to mods -- Useful to associate items to mods
EID._currentMod = "" EID._currentMod = ""
local OldRegisterMod = RegisterMod local OldRegisterMod = RegisterMod
RegisterMod = function (modName, apiVersion) RegisterMod = function (modName, apiVersion, ...)
EID._currentMod = modName EID._currentMod = modName
EID.ModIndicator[modName] = { Name = modName, Icon = nil } EID.ModIndicator[modName] = { Name = modName, Icon = nil }
return OldRegisterMod(modName, apiVersion) return OldRegisterMod(modName, apiVersion, ...)
end end
------- Load all modules and other stuff ------ ------- Load all modules and other stuff ------
@@ -149,7 +149,7 @@ if not success then
end end
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
-------------------------Handle Sacrifice Room----------------------------- -------------Handle Sacrifice Room & Resetting Floor Trackers--------------
function EID:onNewFloor() function EID:onNewFloor()
EID.sacrificeCounter = {} EID.sacrificeCounter = {}
if REPENTANCE then if REPENTANCE then
@@ -238,21 +238,48 @@ function EID:IsAltChoice(pickup)
end end
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
--------------------Handle Crane Game & Flip Item-------------------------- -----------------Handle Crane Game & Flip Item Callbacks-------------------
local initialItemNext = false
local flipItemNext = false
if REPENTANCE then if REPENTANCE then
EID.flipItemPositions = {} EID.flipItemPositions = {}
local lastGetItemResult = {nil, nil, nil} -- itemID, Frame, gridIndex local lastGetItemResult = {nil, nil, nil} -- itemID, Frame, gridIndex
function EID:postGetCollectible(selectedCollectible, itemPoolType, decrease, seed) function EID:postGetCollectible(selectedCollectible, itemPoolType, decrease, seed)
-- Handle flip item -- Handle Flip item
-- PRE_ROOM_ENTITY_SPAWN sets us up to watch for the first POST_GET_COLLECTIBLE for this pedestal
-- (Tainted Isaac and Glitched Crown cause additional calls that have to be ignored)
-- POST_PICKUP_INIT occurs right before the Flip item is decided, so it sets us up to watch for the Flip item
-- POST_NEW_ROOM then handles putting the result in the entity's GetData
local curFrame = Isaac.GetFrameCount() local curFrame = Isaac.GetFrameCount()
if not decrease and curFrame == lastGetItemResult[2] and lastGetItemResult[1] ~= nil then local curRoomIndex = game:GetLevel():GetCurrentRoomIndex()
local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() if curFrame == lastGetItemResult[2] then
EID.flipItemPositions[curRoomIndex][lastGetItemResult[3]] = selectedCollectible if initialItemNext then lastGetItemResult[1] = selectedCollectible
elseif flipItemNext and lastGetItemResult[1] then
if EID.flipItemPositions[curRoomIndex] == nil then
EID.flipItemPositions[curRoomIndex] = {}
end
EID.flipItemPositions[curRoomIndex][lastGetItemResult[3]] = selectedCollectible
end
end end
-- Handle crane game -- Check if Flip item pedestals have moved (restock/Greed shops)
-- BUG if you leave the room before the new shop item spawns??
if EID.flipItemPositions[curRoomIndex] then
local pedestals = Isaac.FindByType(5, 100, -1, true, false)
for _, pedestal in ipairs(pedestals) do
local gridPos = game:GetRoom():GetGridIndex(pedestal.Position)
local oldGridPos = pedestal:GetData()["EID_FlipItemPedestalGrid"]
if EID.flipItemPositions[curRoomIndex][oldGridPos] and gridPos ~= oldGridPos then
EID.flipItemPositions[curRoomIndex][oldGridPos] = nil
EID.flipItemPositions[curRoomIndex][gridPos] = gridPos
pedestal:GetData()["EID_FlipItemPedestalGrid"] = gridPos
end
end
end
-- Handle Crane Game
if itemPoolType == ItemPoolType.POOL_CRANE_GAME then if itemPoolType == ItemPoolType.POOL_CRANE_GAME then
for _, crane in ipairs(Isaac.FindByType(6, 16, -1, true, false)) do for _, crane in ipairs(Isaac.FindByType(6, 16, -1, true, false)) do
if not crane:GetSprite():IsPlaying("Broken") then if not crane:GetSprite():IsPlaying("Broken") then
@@ -263,31 +290,49 @@ if REPENTANCE then
end end
end end
-- save last real collectible. for Flip Item handling initialItemNext = false
if decrease then flipItemNext = false
lastGetItemResult = {selectedCollectible, curFrame, nil}
end
end end
EID:AddCallback(ModCallbacks.MC_POST_GET_COLLECTIBLE, EID.postGetCollectible) EID:AddCallback(ModCallbacks.MC_POST_GET_COLLECTIBLE, EID.postGetCollectible)
-- Handle Flip Item spawn -- Handle Flip Item spawn
function EID:preRoomEntitySpawn(entityType, variant, subtype, gridIndex, seed)
flipItemNext = false
if entityType == 5 and (variant == 100 or variant == 150) then
lastGetItemResult = {nil, Isaac.GetFrameCount(), gridIndex}
initialItemNext = true
end
end
EID:AddCallback(ModCallbacks.MC_PRE_ROOM_ENTITY_SPAWN, EID.preRoomEntitySpawn)
function EID:postPickupInit(entity) function EID:postPickupInit(entity)
local curFrame = Isaac.GetFrameCount() flipItemNext = true
if entity.SubType == lastGetItemResult[1] and curFrame == lastGetItemResult[2] then
local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() -- Keep the Flip item the same for pedestal rerolls
if EID.flipItemPositions[curRoomIndex] == nil then local curRoomIndex = game:GetLevel():GetCurrentRoomIndex()
EID.flipItemPositions[curRoomIndex] = {} local gridPos = game:GetRoom():GetGridIndex(entity.Position)
end local flipEntry = EID.flipItemPositions[curRoomIndex] and EID.flipItemPositions[curRoomIndex][gridPos]
local gridPos = game:GetRoom():GetGridIndex(entity.Position) if flipEntry then entity:GetData()["EID_FlipItemID"] = flipEntry end
local flipEntry = EID.flipItemPositions[curRoomIndex][gridPos] end
if not flipEntry then EID:AddCallback(ModCallbacks.MC_POST_PICKUP_INIT, EID.postPickupInit, PickupVariant.PICKUP_COLLECTIBLE)
lastGetItemResult[3] = gridPos
else function EID:preUseFlip(_)
entity:GetData()["EID_FlipItemID"] = flipEntry local curRoomIndex = game:GetLevel():GetCurrentRoomIndex()
if EID.flipItemPositions[curRoomIndex] then
local pedestals = Isaac.FindByType(5, 100, -1, true, false)
for _, pedestal in ipairs(pedestals) do
local gridPos = game:GetRoom():GetGridIndex(pedestal.Position)
if EID.flipItemPositions[curRoomIndex][gridPos] then
-- don't swap a flip shadow with an empty pedestal!
if pedestal.SubType == 0 then EID.flipItemPositions[curRoomIndex][gridPos] = nil
else EID.flipItemPositions[curRoomIndex][gridPos] = pedestal.SubType end
--postPickupInit will take care of assigning it to the entity's data
end
end end
end end
end end
EID:AddCallback(ModCallbacks.MC_POST_PICKUP_INIT, EID.postPickupInit) EID:AddCallback(ModCallbacks.MC_PRE_USE_ITEM, EID.preUseFlip, CollectibleType.COLLECTIBLE_FLIP)
end end
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
@@ -463,6 +508,8 @@ if REPENTANCE then
isMirrorRoom = game:GetLevel():GetCurrentRoom():IsMirrorWorld() isMirrorRoom = game:GetLevel():GetCurrentRoom():IsMirrorWorld()
-- Handle Flip Item -- Handle Flip Item
initialItemNext = false
flipItemNext = false
local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() local curRoomIndex = game:GetLevel():GetCurrentRoomIndex()
if EID:PlayersHaveCollectible(CollectibleType.COLLECTIBLE_FLIP) and EID.flipItemPositions[curRoomIndex] then if EID:PlayersHaveCollectible(CollectibleType.COLLECTIBLE_FLIP) and EID.flipItemPositions[curRoomIndex] then
local pedestals = Isaac.FindByType(5, 100, -1, true, false) local pedestals = Isaac.FindByType(5, 100, -1, true, false)
@@ -471,6 +518,8 @@ if REPENTANCE then
local flipEntry = EID.flipItemPositions[curRoomIndex][gridPos] local flipEntry = EID.flipItemPositions[curRoomIndex][gridPos]
if flipEntry then if flipEntry then
pedestal:GetData()["EID_FlipItemID"] = flipEntry pedestal:GetData()["EID_FlipItemID"] = flipEntry
pedestal:GetData()["EID_FlipItemPedestalIndex"] = pedestal.Index
pedestal:GetData()["EID_FlipItemPedestalGrid"] = gridPos
end end
end end
end end
@@ -1127,4 +1176,4 @@ end
if EID.enableDebug then if EID.enableDebug then
require("eid_debugging") require("eid_debugging")
end end
+24 -22
View File
@@ -648,28 +648,30 @@ if MCMLoaded then
end end
} }
) )
------------Glitched Items-------------- if REPENTANCE then
MCM.AddSetting( ------------Glitched Items--------------
"EID", MCM.AddSetting(
"Display", "EID",
{ "Display",
Type = ModConfigMenu.OptionType.BOOLEAN, {
CurrentSetting = function() Type = ModConfigMenu.OptionType.BOOLEAN,
return EID.Config["DisplayGlitchedItemInfo"] CurrentSetting = function()
end, return EID.Config["DisplayGlitchedItemInfo"]
Display = function() end,
local onOff = "False" Display = function()
if EID.Config["DisplayGlitchedItemInfo"] then local onOff = "False"
onOff = "True" if EID.Config["DisplayGlitchedItemInfo"] then
end onOff = "True"
return "Glitched Item Infos: " .. onOff end
end, return "Glitched Item Infos: " .. onOff
OnChange = function(currentBool) end,
EID.Config["DisplayGlitchedItemInfo"] = currentBool OnChange = function(currentBool)
end, EID.Config["DisplayGlitchedItemInfo"] = currentBool
Info = {"Note: The --luadebug launch option is required for more detailed glitched item descriptions"} end,
} Info = {"Note: The --luadebug launch option is required for more detailed glitched item descriptions"}
) }
)
end
--------Sacrifice Room--------- --------Sacrifice Room---------
MCM.AddSetting( MCM.AddSetting(
"EID", "EID",