Skip to content

Commit

Permalink
feat: Various improvements
Browse files Browse the repository at this point in the history
/tsc toonA toonB routine now ignores artisan items if toonA is artisan
/tsc toonA depot now respects ignore.lua file
Main routine: recipients now do bank routine even if they didn't give
  • Loading branch information
rawmotion1 committed Jun 5, 2023
1 parent 2d6817c commit 8fcb538
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
4 changes: 3 additions & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
--- @type Mq
local mq = require('mq')

local version = '0.4.8'
local version = '0.4.9'
local me = mq.TLO.Me.Name()

local settingPath = 'Consolidate/settings.lua'
Expand Down Expand Up @@ -193,6 +193,7 @@ local function defineMatches()
if myItem == otherItem then
if not matches[myToon.name] then matches[myToon.name] = {} end
if myProp.totalQty < otherProp.totalQty then
if not matches[otherToon.name] then matches[otherToon.name] = {} end
if not matches[myToon.name][myItem] then
matches[myToon.name][myItem] = {}
matches[myToon.name][myItem].receiver = otherToon.name
Expand All @@ -210,6 +211,7 @@ local function defineMatches()
if tiebreaker == 'Toonone' then
tiebreaker = toons[1].name
end
if not matches[tiebreaker] then matches[tiebreaker] = {} end
matches[myToon.name][myItem].receiver = tiebreaker
matches[myToon.name][myItem].receiverCount = 0
print('\at[TsC]\ag [Tie] \ar'..myToon.name..'\'s \ag'..myProp.totalQty..' \ay'..myItem..' \aowill go to \ar'..tiebreaker..' \aobecause there was a tie.')
Expand Down
35 changes: 35 additions & 0 deletions toongive.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,28 @@ local mq = require('mq')
local utils = require('utils')
local ignorePath = 'Consolidate/ignore.lua'
local givePath = 'Consolidate/tmp/give.lua'
local artisanPath = 'Consolidate/artisan.lua'
local settingPath = 'Consolidate/settings.lua'
local me = mq.TLO.Me.Name()
local pIgnorePath = 'Consolidate/ignore_'..me..'.lua'
local give = {}
local ignore = {}
local items = {}
items[me] = {}
local artList = {}
local isArtisan = false
local settings = {}


local function loadfiles()
local loadSets, setError = loadfile(mq.configDir..'/'..settingPath)
if setError then
settings.tiebreaker = 'Toonone'
settings.artisan = 'nobody'
mq.pickle(settingPath, settings)
elseif loadSets then
settings = loadSets()
end
local mygive, giveerror = loadfile(mq.configDir..'/'..givePath)
if giveerror then
print('\at[TsC]\ao Error loading give.lua')
Expand All @@ -32,11 +45,33 @@ local function loadfiles()
elseif pignoreList then
ignore = pignoreList()
end
if me == settings.artisan then
local loadArt, artError = loadfile(mq.configDir..'/'..artisanPath)
if artError then
elseif loadArt then
artList = loadArt()
isArtisan = true
end
end
end
loadfiles()

print('\at[TsC]\ao Scanning items...')

if isArtisan == true then --Combine ignore and artisan lists
local tempTable = {}
local n = 0
for _,v in pairs(ignore) do
n = n + 1
tempTable[n] = v
end
for _,v in pairs(artList) do
n = n + 1
tempTable[n] = v
end
ignore = tempTable
end

--Scan this toon's inventory
local scope
if give['scope'] == 'all' then
Expand Down
18 changes: 15 additions & 3 deletions toonstore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
local mq = require('mq')
local utils = require('utils')
local itemsPath = 'Consolidate/tmp/allitems.lua'
local ignorePath = 'Consolidate/ignore.lua'
local me = mq.TLO.Me.Name()
local items = {}
local ignore = {}
Expand All @@ -14,17 +15,28 @@ local function loadfiles()
elseif allitems then
items = allitems()
end
local ignoreList, ignoreerror = loadfile(mq.configDir..'/'..ignorePath)
if ignoreerror then
print('\at[TsC]\ao Error loading ignore.lua')
mq.exit()
elseif ignoreList then
ignore = ignoreList()
end
end
loadfiles()

print('\at[TsC]\ao Moving all inventory items to depot...')

utils.scan(me, 4, ignore, items)

local list = {}


local stuffToBank = false
for k,_ in pairs(items[me]) do
table.insert(list, k)
stuffToBank = true
end

utils.depot(list)
if stuffToBank == true then
utils.depot(list)
end

0 comments on commit 8fcb538

Please sign in to comment.