You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
586 lines
25 KiB
586 lines
25 KiB
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!DOCTYPE muclient>
|
|
<!-- Saved on Thursday, December 29, 2016, 11:46 PM -->
|
|
<!-- MuClient version 0.00 -->
|
|
<muclient>
|
|
<plugin
|
|
name="EquipmentManager"
|
|
author="Icecool"
|
|
id="8dc4696d8daf6cd9c88b0125"
|
|
language="Lua"
|
|
purpose="Autowear Equipment on level"
|
|
date_written="2019-01-24 00:00:00"
|
|
save_state="y"
|
|
requires="0.00"
|
|
version="2.10"
|
|
>
|
|
<description trim="y">
|
|
<![CDATA[
|
|
Scripted designed to automatically wear equipment on level. Along with automatic equipment wearing, can manually wear using the 'eqcheck (level)' alias.
|
|
|
|
V1.00 (original)
|
|
* Trigger based level check
|
|
|
|
V1.50 (rewrite)
|
|
* Renamed plugin to be 'EquipmentManager' from 'AutoEquip'
|
|
* OnPluginBroadcast GMCP check for level
|
|
* Plugin uses 'save_state' now as before it was not enabled.
|
|
* Eqadmin & Eqcheck are the two commands.
|
|
* Helpfile automatically displays on enabling the plugin.
|
|
* dnote() was created for debugging messages.
|
|
|
|
v2.00
|
|
* Create table to store the equipment ObjIDs and Levels from the invdata of bag.
|
|
--[[ This should reduce the lag on pulling inventory out of bag and wearing it as we are no longer
|
|
relying on invdata every level ]]--
|
|
* 'EqSync' command to look into Bag and creates/overwrites the table that stores the equipment information
|
|
|
|
v2.10
|
|
* Added 'InvCleanUp' command to check InvData, create a temporary InvList, and put away the manged EQ.
|
|
* Added Portal Inventory (portalsync, portalbag)
|
|
* Added Portal Inventory Clean Up
|
|
|
|
WISH LIST:
|
|
* Performance tweaks
|
|
--[[ Create TemporaryInvData table that InvData is fed into, then parse against InventoryData and PortalInventory or EqInventory tables and create 'CleanUp' table
|
|
This will prevent parsing partial tables each InvData line. ]]--
|
|
|
|
]]>
|
|
</description>
|
|
</plugin>
|
|
<!-- Aliases -->
|
|
<aliases>
|
|
<alias enabled="y" sequence="100" ignore_case="y" regexp="y" keep_evaluating="n"
|
|
match="^\s*(?:eqadmin|eqadmi|eqadm)\s+(?<Args>.+)?$"
|
|
script="COMMAND_EQAdmin"></alias>
|
|
<alias enabled="y" sequence="100" ignore_case="y" regexp="y" keep_evaluating="n"
|
|
match="^\s*(?:eqadmin|eqadmi|eqadm(?<Args>))$"
|
|
script="COMMAND_EQAdmin"></alias>
|
|
<alias enabled="y" sequence="100" ignore_case="y" regexp="y" keep_evaluating="n"
|
|
match="^eqcheck (?<level>\d+)$"
|
|
script="COMMAND_CheckEquipment"></alias>
|
|
</aliases>
|
|
<!-- Triggers -->
|
|
<triggers>
|
|
<!-- Triggers for gagging InvData start -->
|
|
<trigger name="InvDataStart" group="GroupInvDataStart" enabled="n" regexp="y" omit_from_output="y" sequence="100"
|
|
match="^\{invdata(\s\d+)?\}$"></trigger>
|
|
<!-- Triggers for Processing InvData Line -->
|
|
<trigger name="processInvData" group="GroupEqSync" enabled="n" regexp="y" omit_from_output="y" sequence="100" script="TRIGGER_AddInventoryItem"
|
|
match="^(?<objid>\d+),\w+,.*,(?<objlevel>\d+),(?<objtype>\d+),\d+,(?<objwear>.*),.*$" ></trigger>
|
|
<trigger name="InvCleanUpInvData" group="GroupInventoryCleanup" enabled="n" regexp="y" omit_from_output="y" sequence="100" script="TRIGGER_AddInvListItem"
|
|
match="^(?<objid>\d+),\w+,.*,(?<objlevel>\d+),(?<objtype>\d+),\d+,(?<objwear>.*),.*$" ></trigger>
|
|
<trigger name="InvPortalSetupInvData" group="GroupPortalInventorySetup" enabled="n" regexp="y" omit_from_output="y" sequence="100" script="TRIGGER_AddPortalInvItem"
|
|
match="^(?<objid>\d+),\w+,.*,(?<objlevel>\d+),(?<objtype>\d+),\d+,(?<objwear>.*),.*$" ></trigger>
|
|
<trigger name="InvDataPortCleanData" group="GroupPortalCleanUp" enabled="n" regexp="y" omit_from_output="y" sequence="100" script="TRIGGER_AddInvPortalListItem"
|
|
match="^(?<objid>\d+),\w+,.*,(?<objlevel>\d+),(?<objtype>\d+),\d+,(?<objwear>.*),.*$" ></trigger>
|
|
<!-- Triggers for InvData end -->
|
|
<trigger name="InvDataEnd" group="GroupEqSync" enabled="n" regexp="y" omit_from_output="y" sequence="100" script="TRIGGER_EndInvData"
|
|
match="^\{\/invdata\}$"></trigger>
|
|
<trigger name="InvDataInvCleanUpEnd" group="GroupInventoryCleanup" enabled="n" regexp="y" omit_from_output="y" sequence="100" script="TRIGGER_EndInvData"
|
|
match="^\{\/invdata\}$"></trigger>
|
|
<trigger name="InvDataPortalSetupEnd" group="GroupPortalInventorySetup" enabled="n" regexp="y" omit_from_output="y" sequence="100" script="TRIGGER_EndInvData"
|
|
match="^\{\/invdata\}$"></trigger>
|
|
<trigger name="InvDataPortCleanEnd" group="GroupPortalCleanUp" enabled="n" regexp="y" omit_from_output="y" sequence="100" script="TRIGGER_EndInvData"
|
|
match="^\{\/invdata\}$"></trigger>
|
|
</triggers>
|
|
<!-- Get our standard constants -->
|
|
<include name="constants.lua"/>
|
|
<!-- Script -->
|
|
<script> <![CDATA[ --[[ Universal Basic Functions ]]--
|
|
require 'serialize'
|
|
dofile (GetInfo(60) .. "aardwolf_colors.lua")
|
|
GMCPPluginID = "3e7dedbe37e44942dd46d264"
|
|
Prepend = "@GEqCheck: @w"
|
|
-- Function to print colors using Aard Color Scheme
|
|
function cnote(str)
|
|
AnsiNote(stylesToANSI(ColoursToStyles(str)))
|
|
end
|
|
-- Function to check if Debug is active and then print message
|
|
function dnote(str)
|
|
if EqCheck.Debug then
|
|
cnote("@R[DEBUG]: @w"..str.."@w")
|
|
end
|
|
end
|
|
-- Function to return GMCP value
|
|
function checkGMCPValue(key)
|
|
local result, value = CallPlugin(GMCPPluginID,"gmcpval", key)
|
|
if result ~= 0 then
|
|
dnote(("%s: checkGMCPValue for %s did not return any data."):format(Prepend, key))
|
|
return false
|
|
end
|
|
return value
|
|
end
|
|
-- Return true if tonumber() is not nil
|
|
function isNumber(num)
|
|
if tonumber(num) ~= nil then
|
|
return true
|
|
else
|
|
return false
|
|
end
|
|
end
|
|
]]> </script>
|
|
<script> <![CDATA[ --[[ EqCheck functions ]]--
|
|
EqCheck = { Debug=false, Level=0 }
|
|
function EqCheck.IsPlaying()
|
|
if not IsConnected() then return false end
|
|
if not checkGMCPValue("char.status.state") then return false end
|
|
local state = tonumber(checkGMCPValue("char.status.state"))
|
|
if not state then
|
|
return false
|
|
elseif state >= 3 then
|
|
return true
|
|
else
|
|
return false
|
|
end
|
|
end
|
|
function EqCheck.ProcessLevel()
|
|
dnote(("%s EqCheck.ProcessLevel() has been called."):format(Prepend))
|
|
if InventoryManager.CreateTempItemList(EqCheck.Player:EffectiveLevel()) then
|
|
InventoryManager.WearItemList()
|
|
end
|
|
end
|
|
function EqCheck.Remove()
|
|
dnote(("%s EqCheck.Remove() called, removing all dual wear slots now."):format(Prepend))
|
|
SendNoEcho( "remove lear" )
|
|
SendNoEcho( "remove rear" )
|
|
SendNoEcho( "remove neck1" )
|
|
SendNoEcho( "remove neck2" )
|
|
SendNoEcho( "remove lwrist" )
|
|
SendNoEcho( "remove rwrist" )
|
|
SendNoEcho( "remove lfinger" )
|
|
SendNoEcho( "remove rfinger" )
|
|
end
|
|
]]> </script>
|
|
<script> <![CDATA[ --[[ Character Object
|
|
Character Traits include: Name, LastLevel, Level, TierLevel, EffectiveLevel
|
|
]]--
|
|
Character = { }
|
|
Player_MT = { __index = Character }
|
|
function Character.New()
|
|
if not (checkGMCPValue("char.base.name") or checkGMCPValue("char.status.level") or checkGMCPValue("char.status.level")) then
|
|
dnote(("%s: Character.New() failed to create character object. Missing GMCP data was detected."):format(Prepend))
|
|
return nil
|
|
end
|
|
local player = {
|
|
Name = checkGMCPValue("char.base.name"),
|
|
LastLevel = checkGMCPValue("char.status.level"),
|
|
CurrentLevel = checkGMCPValue("char.status.level")
|
|
}
|
|
setmetatable( player, Player_MT )
|
|
dnote(("%s Character.New() returns: %s, %d, %d"):format(Prepend, player.Name, player.LastLevel, player.CurrentLevel))
|
|
return player
|
|
end
|
|
function Character:Level()
|
|
if not checkGMCPValue("char.status.level") then
|
|
dnote(("%s: Character:Level() did not return any GMCP data. Attempting to call the GMCP data."):format(Prepend))
|
|
Send_GMCP_Packet("request char")
|
|
end
|
|
dnote(("%s Character:Level() returns: %d"):format(Prepend, tonumber(checkGMCPValue("char.status.level"))))
|
|
return tonumber(checkGMCPValue("char.status.level"))
|
|
end
|
|
function Character:TierLevel()
|
|
if not checkGMCPValue("char.base.tier") then
|
|
dnote(("%s: Character:TierLevel() did not return any GMCP data. Attempting to call the GMCP data."):format(Prepend))
|
|
Send_GMCP_Packet("request char")
|
|
end
|
|
dnote(("%s Character:TierLevel() returns: %d"):format(Prepend, (tonumber(checkGMCPValue("char.base.tier"))*10)))
|
|
return (tonumber(checkGMCPValue("char.base.tier"))*10)
|
|
end
|
|
function Character:EffectiveLevel()
|
|
if not checkGMCPValue("char") then
|
|
dnote(("%s: Character:EffectiveLevel() did not return any GMCP data. Attempting to call the GMCP data."):format(Prepend))
|
|
Send_GMCP_Packet("request char")
|
|
end
|
|
dnote(("%s Character:EffectiveLevel() returns: %d"):format(Prepend, (self:Level()+self:TierLevel())))
|
|
return (self:Level() + self:TierLevel())
|
|
end
|
|
]]> </script>
|
|
<script> <![CDATA[ --[[ EqCheck loading & saving to MUSH variables ]]--
|
|
EqCheckSetup = { }
|
|
function EqCheckSetup.SaveEqCheckSettings()
|
|
dnote(("%s EqCheckSetup.SaveEqCheckSettings() was called."):format(Prepend))
|
|
SetVariable("EqCheckSettings", serialize.save_simple(EqCheckSettings))
|
|
end
|
|
function EqCheckSetup.LoadEqCheckSettings()
|
|
dnote(("%s EqCheckSetup.LoadEqCheckSettings() was called."):format(Prepend))
|
|
local settings = GetVariable("EqCheckSettings")
|
|
if settings and settings ~= "" then
|
|
assert(loadstring("EqCheckSettings = "..settings))()
|
|
-- Prevent isses with nil arguments from early adapters for PortalBag --
|
|
if not EqCheckSettings.PortalBag then
|
|
EqCheckSettings.PortalBag=0
|
|
end
|
|
else
|
|
EqCheckSetup.InitializeEqCheckSettings()
|
|
end
|
|
end
|
|
function EqCheckSetup.InitializeEqCheckSettings()
|
|
dnote(("%s EqCheckSetup.InitializeEqCheckSettings() was called."):format(Prepend))
|
|
EqCheckSettings = {
|
|
Enabled=true,
|
|
Bag=0,
|
|
PortalBag=0
|
|
}
|
|
end
|
|
InvSetup = { }
|
|
function InvSetup.SaveInventory()
|
|
dnote(("%s InvSetup.SaveInventory() was called."):format(Prepend))
|
|
SetVariable("EqInventory", serialize.save_simple(EqInventory))
|
|
end
|
|
function InvSetup.LoadInventory()
|
|
dnote(("%s InvSetup.LoadInventory() was called."):format(Prepend))
|
|
local settings = GetVariable("EqInventory")
|
|
if settings and settings ~= "" then
|
|
assert(loadstring("EqInventory = "..settings))()
|
|
else
|
|
dnote(("%s MUSH Variable for 'EqInventory' could not be loaded. Creating an empty EqInventory table."):format(Prepend))
|
|
EqInventory = { }
|
|
end
|
|
end
|
|
PortalSetup = { }
|
|
function PortalSetup.SavePortalInventory()
|
|
dnote(("%s PortalSetup.SavePortalInventory() was called."):format(Prepend))
|
|
SetVariable("PortalInventory", serialize.save_simple(PortalInventory))
|
|
end
|
|
function PortalSetup.LoadPortalInventory()
|
|
dnote(("%s PortalSetup.LoadPortalInventory() was called."):format(Prepend))
|
|
local settings = GetVariable("PortalInventory")
|
|
if settings and settings ~= "" then
|
|
assert(loadstring("PortalInventory = "..settings))()
|
|
else
|
|
dnote(("%s MUSH Variable for 'PortalInventory' could not be loaded. Creating an empty PortalInventory table."):format(Prepend))
|
|
PortalInventory = { }
|
|
end
|
|
end
|
|
]]> </script>
|
|
<script> <![CDATA[ --[[ MUSH calls:
|
|
OnPluginBroadcast():
|
|
OnPluginEnable()
|
|
OnPluginInstall()
|
|
]]--
|
|
function OnPluginBroadcast (msg, id, name, text)
|
|
if not (id == GMCPPluginID) then return end
|
|
if id == GMCPPluginID and text == "char.status" and EqCheck.IsPlaying() then
|
|
if not EqCheck.Player then EqCheck.Player = Character.New() end
|
|
EqCheck.Player.LastLevel = EqCheck.Player.CurrentLevel
|
|
EqCheck.Player.CurrentLevel = EqCheck.Player:Level()
|
|
if EqCheck.Player.LastLevel ~= EqCheck.Player.CurrentLevel then
|
|
dnote(Prepend.."EqCheck.Player.LastLevel and EqCheck.Player.CurrentLevel are different, EqCheck.ProcessLevel() called!")
|
|
EqCheck.ProcessLevel()
|
|
end
|
|
end
|
|
end
|
|
function OnPluginInstall()
|
|
OnPluginEnable()
|
|
end
|
|
function OnPluginEnable()
|
|
EqCheckSetup.InitializeEqCheckSettings()
|
|
EqCheckSetup.LoadEqCheckSettings()
|
|
InvSetup.LoadInventory()
|
|
PortalSetup.LoadPortalInventory()
|
|
EQADMIN_Help()
|
|
end
|
|
]]> </script>
|
|
<script> <![CDATA[ --[[ EQAdmin Commands ]]--
|
|
EQADMIN_Commands = {
|
|
EQADMIN_Debug = { "debug", "debu", "deb" },
|
|
EQADMIN_Enable = { "enabled", "enable", "enabl", "enab", "ena", "en", "e" },
|
|
EQADMIN_EqSync = { "eqsync", "eqsyn", "eqsy" },
|
|
EQADMIN_Help = { "help", "hel", "he", "h" },
|
|
EQADMIN_InvClean = { "invclean", "invclea", "invcle", "invcl", "invc" },
|
|
EQADMIN_PortalClean = { "portalclean", "portalclea", "portalcle", "portalcl", "portalc" },
|
|
EQADMIN_PortalSync = { "portalsync", "portalsyn", "portalsy" },
|
|
EQADMIN_Set = { "set", "se" },
|
|
EQADMIN_Status = { "status", "statu", "stat", "sta", "st" }
|
|
}
|
|
EQADMIN_SET_Commands = {
|
|
EQADMIN_SET_Bag = { "bag", "ba", "b" },
|
|
EQADMIN_SET_PortalBag = { "portalbag", "portalba", "portalb" }
|
|
}
|
|
function COMMAND_CheckEquipment( name, line, args )
|
|
if not (args.level or isNumber(args.level)) then
|
|
cnote(("%s EqCheck command requires a level argument."):format(Prepend))
|
|
dnote(("%s EqCheck command did not have an argument or argument was not a number."):format(Prepend))
|
|
return
|
|
end
|
|
dnote(("%s EqCheck used %d as level to call InventoryManager.CreateTempItemList."):format(Prepend,args.level))
|
|
if InventoryManager.CreateTempItemList(tonumber(args.level)) then
|
|
InventoryManager.WearItemList()
|
|
end
|
|
end
|
|
function COMMAND_EQAdmin(name, lines, wildcards)
|
|
local args, command = {}, nil
|
|
--split args, set first to "command", default to 'help'
|
|
for word in string.gmatch(wildcards.Args, "%w+") do
|
|
table.insert(args, word)
|
|
dnote( ("%s COMMAND_EQAdmin argument added to 'args' table: %s"):format(Prepend,word) )
|
|
end
|
|
command = args[1]
|
|
if command then table.remove(args,1) else command = "help" end
|
|
--parse command
|
|
command = string.lower(command)
|
|
for func, list in pairs(EQADMIN_Commands) do
|
|
for _, item in ipairs(list) do
|
|
if command == item then
|
|
dnote( ("%s COMMAND_EQAdmin passing function [%s] and sending the following argument on [%s]"):format(Prepend, func, args[1]) )
|
|
return _G[func](args)
|
|
end
|
|
end
|
|
end
|
|
EQADMIN_UnrecognizedCommand()
|
|
end
|
|
--[[ EQAdmin main command functions ]]--
|
|
function EQADMIN_UnrecognizedCommand()
|
|
cnote(Prepend.."Unrecognized command. Try '@Gqadmin help@w' for help.")
|
|
Note()
|
|
end
|
|
function EQADMIN_Debug()
|
|
EqCheck.Debug = not EqCheck.Debug
|
|
cnote( Prepend.."EqCheck Debug mode is now "..(EqCheck.Debug and "@GOn@w" or "@ROff@w") )
|
|
cnote( Prepend.."This setting is not saved and must be toggled each time script is enabled." )
|
|
Note()
|
|
end
|
|
function EQADMIN_Enable()
|
|
EqCheckSettings.Enabled = not EqCheckSettings.Enabled
|
|
cnote( Prepend.."EqCheck is now "..(EqCheckSettings.Enabled and "@GOn@w" or "@ROff@w") )
|
|
EqCheckSetup.SaveEqCheckSettings()
|
|
end
|
|
function EQADMIN_EqSync()
|
|
dnote(("%s EQADMIN_EqSync has been called. Starting the process of creating the EqInventory table."):format(Prepend))
|
|
EnableTriggerGroup("GroupInvDataStart", true)
|
|
EnableTriggerGroup("GroupEqSync", true)
|
|
EqInventory = { }
|
|
SendNoEcho(("invdata %d ansi"):format(EqCheckSettings.Bag))
|
|
end
|
|
function EQADMIN_Help()
|
|
cnote("@GEquipment Manager@w")
|
|
cnote("@WUsage:@w")
|
|
cnote("@G eqadmin help @w:@W This menu@w")
|
|
cnote("@G eqadmin enabled @w:@W Toggles ON/OFF the automatic equipment checking@w")
|
|
cnote("@G eqadmin status @w:@W Display the current settings EquipmentManager@w")
|
|
cnote("@G eqcheck <level> @w:@W Manually auto-wear equipment for level inputted@w")
|
|
Note()
|
|
cnote("@WInventory Cleanup Commands:@w")
|
|
cnote("@G eqadmin invclean @w:@W Puts any items that exist in Equipment Inventory into defined bag@w")
|
|
cnote("@G eqadmin portalclean @w:@W Puts any portals that exist in Portal Inventory into defined bag@w")
|
|
Note()
|
|
cnote("@WSet Commands:@w")
|
|
cnote("@G eqadmin set bag <Bag ID#> @w:@W Sets the BAG ID# EqCheck will check in@w")
|
|
cnote("@G eqadmin set portalbag <Bag ID#> @w:@W Sets the Portal BAG ID# for Portal Inventory@w")
|
|
Note()
|
|
cnote("@WSetup Commands:@w")
|
|
cnote("@G eqadmin eqsync @w:@W Builds the Equipment Inventory@w" )
|
|
cnote("@G eqadmin portalsync @w:@W Builds the Portal Inventory@w")
|
|
Note()
|
|
end
|
|
function EQADMIN_InvClean()
|
|
dnote(("%s EQADMIN_InvClean has been called. Starting the process of putting away equipment."):format(Prepend))
|
|
EnableTriggerGroup("GroupInvDataStart", true)
|
|
EnableTriggerGroup("GroupInventoryCleanup", true)
|
|
InvList = { }
|
|
SendNoEcho("invdata ansi")
|
|
end
|
|
function EQADMIN_PortalClean()
|
|
dnote(("%s EQADMIN_PortalClean has been called. Starting the process of putting away equipment."):format(Prepend))
|
|
EnableTriggerGroup("GroupInvDataStart", true)
|
|
EnableTriggerGroup("GroupPortalCleanUp", true)
|
|
PortalList = { }
|
|
SendNoEcho("invdata ansi")
|
|
end
|
|
function EQADMIN_PortalSync()
|
|
dnote(("%s EQADMIN_PortalSync has been called. Starting the process of creating the PortalInventory table."):format(Prepend))
|
|
EnableTriggerGroup("GroupInvDataStart", true)
|
|
EnableTriggerGroup("GroupPortalInventorySetup", true)
|
|
PortalInventory = { }
|
|
SendNoEcho(("invdata %d ansi"):format(EqCheckSettings.PortalBag))
|
|
end
|
|
function EQADMIN_Set(arguments)
|
|
if not arguments[1] then
|
|
dnote( ("%s EQAdmin_Set(arguments) returned without any arguments."):format(Prepend) )
|
|
return
|
|
end
|
|
dnote( ("%s EQAdmin_Set(arguments) called." ):format(Prepend) )
|
|
--parse command
|
|
local command = string.lower(arguments[1])
|
|
for func, list in pairs(EQADMIN_SET_Commands) do
|
|
for _, item in ipairs(list) do
|
|
if command == item then
|
|
dnote(("%s EQADMIN_Set called %s function with the argument of %s"):format(Prepend,func,arguments[2]))
|
|
return _G[func](arguments[2])
|
|
end
|
|
end
|
|
end
|
|
EQADMIN_UnrecognizedCommand()
|
|
end
|
|
function EQADMIN_Status()
|
|
cnote(("%s EqCheck is %s"):format(Prepend, (EqCheckSettings.Enabled and "@Gon@w" or "@Roff@w")))
|
|
cnote(("%s EqCheck is using Bag ID#@G%d@w to check for new equipment."):format(Prepend, EqCheckSettings.Bag))
|
|
cnote(("%s Portal Inventory is using Bag ID#@G%d@w for portals."):format(Prepend,EqCheckSettings.PortalBag))
|
|
Note()
|
|
end
|
|
--[[ EQAdmin Set command Functions ]]--
|
|
function EQADMIN_SET_Bag(args)
|
|
if (not args) or (tonumber(args) == nil) then
|
|
cnote(Prepend.."@CSyntax is: @weqadmin set bag @R<bag id#>@w" )
|
|
return
|
|
end
|
|
dnote(("%s EQADMIN_SET_Bag is setting EqCheckSettings.Bag to %d"):format(Prepend, tonumber(args)))
|
|
EqCheckSettings.Bag = tonumber(args)
|
|
cnote(("%s EqCheck will now look for equipment from Bag ID#@G%d@w."):format(Prepend, EqCheckSettings.Bag))
|
|
EqCheckSetup.SaveEqCheckSettings()
|
|
end
|
|
function EQADMIN_SET_PortalBag(args)
|
|
if (not args) or (tonumber(args) == nil) then
|
|
cnote(Prepend.."@CSyntax is: @weqadmin set portalbag @R<bag id#>@w" )
|
|
return
|
|
end
|
|
dnote(("%s EQADMIN_SET_PortalBag is setting EqCheckSettings.PortalBag to %d"):format(Prepend, tonumber(args)))
|
|
EqCheckSettings.PortalBag = tonumber(args)
|
|
cnote(("%s Portal Management will now place portals in Bag ID#@G%d@w."):format(Prepend, EqCheckSettings.PortalBag))
|
|
EqCheckSetup.SaveEqCheckSettings()
|
|
end
|
|
]]> </script>
|
|
<script> <![CDATA[ --[[ Trigger Functions ]]--
|
|
function TRIGGER_AddInventoryItem( name, line, args )
|
|
if not (args.objid or args.objlevel) then
|
|
cnote(("%s Error adding item to EqInventory table."):format(Prepend))
|
|
dnote(("%s TRIGGER_AddInventoryItem did not provide an argument for either objid or objlevel"):format(Prepend))
|
|
return
|
|
end
|
|
local obj_id, obj_level = tostring(args.objid), tonumber(args.objlevel)
|
|
EqInventory[obj_id] = obj_level
|
|
dnote(("%s AddInventoryItem( %s, %d ) called. Added %s with value of %d to EqInventory table."):format(Prepend, obj_id, obj_level, obj_id, obj_level))
|
|
cnote(("%s Item(%s) with a level of %d was added."):format(Prepend, obj_id, obj_level))
|
|
end
|
|
function TRIGGER_AddInvListItem( name, line, args )
|
|
if not (args.objid) then
|
|
dnote(("%s TRIGGER_CreateInventoryListItem() did not have an args.objid argument."):format(Prepend))
|
|
return
|
|
end
|
|
if not temporaryEquipmentList then temporaryEquipmentList = {} end
|
|
table.insert(temporaryEquipmentList, 1, tostring(args.objid))
|
|
end
|
|
function TRIGGER_AddPortalInvItem( name, line, args )
|
|
if not (args.objid) then
|
|
cnote(("%s Error adding item to PortalInventory table."):format(Prepend))
|
|
dnote(("%s TRIGGER_AddPortalItem did not provide an argument for objid"):format(Prepend))
|
|
return
|
|
end
|
|
table.insert(PortalInventory, 1, tostring(args.objid))
|
|
dnote(("%s TRIGGER_AddPortalItem(%s) called. Added %s to PortalInventory table."):format(Prepend, tostring(args.objid), tostring(args.objid)))
|
|
cnote(("%s Portal(%s) was added Portal Inventory."):format(Prepend, tostring(args.objid)))
|
|
end
|
|
function TRIGGER_AddInvPortalListItem( name, line, args )
|
|
if not (args.objid) then
|
|
dnote(("%s TRIGGER_CreateInventoryPortalListItem() did not have an args.objid argument."):format(Prepend))
|
|
return
|
|
end
|
|
if not temporaryPortalList then temporaryPortalList = {} end
|
|
table.insert( temporaryPortalList, 1, tostring(args.objid) )
|
|
end
|
|
function TRIGGER_EndInvData( name, line, args )
|
|
if name == "InvDataEnd" then
|
|
EnableTriggerGroup("GroupInvDataStart", false)
|
|
EnableTriggerGroup("GroupEqSync", false)
|
|
cnote(("%s EqSync is complete!"):format(Prepend))
|
|
InvSetup.SaveInventory()
|
|
elseif name == "InvDataInvCleanUpEnd" then
|
|
EnableTriggerGroup("GroupInvDataStart", false)
|
|
EnableTriggerGroup("GroupInventoryCleanup", false)
|
|
dnote(("%s Now creating a temporary 'inventory' table to then process against EqInventory table."):format(Prepend))
|
|
InventoryManager.ProcessEquipmentCleanUpList()
|
|
elseif name == "InvDataPortalSetupEnd" then
|
|
EnableTriggerGroup("GroupInvDataStart", false)
|
|
EnableTriggerGroup("GroupPortalInventorySetup", false)
|
|
cnote(("%s PortalSync is complete!"):format(Prepend))
|
|
PortalSetup.SavePortalInventory()
|
|
elseif name == "InvDataPortCleanEnd" then
|
|
EnableTriggerGroup("GroupInvDataStart", false)
|
|
EnableTriggerGroup("GroupPortalCleanUp", false)
|
|
dnote(("%s Now creating a temporary 'inventory' table to then process against PortalInventory table."):format(Prepend))
|
|
InventoryManager.ProcessPortalCleanUpList()
|
|
end
|
|
end
|
|
]]> </script>
|
|
<script> <![CDATA[ --[[ Inventory Manager Functions ]]--
|
|
InventoryManager = { }
|
|
local TempInventory, InvList = { }, { }
|
|
function InventoryManager.CreateTempItemList(objlevel)
|
|
if not objlevel then return false end
|
|
local obj_level = tonumber(objlevel)
|
|
for obj, list in pairs(EqInventory) do
|
|
if EqInventory[obj] == objlevel then
|
|
table.insert(TempInventory, 1, obj)
|
|
dnote(("%s InventoryManager.RetrieveItemList(%d) added Object ID#%s to TempInventory table."):format(Prepend,obj_level,obj))
|
|
end
|
|
end
|
|
if #TempInventory>0 then
|
|
dnote(("%s InventoryManager.CreateTempItemList created the TempInventory table with a size of %d"):format(Prepend, #TempInventory))
|
|
return true
|
|
else
|
|
dnote(("%s InventoryManager.CreateTempItemList did not create the TempInventory table."):format(Prepend))
|
|
return false
|
|
end
|
|
end
|
|
function InventoryManager.WearItemList()
|
|
dnote(("%s InventoryManager.WearItemList() is now wearing items from TempInventory table."):format(Prepend))
|
|
if #TempInventory > 0 then EqCheck.Remove() end
|
|
for obj, list in pairs(TempInventory) do
|
|
SendNoEcho(("take %s %d"):format(TempInventory[obj], EqCheckSettings.Bag))
|
|
SendNoEcho(("wear %s"):format(TempInventory[obj]))
|
|
end
|
|
if #TempInventory > 0 then SendNoEcho("wear all") end
|
|
TempInventory = { }
|
|
end
|
|
function InventoryManager.ProcessEquipmentCleanUpList()
|
|
for invdata, value in pairs(EqInventory) do
|
|
for portal, objid in pairs(temporaryEquipmentList) do
|
|
if objid == invdata then
|
|
dnote(("%s @wInventoryManager.ProcessEquipmentCleanUpList added equipment(@R%s@w) to InvList for cleanup.@w"):format(Prepend, objid))
|
|
table.insert(InvList, 1, objid)
|
|
break
|
|
end
|
|
end
|
|
end
|
|
InventoryManager.InventoryCleanUp()
|
|
end
|
|
function InventoryManager.InventoryCleanUp()
|
|
if #InvList == 0 then
|
|
dnote(("%s InventoryManager.InventoryCleanUp is reporting InvList as emtpy."):format(Prepend))
|
|
return
|
|
end
|
|
dnote(("%s InventoryManager.InventoryCleanUp() is now putting items from InvList table into bag id#%d."):format(Prepend, EqCheckSettings.Bag))
|
|
cnote(("%s Putting the managed equipment into bag id#@R%d@w."):format(Prepend,EqCheckSettings.Bag))
|
|
for obj, list in pairs(InvList) do
|
|
SendNoEcho(("put %s %d"):format(InvList[obj], EqCheckSettings.Bag))
|
|
end
|
|
InvList = { }
|
|
end
|
|
function InventoryManager.ProcessPortalCleanUpList()
|
|
for invdata, value in pairs(PortalInventory) do
|
|
for portal, objid in pairs(temporaryPortalList) do
|
|
if objid == value then
|
|
dnote(("%s @wInventoryManager.ProcessPortalCleanUpList added portal(@R%s@w) to PortalList for cleanup.@w"):format(Prepend, objid))
|
|
table.insert(PortalList, 1, objid)
|
|
break
|
|
end
|
|
end
|
|
end
|
|
InventoryManager.PortalCleanUp()
|
|
end
|
|
function InventoryManager.PortalCleanUp()
|
|
if #PortalList == 0 then
|
|
dnote(("%s InventoryManager.PortalCleanUp() is reporting PortalList as emtpy."):format(Prepend))
|
|
return
|
|
end
|
|
dnote(("%s InventoryManager.PortalCleanUp() is now putting portals from PortalList table into bag id#%d."):format(Prepend, EqCheckSettings.PortalBag))
|
|
cnote(("%s Putting the managed portals into bag id#@R%d@w."):format(Prepend,EqCheckSettings.PortalBag))
|
|
for obj, list in pairs(PortalList) do
|
|
SendNoEcho(("put %s %d"):format(PortalList[obj], EqCheckSettings.PortalBag))
|
|
end
|
|
InvList = { }
|
|
|
|
end
|
|
]]> </script>
|
|
</muclient> |