Skip to content

Commit

Permalink
Merge pull request #22 from endavis/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
endavis authored Nov 10, 2017
2 parents fa933e1 + 02a6e6e commit b336bf6
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 41 deletions.
5 changes: 5 additions & 0 deletions Bast/BastmushChanges.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Bastmush Changes List

r2100 snapshot
- eqDB.xml
- fix bug when getting multiple containers before the first
was finished

r2099 snapshot
- eqDB.xml
- don't pre-enable eq tag triggers
Expand Down
35 changes: 18 additions & 17 deletions Bast/broadcast_gq.xml
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ enemy = ""
charname = ""
function gqnew()
phelper:mdebug('creating new gq')
gq_info = {}
gq_info['mobs'] = {}
gq_info['trains'] = 0
Expand All @@ -404,14 +405,14 @@ function gqnew()
end
function gqdeclared (name, line, wildcards)
--print('gqdeclared')
phelper:mdebug('gqdeclared')
gqsdeclared[verify_number(wildcards.gqnum)] = true
checkgqavailable()
raisegq(1)
end
function gqjoin (name, line, wildcards)
--print('gqjoin')
phelper:mdebug('gqjoin')
gqnew()
phelper:set('joined', wildcards.gqnum, {silent=true})
mobsleft = {}
Expand All @@ -427,7 +428,7 @@ function gqjoin (name, line, wildcards)
end
function gqstarted (name, line, wildcards)
--print('gqstart')
phelper:mdebug('gqstarted')
if not (gqsstarted[verify_number(wildcards.gqnum)]) then
gqsstarted[verify_number(wildcards.gqnum)] = true
Expand All @@ -442,7 +443,7 @@ function gqstarted (name, line, wildcards)
end
function gqcancelled(name, line, wildcards)
--print('gqcancelled')
phelper:mdebug('gqcancelled')
if verify_number(wildcards.gqnum) == phelper.joined then
raisegq(6)
if gq_info['qpmobs'] > 0 then
Expand All @@ -463,7 +464,7 @@ function gqcancelled(name, line, wildcards)
end
function gqitem(name, line, wildcards)
--print('gqitem')
phelper:mdebug('gqitem')
name = wildcards.name
location = wildcards.location
num = trim(wildcards.num)
Expand All @@ -476,13 +477,13 @@ function gqitem(name, line, wildcards)
end -- campaign_item
function notstarted(name, line, wildcards)
--print('notstarted')
phelper:mdebug('notstarted')
phelper:enabletriggroup("gqcheck", false)
phelper:enabletriggroup("gqin", false)
end
function gqwins(name, line, wildcards)
--print('gqwins')
phelper:mdebug('gqwins')
if not next(gq_info['mobs']) then
gq_info['mobs'] = copytable.deep(mobsleft)
SaveState()
Expand All @@ -492,7 +493,7 @@ function gqwins(name, line, wildcards)
end
function gqmobdead (name, line, wildcards)
--print('mobdead')
phelper:mdebug('gqmobdead')
local tenemy = enemy
local found = false
if not phelper.maxkills then
Expand All @@ -518,41 +519,41 @@ function gqmobdead (name, line, wildcards)
end
function gqmaxkills(name, line, wildcards)
--print('gqmaxkills')
phelper:mdebug('gqmaxkills')
phelper:set('maxkills', true, {silent=true})
end
function gqwon(name, line, wildcards)
--print('gqwon')
phelper:mdebug('gqwon')
gq_info['won'] = 1
gq_info['finishtime'] = GetInfo(304)
phelper:enabletriggroup("gqrew", true)
end
function gqwonannounce(name, line, wildcards)
--print('gqwonannounce')
phelper:mdebug('gqwonannounce')
if charname == wildcards.winner then
raisegq(4, 'gq_info', gq_info)
gqreset(phelper.joined)
end
end
function gqreward (name, line, wildcards)
--print('gqreward')
phelper:mdebug('gqreward')
local type = wildcards.type
local amount = verify_number(wildcards.amount)
gq_info[rewardtable[type]] = amount
gq_info['won'] = 1
end
function gqcheck( name, line, wildcards)
--print('gqcheck')
phelper:mdebug('gqcheck')
mobsleft = {}
phelper:enabletriggroup("gqcheck", true)
end -- gq_check
function gqquit(name, line, wildcards)
--print('gqquit')
phelper:mdebug('gqquit')
if gq_info['qpmobs'] > 0 then
gq_info['finishtime'] = GetInfo(304)
raisegq(4, 'gq_info', gq_info)
Expand All @@ -562,7 +563,7 @@ function gqquit(name, line, wildcards)
end
function gqextfin(name, line, wildcards)
--print('gqextfin')
phelper:mdebug('gqextfin')
if gq_info['qpmobs'] > 0 then
gq_info['completed'] = 1
gq_info['finishtime'] = GetInfo(304)
Expand All @@ -572,7 +573,7 @@ function gqextfin(name, line, wildcards)
end
function gqnote(name, line, wildcards)
--print('gqnote')
phelper:mdebug('gqnote')
if verify_number(wildcards.gqnum) == phelper.joined then
raisegq(6)
if gq_info['qpmobs'] > 0 then
Expand Down Expand Up @@ -601,7 +602,7 @@ function raisegq(number, dataname, data)
end
function gqreset(gqnum)
--print('gqreset')
phelper:mdebug('gqreset')
gqnum = verify_number(gqnum)
Expand Down
53 changes: 32 additions & 21 deletions Bast/eqDB.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ then type "eqdb refresh"
regexp="y"
send_to="12"
>
<send>
EnableTrigger("start_eqdata", false)
</send>
</trigger>

