Added Scroll and hide features for Bag of crafting
This commit is contained in:
1 parent
10cd31d7cb
commit
94fa9d9456
4 files changed
+70
-15
No files matched your search
@@ -535,5 +535,5 @@ EID.descriptions["en_us"].horsepills={
|
||||
}
|
||||
|
||||
EID.descriptions["en_us"].CraftingRoomContent = "Pickups in room:"
|
||||
EID.descriptions["en_us"].CraftingResults = "Results:"
|
||||
EID.descriptions["en_us"].CraftingResults = "Results:#(Scroll: Hold TAB + Shoot △/▽)"
|
||||
|
||||
+7
-1
@@ -123,12 +123,18 @@ EID.DefaultConfig = {
|
||||
-- Toggle Display of Diceroom descriptions
|
||||
-- Default = true
|
||||
["DisplayDiceInfo"] = true,
|
||||
-------------MISC---------------
|
||||
---------Bag of Crafting-----------
|
||||
|
||||
-- Display-modes for Bag of Crafting descriptions
|
||||
-- Options: "always", "hold", "never"
|
||||
-- "always" = Always show Results, "hold" = Show when holding up bag, "never" = Never show results
|
||||
-- Default = "always"
|
||||
["DisplayBagOfCrafting"] = "always",
|
||||
-- Changes the number of Results shown in the Bag of crafting description
|
||||
-- Higher numbers can cause more lag!
|
||||
-- Default = 7
|
||||
["BagOfCraftingResults"] = 7,
|
||||
-------------MISC---------------
|
||||
-- Changes the number of Results shown for the additional Spindown dice description
|
||||
-- Default = 3
|
||||
["SpindownDiceResults"] = 3,
|
||||
|
||||
@@ -332,6 +332,8 @@ end
|
||||
|
||||
local randResultCache = {}
|
||||
|
||||
EID.bagOfCraftingOffset = 0
|
||||
|
||||
local function handleBagOfCraftingRendering()
|
||||
local results = {}
|
||||
local bagItems = {} -- TODO: Get content of Bag
|
||||
@@ -373,11 +375,13 @@ local function handleBagOfCraftingRendering()
|
||||
end
|
||||
randResultCache[queryString] = calcResults
|
||||
results = calcResults
|
||||
EID.bagOfCraftingOffset = 0
|
||||
else
|
||||
results = randResultCache[queryString]
|
||||
end
|
||||
|
||||
if #results == 0 then
|
||||
EID.bagOfCraftingOffset = 0
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -386,18 +390,37 @@ local function handleBagOfCraftingRendering()
|
||||
local resultDesc = EID.descriptions[EID.Config["Language"]].CraftingResults or EID.descriptions["en_us"].CraftingResults
|
||||
customDescObj.Description = roomDesc.."#"..EID:tableToCraftingIconsMerged(floorItems).."#"..resultDesc
|
||||
|
||||
if Input.IsActionPressed(ButtonAction.ACTION_MAP, 0) or Input.IsActionPressed(ButtonAction.ACTION_MAP, 1) then
|
||||
if Input.IsActionTriggered(ButtonAction.ACTION_SHOOTDOWN, 0) or Input.IsActionTriggered(ButtonAction.ACTION_SHOOTDOWN, 1) then
|
||||
EID.bagOfCraftingOffset = math.min(#results-(#results%EID.Config["BagOfCraftingResults"]), EID.bagOfCraftingOffset + EID.Config["BagOfCraftingResults"])
|
||||
elseif Input.IsActionTriggered(ButtonAction.ACTION_SHOOTUP, 0) or Input.IsActionTriggered(ButtonAction.ACTION_SHOOTUP, 1) then
|
||||
EID.bagOfCraftingOffset = math.max(0, EID.bagOfCraftingOffset - EID.Config["BagOfCraftingResults"])
|
||||
end
|
||||
Isaac.GetPlayer(0).ControlsEnabled = false
|
||||
else
|
||||
Isaac.GetPlayer(0).ControlsEnabled = true
|
||||
end
|
||||
|
||||
local resultCount = 0
|
||||
local skips = 0
|
||||
for quality = 4, 0, -1 do -- sort by result quality
|
||||
for i, v in ipairs(results) do
|
||||
if EID.itemWeightsLookup[v[2]]== quality then
|
||||
customDescObj.Description = customDescObj.Description.."# {{Collectible"..v[2].."}} ="
|
||||
customDescObj.Description = customDescObj.Description..EID:tableToCraftingIconsMerged(v[1])
|
||||
resultCount = resultCount + 1
|
||||
if resultCount > EID.Config["BagOfCraftingResults"]-1 then
|
||||
if #results > EID.Config["BagOfCraftingResults"] then
|
||||
customDescObj.Description = customDescObj.Description.."#{{Blank}} ...+"..(#results-EID.Config["BagOfCraftingResults"]).." more"
|
||||
if skips < EID.bagOfCraftingOffset then
|
||||
skips = skips + 1
|
||||
if skips == EID.bagOfCraftingOffset then
|
||||
customDescObj.Description = customDescObj.Description.."#{{Blank}} ...+"..skips.." more"
|
||||
end
|
||||
else
|
||||
customDescObj.Description = customDescObj.Description.."# {{Collectible"..v[2].."}} ="
|
||||
customDescObj.Description = customDescObj.Description..EID:tableToCraftingIconsMerged(v[1])
|
||||
resultCount = resultCount + 1
|
||||
if resultCount > EID.Config["BagOfCraftingResults"]-1 then
|
||||
if #results > EID.Config["BagOfCraftingResults"] then
|
||||
customDescObj.Description = customDescObj.Description.."#{{Blank}} ...+"..(#results-EID.Config["BagOfCraftingResults"]- skips).." more"
|
||||
end
|
||||
break
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -440,10 +463,12 @@ local function onRender(t)
|
||||
else
|
||||
EID:removeTextPosModifier("Tained HUD")
|
||||
end
|
||||
if player.SubType == 23 then
|
||||
local success = handleBagOfCraftingRendering()
|
||||
if success then
|
||||
return
|
||||
if player:HasCollectible(710) and EID.Config["DisplayBagOfCrafting"] ~= "never" then
|
||||
if EID.Config["DisplayBagOfCrafting"] == "always" or (EID.Config["DisplayBagOfCrafting"] == "hold" and string.find(player:GetSprite():GetAnimation(), "PickupWalk")) then
|
||||
local success = handleBagOfCraftingRendering()
|
||||
if success then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+26
-2
@@ -450,6 +450,30 @@ if MCMLoaded then
|
||||
}
|
||||
)
|
||||
|
||||
MCM.AddSpace("EID", "Display")
|
||||
MCM.AddText("EID", "Display", "Bag of Crafting")
|
||||
|
||||
-- Bag of Crafting Display
|
||||
local bagDisplays = {"always","hold","never"}
|
||||
MCM.AddSetting(
|
||||
"EID",
|
||||
"Display",
|
||||
{
|
||||
Type = ModConfigMenu.OptionType.NUMBER,
|
||||
CurrentSetting = function()
|
||||
return AnIndexOf(bagDisplays, EID.Config["DisplayBagOfCrafting"])
|
||||
end,
|
||||
Minimum = 1,
|
||||
Maximum = 3,
|
||||
Display = function()
|
||||
return "Display mode: " .. EID.Config["DisplayBagOfCrafting"]
|
||||
end,
|
||||
OnChange = function(currentNum)
|
||||
EID.Config["DisplayBagOfCrafting"] = bagDisplays[currentNum]
|
||||
end,
|
||||
Info = {"always = Always show Results, hold = Show when holding up bag, never = Never show results"}
|
||||
}
|
||||
)
|
||||
-- Bag of Crafting results
|
||||
MCM.AddSetting(
|
||||
"EID",
|
||||
@@ -460,8 +484,8 @@ if MCMLoaded then
|
||||
return AnIndexOf(diceSteps, EID.Config["BagOfCraftingResults"]) - 1
|
||||
end,
|
||||
Display = function()
|
||||
return "Crafting bag: $scroll" ..
|
||||
AnIndexOf(diceSteps, EID.Config["BagOfCraftingResults"]) - 1 .. " " .. EID.Config["BagOfCraftingResults"] .. " Results"
|
||||
return "Displayed Results: $scroll" ..
|
||||
AnIndexOf(diceSteps, EID.Config["BagOfCraftingResults"]) - 1 .. " " .. EID.Config["BagOfCraftingResults"]
|
||||
end,
|
||||
OnChange = function(currentNum)
|
||||
EID.Config["BagOfCraftingResults"] = diceSteps[currentNum%#diceSteps + 1]
|
||||
|
||||
Reference in new issue
Block a user