Added detection of bag of crafting content shifts
This commit is contained in:
1 parent
1bd04bc72f
commit
9e837ac368
3 files changed
+29
-5
No files matched your search
@@ -650,6 +650,7 @@ EID.descriptions["en_us"].horsepills={
|
|||||||
[9999] = {"", "Golden Pill", "Random horse pill effect#Destroys itself after a few uses"}, -- golden Pill
|
[9999] = {"", "Golden Pill", "Random horse pill effect#Destroys itself after a few uses"}, -- golden Pill
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EID.descriptions["en_us"].CraftingBagContent = "Pickups in bag:"
|
||||||
EID.descriptions["en_us"].CraftingRoomContent = "Pickups in room:"
|
EID.descriptions["en_us"].CraftingRoomContent = "Pickups in room:"
|
||||||
EID.descriptions["en_us"].CraftingResults = "Results:#(Scroll: Hold TAB + Shoot △/▽)"
|
EID.descriptions["en_us"].CraftingResults = "Results:#(Scroll: Hold TAB + Shoot △/▽)"
|
||||||
|
|
||||||
+6
-4
@@ -726,9 +726,10 @@ end
|
|||||||
-- Example input: {1,2,3,4,5,6,7,8}
|
-- Example input: {1,2,3,4,5,6,7,8}
|
||||||
-- Result: "{{Crafting8}}{{Crafting7}}{{Crafting6}}{{Crafting5}}{{Crafting4}}{{Crafting3}}{{Crafting2}}{{Crafting1}}"
|
-- Result: "{{Crafting8}}{{Crafting7}}{{Crafting6}}{{Crafting5}}{{Crafting4}}{{Crafting3}}{{Crafting2}}{{Crafting1}}"
|
||||||
function EID:tableToCraftingIconsFull(craftTable)
|
function EID:tableToCraftingIconsFull(craftTable)
|
||||||
table.sort(craftTable, function(a, b) return a > b end)
|
local sortedList = {table.unpack(craftTable)}
|
||||||
|
table.sort(sortedList, function(a, b) return a > b end)
|
||||||
local iconString = ""
|
local iconString = ""
|
||||||
for _,nr in ipairs(craftTable) do
|
for _,nr in ipairs(sortedList) do
|
||||||
iconString = iconString.."{{Crafting"..nr.."}}"
|
iconString = iconString.."{{Crafting"..nr.."}}"
|
||||||
end
|
end
|
||||||
return iconString
|
return iconString
|
||||||
@@ -738,9 +739,10 @@ end
|
|||||||
-- Example input: {1,1,1,2,2,3,3,3}
|
-- Example input: {1,1,1,2,2,3,3,3}
|
||||||
-- Result: "3{{Crafting3}}2{{Crafting2}}3{{Crafting1}}"
|
-- Result: "3{{Crafting3}}2{{Crafting2}}3{{Crafting1}}"
|
||||||
function EID:tableToCraftingIconsMerged(craftTable)
|
function EID:tableToCraftingIconsMerged(craftTable)
|
||||||
table.sort(craftTable, function(a, b) return a > b end)
|
local sortedList = {table.unpack(craftTable)}
|
||||||
|
table.sort(sortedList, function(a, b) return a > b end)
|
||||||
local filteredList = {}
|
local filteredList = {}
|
||||||
for _,nr in ipairs(craftTable) do
|
for _,nr in ipairs(sortedList) do
|
||||||
if filteredList[nr] == nil then
|
if filteredList[nr] == nil then
|
||||||
filteredList[nr] = 1
|
filteredList[nr] = 1
|
||||||
else
|
else
|
||||||
|
|||||||
+22
-1
@@ -435,6 +435,9 @@ EID:AddCallback(ModCallbacks.MC_POST_ENTITY_REMOVE, function(_, bag)
|
|||||||
local craftingIDs = EID:getBagOfCraftingID(e.Variant, e.SubType)
|
local craftingIDs = EID:getBagOfCraftingID(e.Variant, e.SubType)
|
||||||
if craftingIDs ~= nil then
|
if craftingIDs ~= nil then
|
||||||
for _,v in ipairs(craftingIDs) do
|
for _,v in ipairs(craftingIDs) do
|
||||||
|
if #EID.BagItems >= 8 then
|
||||||
|
table.remove(EID.BagItems, 1)
|
||||||
|
end
|
||||||
table.insert(EID.BagItems, v)
|
table.insert(EID.BagItems, v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -455,6 +458,21 @@ local function trackBagHolding()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function shiftBagContent()
|
||||||
|
local newContent = {}
|
||||||
|
for i=2,#EID.BagItems do
|
||||||
|
table.insert(newContent, EID.BagItems[i])
|
||||||
|
end
|
||||||
|
table.insert(newContent, EID.BagItems[1])
|
||||||
|
EID.BagItems = newContent
|
||||||
|
end
|
||||||
|
|
||||||
|
local function detectBagContentShift()
|
||||||
|
if Input.IsActionTriggered(ButtonAction.ACTION_DROP, 0) or Input.IsActionTriggered(ButtonAction.ACTION_DROP, 1) then
|
||||||
|
shiftBagContent()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-----------------------------
|
-----------------------------
|
||||||
-----------------------------
|
-----------------------------
|
||||||
-----------RENDERING---------
|
-----------RENDERING---------
|
||||||
@@ -471,6 +489,7 @@ EID.BagItems = {}
|
|||||||
|
|
||||||
function EID:handleBagOfCraftingRendering()
|
function EID:handleBagOfCraftingRendering()
|
||||||
trackBagHolding()
|
trackBagHolding()
|
||||||
|
detectBagContentShift()
|
||||||
local results = {}
|
local results = {}
|
||||||
local floorItems = {}
|
local floorItems = {}
|
||||||
local pickups = Isaac.FindByType(5, -1, -1, true, false)
|
local pickups = Isaac.FindByType(5, -1, -1, true, false)
|
||||||
@@ -501,6 +520,7 @@ function EID:handleBagOfCraftingRendering()
|
|||||||
if #itemQuery < 8 then
|
if #itemQuery < 8 then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
table.sort(itemQuery, function(a, b) return a > b end)
|
||||||
|
|
||||||
local queryString = table.concat(itemQuery,",")
|
local queryString = table.concat(itemQuery,",")
|
||||||
if randResultCache[queryString] == nil then
|
if randResultCache[queryString] == nil then
|
||||||
@@ -537,8 +557,9 @@ function EID:handleBagOfCraftingRendering()
|
|||||||
|
|
||||||
local customDescObj = EID:getDescriptionObj(5, 100, 710)
|
local customDescObj = EID:getDescriptionObj(5, 100, 710)
|
||||||
local roomDesc = EID.descriptions[EID.Config["Language"]].CraftingRoomContent or EID.descriptions["en_us"].CraftingRoomContent
|
local roomDesc = EID.descriptions[EID.Config["Language"]].CraftingRoomContent or EID.descriptions["en_us"].CraftingRoomContent
|
||||||
|
local bagContentDesc = EID.descriptions[EID.Config["Language"]].CraftingBagContent or EID.descriptions["en_us"].CraftingBagContent
|
||||||
local resultDesc = EID.descriptions[EID.Config["Language"]].CraftingResults or EID.descriptions["en_us"].CraftingResults
|
local resultDesc = EID.descriptions[EID.Config["Language"]].CraftingResults or EID.descriptions["en_us"].CraftingResults
|
||||||
customDescObj.Description = "Items in Bag:#"..EID:tableToCraftingIconsMerged(EID.BagItems).."#"
|
customDescObj.Description = bagContentDesc.."#"..EID:tableToCraftingIconsMerged(EID.BagItems).."#"
|
||||||
customDescObj.Description = customDescObj.Description ..roomDesc.."#"..EID:tableToCraftingIconsMerged(floorItems).."#"..resultDesc
|
customDescObj.Description = customDescObj.Description ..roomDesc.."#"..EID:tableToCraftingIconsMerged(floorItems).."#"..resultDesc
|
||||||
|
|
||||||
if Input.IsActionPressed(ButtonAction.ACTION_MAP, 0) or Input.IsActionPressed(ButtonAction.ACTION_MAP, 1) then
|
if Input.IsActionPressed(ButtonAction.ACTION_MAP, 0) or Input.IsActionPressed(ButtonAction.ACTION_MAP, 1) then
|
||||||
|
|||||||
Reference in new issue
Block a user