<trigger
Expand Down Expand Up @@ -135,9 +132,6 @@ then type "eqdb refresh"
regexp="y"
send_to="12"
>
<send>
EnableTrigger("start_invdata", false)
</send>
</trigger>

<trigger
Expand Down Expand Up @@ -261,7 +255,8 @@ db = EQdb:new{}
eqdata = {}
invdata = {}
waiting = {}
need = {}
currentcontainer = nil
identdata = {}
lastidentkey = ''
container = ""
Expand Down Expand Up @@ -335,9 +330,6 @@ function checkvaliditem(item)
end
function getdata(type)
if waiting[type] then
return
end
if type == 'Inventory' then
EnableTrigger("start_invdata")
sendcmd('invdata')
Expand All @@ -348,7 +340,19 @@ function getdata(type)
EnableTrigger("start_invdata")
sendcmd('invdata ' .. tostring(type))
end
waiting[type] = true
currentcontainer = type
end
function addcontainer(container)
need[container] = 'yes'
nextitem()
end
function nextitem()
itemkey, itemvalue = tableRandomItem(need)
if currentcontainer == nil and itemkey ~= nil then
getdata(itemkey)
end
end
function addmod(ltype, mod)
Expand Down Expand Up @@ -491,7 +495,9 @@ function eqdata_redirect (name, line, wildcards, styles)
db:additems(eqdata)
--db:addcontainer('worn', eqdata)
event_container_change('Worn')
waiting['Worn'] = nil
currentcontainer = nil
need['Worn'] = nil
nextitem()
return
end -- if
Expand All @@ -507,7 +513,7 @@ function eqdata_redirect (name, line, wildcards, styles)
eqdata[titem.serial] = titem
else
ColourNote("red", "", "Got a bad item, rerequesting inventory data for " .. container)
DoAfterSpecial(1, 'getdata("' .. container .. '")', 12)
DoAfterSpecial(1, 'addcontainer("' .. container .. '")', 12)
end
end
Expand All @@ -530,7 +536,12 @@ function invdata_redirect (name, line, wildcards, styles)
db:clearcontainer(container)
db:additems(invdata)
--db:addcontainer(container, invdata)
waiting[container] = nil
need[container] = nil
currentcontainer = nil
nextitem()
if tableCountItems(need) == 0 then
EnableTrigger("start_invdata", false)
end
event_container_change(container)
if initdb then
initdb = false
Expand All @@ -551,7 +562,7 @@ function invdata_redirect (name, line, wildcards, styles)
invdata[titem.serial] = titem
else
ColourNote("red", "", "Got a bad item, rerequesting inventory data for " .. container)
DoAfterSpecial(1, 'getdata("' .. container .. '")', 12)
DoAfterSpecial(1, 'addcontainer("' .. container .. '")', 12)
end
end
Expand Down Expand Up @@ -673,9 +684,9 @@ function emptyline()
phelper:enabletriggroup("emptyline", false)
--print('removingall =', removingall)
--print('wearingall =', wearingall)
getdata('Inventory')
addcontainer('Inventory')
if removingall or wearingall then
getdata('Worn')
addcontainer('Worn')
showoutput('setting removingall and wearingall to false')
removingall = false
wearingall = false
Expand All @@ -684,7 +695,7 @@ function emptyline()
if gettingall or puttingall then
if allcontainer ~= -1 then
db:clearcontainer(allcontainer)
getdata(allcontainer)
addcontainer(allcontainer)
showoutput('setting gettingall and puttingall = false')
gettingall = false
puttingall = false
Expand All @@ -695,16 +706,16 @@ end
function initinv(char)
if char.status and char.status.state and tonumber(char.status.state) == 3 and db:getlastrowid('items') <= 0 then
getdata('Worn')
getdata('Inventory')
addcontainer('Worn')
addcontainer('Inventory')
initdb = true
end
end
function getcontainers()
for i,v in pairs(invdata) do
if tonumber(v.type) == 11 then
getdata(v.serial)
addcontainer(v.serial)
end
end
end
Expand Down
1 change: 1 addition & 0 deletions Bast/lua/phelpobject.lua
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ function Phelpobject:enabletriggroup(group, flag)
end
print("")
end
self:mdebug('enabletriggroup ' .. group .. " - " .. tostring(flag))
end

function Phelpobject:cmd_update(cmd, key, value)
Expand Down
15 changes: 12 additions & 3 deletions Bast/lua/tablefuncs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function tableSort(ttable, sortkey, default, reverse)
end
end
if akey == nil or bkey == nil then
if akey == nil then
if akey == nil then
print('BUG: akey: ', sortkey, ' - is nil for item', a)
elseif bkey == nil then
print('BUG: bkey: ', sortkey, ' - is nil for item', b)
Expand Down Expand Up @@ -128,7 +128,7 @@ function tableCountItems(ttable)
if count == 0 then
for i,v in ipairs(ttable) do
count = count + 1
end
end
end
return count
end
Expand All @@ -141,6 +141,15 @@ function tableCountKeys(ttable, key, value, tnot)
elseif not tnot and v[key] == value then
count = count + 1
end
end
end
return count
end

function tableRandomItem(t) --Selects a random item from a table
local keys = {}
for key, value in pairs(t) do
keys[#keys+1] = key --Store keys in another table
end
index = keys[math.random(1, #keys)]
return index, t[index]
end

0 comments on commit b336bf6

Please sign in to comment.