Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function kaiUI.sortGMCPItems()
- local items = table.deepcopy(kaiUI.gmcp.infoHere)
- local mobs = {}
- local attribs = {}
- kaiUI.itemsByType = {}
- for k, v in pairs(items) do
- if not v.attrib then
- items[k].attrib = "none"
- end
- if not kaiUI.itemsByType[v.attrib] then
- kaiUI.itemsByType[v.attrib] = {}
- if not attribs[v.attrib] then
- table.insert(attribs, v.attrib)
- end
- end
- table.insert(kaiUI.itemsByType[v.attrib], v)
- end
- items = {}
- for _, v in ipairs(attribs) do
- for k, v in pairs(kaiUI.itemsByType[v]) do
- if v.attrib ~= "mdt" then
- if (v.attrib:match("%w?m%w?")) then
- table.insert(mobs, v)
- else
- table.insert(items, v)
- end
- end
- end
- end
- kaiUI.gmcp.mobs = table.deepcopy(mobs)
- kaiUI.gmcp.items = table.deepcopy(items)
- end
- function kaiUI.updateInfoHere()
- local echoString = "<LightYellow>["
- local color = ""
- local divColor = "<" .. kaiUI.CSS.base:get("border-color") .. ">"
- local divColor2 = kaiUI.infoHereColors.none
- local divString = ""
- local capString = divColor .. "------------------------------------------"
- local targetsHere = 0
- kaiUI.sortGMCPItems()
- kaiUI.mobsInRoom = {}
- kaiUI.denizenListConsole:clear()
- if table.size(kaiUI.gmcp.infoHere) == 0 then
- kaiUI.denizenListConsole:cecho("\n" .. capString)
- kaiUI.denizenListConsole:cecho("\n<LightYellow> Nothing here.")
- kaiUI.denizenListConsole:cecho("\n" .. capString)
- return
- else
- if table.size(kaiUI.gmcp.items) ~= 0 then
- divString =
- divColor ..
- "--" ..
- divColor2 ..
- " Objects " ..
- divColor ..
- "----------------------------------"
- kaiUI.denizenListConsole:cecho("\n" .. divString)
- for k, v in pairs(kaiUI.gmcp.items) do
- color = kaiUI.infoHereColors[v.attrib]
- if not color then
- color = kaiUI.infoHereColors["none"]
- end
- -- futureproofing
- echoString =
- string.rep(" ", 6 - #v.id) ..
- echoString ..
- color ..
- v.id ..
- "<LightYellow>] " ..
- color ..
- v.name
- if v.attrib ~= "mdt" then
- kaiUI.denizenListConsole:cecho("\n" .. echoString)
- end
- echoString = "<LightYellow>["
- end
- end
- if table.size(kaiUI.gmcp.mobs) ~= 0 then
- divString =
- divColor ..
- "--" ..
- divColor2 ..
- " Mobs " ..
- divColor ..
- "----------------------------------"
- kaiUI.denizenListConsole:cecho("\n" .. divString)
- for k, v in pairs(kaiUI.gmcp.mobs) do
- color = kaiUI.infoHereColors[v.attrib] or kaiUI.infoHereColors["m"]
- if v.attrib:match("%w?m%w?") and v.name:upper():find(kaiUI.targetName:upper()) then
- color = "<OrangeRed>"
- targetsHere = targetsHere + 1
- end
- kaiUI.mobsInRoom[v.id] = v.name
- echoString =
- string.rep(" ", 6 - #v.id) ..
- echoString ..
- color ..
- v.id ..
- "<LightYellow>] " ..
- color ..
- v.name
- if v.attrib ~= "mdt" then
- kaiUI.denizenListConsole:cecho("\n" .. echoString)
- end
- echoString = "<LightYellow>["
- end
- end
- kaiUI.denizenListConsole:cecho("\n" .. capString)
- end
- kaiUI.mobCounterLabel:echo(
- [[
- <p style="font-size:12px;"><font color="DarkSlateBlue"><b>|[<font color="LightYellow">Mobs: <font color="chartreuse">]] ..
- table.size(kaiUI.gmcp.mobs) ..
- [[<font color="DarkSlateBlue">]|[<font color="LightYellow">Targets: <font color="OrangeRed">]] ..
- targetsHere ..
- [[<font color="DarkSlateBlue">]|
- ]]
- )
- kaiUI.denizenListConsole:hide()
- kaiUI.denizenListConsole:show()
- end
- function kaiUI.onItemsList()
- if gmcp.Char.Items.List.location ~= "room" then
- return
- else
- kaiUI.gmcp.infoHere = table.deepcopy(gmcp.Char.Items.List.items)
- end
- kaiUI.updateInfoHere()
- end
- function kaiUI.onItemsAdd()
- if gmcp.Char.Items.Add.location ~= "room" or gmcp.Char.Items.Add.item.attrib == "mdt" then
- return
- else
- table.insert(kaiUI.gmcp.infoHere, gmcp.Char.Items.Add.item)
- if gmcp.Char.Items.Add.item.attrib == "m" or gmcp.Char.Items.Add.item.attrib == "mh" then
- kaiUI.mobsInRoom[gmcp.Char.Items.Add.item.id] = gmcp.Char.Items.Add.item.name
- end
- end
- if kaiUI.addItemTimer then
- killTimer(kaiUI.addItemTimer)
- end
- kaiUI.addItemTimer =
- tempTimer(
- 0.25,
- function()
- kaiUI.updateInfoHere()
- end
- )
- end
- function kaiUI.onItemsRemove()
- if gmcp.Char.Items.Remove.location ~= "room" then
- return
- else
- for k, v in pairs(kaiUI.mobsInRoom) do
- if k == gmcp.Char.Items.Remove.item.id then
- kaiUI.mobsInRoom[gmcp.Char.Items.Remove.item.id] = nil
- end
- end
- for k, v in pairs(kaiUI.gmcp.infoHere) do
- if gmcp.Char.Items.Remove.item.id == v.id or kaiUI.gmcp.infoHere[k].attrib == "mdt" then
- kaiUI.gmcp.infoHere[k] = nil
- end
- end
- end
- kaiUI.updateInfoHere()
- end
- registerAnonymousEventHandler("gmcp.Char.Items.Add", "kaiUI.onItemsAdd")
- registerAnonymousEventHandler("gmcp.Char.Items.Remove", "kaiUI.onItemsRemove")
- registerAnonymousEventHandler("gmcp.Char.Items.List", "kaiUI.onItemsList")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement