Skip to content

Commit 4cbe21d

Browse files
committed
check remnants before buying
prevents infinite loop if user does not have enough remnants to buy the desired augments. Note: Need to add same check for plat for solvents.
1 parent c7c9c10 commit 4cbe21d

1 file changed

Lines changed: 42 additions & 1 deletion

File tree

lib/module.lua

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@ function M.countAugNeeded(tableName,isArmor)
226226

227227
end
228228

229+
tableName.currentAugTotalCost = M.computeAugCost(tableName,tableName.currentAugmentNumNeeded)
230+
229231
M.printDebug(string.format('DEBUG countAugNeeded: current num aug needed: ' .. tableName.currentAugmentNumNeeded),debugFlag)
232+
M.printDebug(string.format('DEBUG countAugNeeded: current aug total cost: ' .. tableName.currentAugTotalCost),debugFlag)
230233

231234
return tableName -- return the object
232235
end -- countAugNeeded
@@ -240,6 +243,7 @@ end -- countAugNeeded
240243

241244
-- This function is used to set appropriate flags so that buying actions are initiated
242245
function M.initiateBuyItem(tableName,buyTargetName)
246+
local conditionCheckFlag = false
243247
if buyTargetName == 'solvent' then
244248
if tableName.currentSolvNumNeeded > 0 then
245249
print('initiateBuyItem: Need to purchase solvents')
@@ -250,7 +254,15 @@ function M.initiateBuyItem(tableName,buyTargetName)
250254
end
251255

252256
elseif buyTargetName == 'aug' then
253-
if tableName.currentAugmentNumNeeded > 0 then
257+
258+
if tableName.currentAugTotalCost > mq.TLO.Me.AltCurrency('Remnants of Tranquility')() then
259+
print('DEBUG: Not enough Remnants to purchase the necessary augments')
260+
conditionCheckFlag = false
261+
else
262+
conditionCheckFlag = true
263+
end
264+
265+
if tableName.currentAugmentNumNeeded > 0 and conditionCheckFlag then
254266
print('initiateBuyItem: Need to purchase Aug')
255267
tableName.doBuyAugFlag = true
256268
else
@@ -649,6 +661,32 @@ function M.sellOldAug(tableName)
649661
end
650662

651663

664+
function M.computeAugCost(tableName,numAugToBuy)
665+
local level = tableName.augPrefixIndex
666+
local count = numAugToBuy
667+
local cost = 0
668+
print('DEBUG: computeAugCost: level ' .. level)
669+
if level == 1 then
670+
cost = count * 50
671+
elseif level == 2 then
672+
cost = count * 90
673+
elseif level == 3 then
674+
cost = count * 190
675+
elseif level == 4 then
676+
cost = count * 380
677+
elseif level == 5 then
678+
cost = count * 630
679+
elseif level == 6 then
680+
cost = count * 940
681+
elseif level == 7 then
682+
cost = count * 1250
683+
end
684+
print('DEBUG: computeAugCost: cost ' .. cost)
685+
686+
return cost
687+
688+
689+
end
652690

653691

654692

@@ -1095,6 +1133,9 @@ function M.comboWrapper(idVal,tableName,typeId,isArmor,equipType )
10951133
tableName.currentAugName = M.genAugNames(tableName,isArmor) -- FUTURE: set the table.desiredNameType9 and 5 and 6 and...
10961134

10971135
M.countAugNeeded(tableName,isArmor) -- set flagForRemovalType<>
1136+
if tableName.currentAugTotalCost > mq.TLO.Me.AltCurrency('Remnants of Tranquility')() then
1137+
print('DEBUG: Not enough Remnants to purchase the necessary augments')
1138+
end
10981139
end
10991140
imgui.SameLine()
11001141
if imgui.Button('Run the script##' .. typeId .. 'A') then

0 commit comments

Comments
 (0)