Postado Outubro 24, 2015 9 anos Caso vocês souberem quem criou o scripting, por favor me informar o créditos para eu editar. while (true) do cID_cName = { [1] = "3478", } cID_ID = { [1] = {3031, 3059, 3265, 3282, 3285, 3409}, } function itemFix(item) return 0 end if (type(getItemCost) == "nil") then print("XenoBot: You are using an old version that does not support Item.GetCost(). Therefore the function was replaced.") Item.GetCost = itemFix end if (type(getItemValue) == "nil") then print("XenoBot: You are using an old version that does not support Item.GetValue(). Therefore the function was replaced.") Item.GetValue = itemFix end --- Get monsterid from name. -- Returns the monsterid by providing it's name -- @class Creature -- @param creature the monster's name -- @return number the monsterid function Creature.GetMonsterID(creature) for id, name in pairs(cID_cName) do if (name:lower() == creature:lower()) then return id end end return 0 end Settings = {} --- Create deposit list -- Prints a list for stackable and non-stackable items used for the Self.DepositItems() function -- @class Settings -- @param minvalue the minimum value of an item to be added to the list -- @param stackbp the backpack index where stackable items should go to -- @param nonstackbp the backpack index where non-stackable items should go to -- @param creatures a table or single creature which you want to get the loot of -- @return nothing function Settings.CreateDepositList(minvalue, stackbp, nonstackbp, creatures, ch) minvalue = minvalue or -1 stackbp = stackbp or 0 nonstackbp = nonstackbp or 0 local stackables = {} local nonstackables = {} if (type(creatures) == "table") then for _, name in ipairs(creatures) do local creatureID = Creature.GetMonsterID(name) if (creatureID ~= 0) then for _, item in ipairs(cID_iID[creatureID]) do if (Item.GetCost(item) >= minvalue or Item.GetValue(item) >= minvalue) then if (Item.isStackable(item) and not table.contains(stackables, item)) then stackables[#stackables+1] = "{" .. item .. ", " .. stackbp .. "}" elseif (not Item.isStackable(item) and not table.contains(nonstackables, item)) then nonstackables[#nonstackables+1] = "{" .. item .. ", " .. nonstackbp .. "}" end end end else ch:SendOrangeMessage("XenoBot", "Could not find creature with name '" .. name .. "'.") end end else local creatureID = Creature.GetMonsterID(creatures) if (creatureID ~= 0) then for _, item in ipairs(cID_iID[creatureID]) do if (Item.GetCost(item) >= minvalue or Item.GetValue(item) >= minvalue) then if (Item.isStackable(item) and not table.contains(stackables, item)) then stackables[#stackables+1] = "{" .. item .. ", " .. stackbp .. "}" elseif (not Item.isStackable(item) and not table.contains(nonstackables, item)) then nonstackables[#nonstackables+1] = "{" .. item .. ", " .. nonstackbp .. "}" end end end end end local depositlist = {} for i = 1, #nonstackables do depositlist[#depositlist+1] = nonstackables[i] end for i = 1, #stackables do depositlist[#depositlist+1] = stackables[i] end ch:SendOrangeMessage("XenoBot", "Self.DepositItems(" .. table.concat(depositlist, ", ") .. ")") end --- Create loot list -- Creates a lootlist and additionally a file in your Settings folder named XenoBot - Lootlist.xbst -- @class Settings -- @param minvalue the minimum value of an item to be added to the list -- @param stackbp the backpack number where stackable items should go to -- @param nonstackbp the backpack number where non-stackable items should go to -- @param creatures a table or single creature which you want to get the loot of -- @return boolean true or false function Settings.CreateLootList(minvalue, stackbp, nonstackbp, creatures, ch) minvalue = minvalue or -1 stackbp = stackbp or 0 nonstackbp = nonstackbp or 0 local function tSort(t) table.sort(t) return pairs(t) end local function iName(i) local n = Item.GetName(i) if (n ~= "unknown") then return n end return "?" end local function wFile(n, t) local f = io.open("..\\Settings\\"..n..".xbst", "a") f:write(t.."\n") f:close() end local fname = "XenoBot - Lootlist" local lootlist = {} local lootvalue = {} if (type(creatures) == "table") then header = "<!-- Creatures: "..table.concat(creatures, ", ").." -->" for _, name in ipairs(creatures) do local creatureID = Creature.GetMonsterID(name) if (creatureID ~= 0) then for _, item in ipairs(cID_iID[creatureID]) do if (not table.contains(lootlist, item) and (Item.GetCost(item) >= minvalue or Item.GetValue(item) >= minvalue)) then if (Item.GetValue(item) > 0) then lootvalue[#lootvalue+1] = Item.GetValue(item) else lootvalue[#lootvalue+1] = 0 end lootlist[#lootlist+1] = item end end else ch:SendOrangeMessage("XenoBot", "Could not find creature with name '" .. name .. "'.") end end else header = "<!-- Creatures: "..creatures.." -->" local creatureID = Creature.GetMonsterID(creatures) if (creatureID ~= 0) then for _, item in ipairs(cID_iID[creatureID]) do if (not table.contains(lootlist, item) and (Item.GetCost(item) >= minvalue or Item.GetValue(item) >= minvalue)) then if (Item.GetValue(item) > 0) then lootvalue[#lootvalue+1] = Item.GetValue(item) else lootvalue[#lootvalue+1] = 0 end lootlist[#lootlist+1] = item end end end end if (#lootlist > 0) then local f = io.open("..\\Settings\\"..fname..".xbst", "w") f:close() wFile(fname, header) wFile(fname, "<panel name=\"Looter\">") wFile(fname, " <control name=\"LootList\" first=\"0\" unlisted=\"0\">") local val = {} for k, v in tSort(lootvalue) do if (not table.contains(val, v)) then val[#val+1] = v end end local i = #val while (i > 0) do for j = 1, #lootlist do if (Item.GetValue(lootlist[j]) == val[i]) then if (Item.isStackable(lootlist[j])) then wFile(fname, " <item ID=\""..lootlist[j].."\" action=\"" .. stackbp-1 .. "\"/> <!-- "..iName(lootlist[j]).." -->") else wFile(fname, " <item ID=\""..lootlist[j].."\" action=\"" .. nonstackbp-1 .. "\"/> <!-- "..iName(lootlist[j]).." -->") end end end i = i - 1 end wFile(fname, " </control>") wFile(fname, "</panel>") loadSettings(fname, "All") ch:SendOrangeMessage("XenoBot", "Created lootlist successfully.") return true end return false end function explode(div, str) if (div == '') then return false end local pos, arr = 0, {} for st, sp in function() return string.find(str, div, pos, true) end do table.insert(arr, string.sub(str, pos, st - 1)) pos = sp + 1 end table.insert(arr, string.sub(str, pos)) for i = 1, #arr do arr[i] = arr[i]:trim() end return arr end local lootlist = false local depositlist = false local loads = false local list = false function onSpeak(ch, cmd) ch:SendYellowMessage(Self.Name(), cmd) cmd = cmd:lower() if (cmd == "loot" and not lootlist and not depositlist) then lootlist = true ch:SendOrangeMessage("XenoBot", "Please type 'load' if you want to load the creature list from a XenoBot Settings's Targeting list.") ch:SendOrangeMessage("XenoBot", "Please type 'enter' if you want to enter the creature list yourself.") elseif (cmd == "deposit" and not depositlist and not lootlist) then depositlist = true ch:SendOrangeMessage("XenoBot", "Please type 'load' if you want to load the creature list from a XenoBot Settings's Targeting list.") ch:SendOrangeMessage("XenoBot", "Please type 'enter' if you want to enter the creature list yourself.") elseif (cmd == "load" and (lootlist or depositlist) and not loads and not list) then loads = true ch:SendOrangeMessage("XenoBot", "Please type the name of the Settings file.") elseif (cmd == "enter" and (lootlist or depositlist) and not list and not loads) then list = true ch:SendOrangeMessage("XenoBot", "Please type every creature name separated by a comma.") else if (cmd == "restart") then lootlist = false depositlist = false loads = false list = false ch:SendOrangeMessage("XenoBot", "Please type 'loot' to create your own list for XenoBot's Looter.") ch:SendOrangeMessage("XenoBot", "Please type 'deposit' to create your own list for XenoBot's Self.DepositItems() function.") elseif (cmd:find(".xbst") and loads and (lootlist or depositlist)) then if (lootlist) then xpcall( function() local file = io.open("..\\Settings\\".. cmd, "r") local data = file:read("*all") file:close() creatureTable = {} for k, v in string.gmatch(data, '<item type="(.-)"') do creatureTable[#creatureTable+1] = k end Settings.CreateLootList(-1, 1, 2, creatureTable, ch) end, function(err) ch:SendOrangeMessage("XenoBot", "The file could not be found. Please check if you have spelled the name correctly.") end ) elseif (depositlist) then xpcall( function() local file = io.open("..\\Settings\\".. cmd, "r") local data = file:read("*all") file:close() creatureTable = {} for k, v in string.gmatch(data, '<item type="(.-)"') do creatureTable[#creatureTable+1] = k end Settings.CreateDepositList(-1, 1, 2, creatureTable, ch) end, function(err) ch:SendOrangeMessage("XenoBot", "The file could not be found. Please check if you have spelled the name correctly.") end ) end elseif (cmd:find(",") and list and (lootlist or depositlist)) then if (lootlist) then xpcall( function() creatureTable = explode(",", cmd) Settings.CreateLootList(-1, 1, 2, creatureTable, ch) end, function(err) ch:SendOrangeMessage("XenoBot", "Your list could not be recognised. Please check if you have separated every name with a comma") end ) elseif (depositlist) then xpcall( function() creatureTable = explode(",", cmd) Settings.CreateDepositList(-1, 1, 2, creatureTable, ch) end, function(err) ch:SendOrangeMessage("XenoBot", "Your list could not be recognised. Please check if you have separated every name with a comma") end ) end elseif (list and (lootlist or depositlist)) then if (lootlist) then xpcall( function() Settings.CreateLootList(-1, 1, 2, cmd, ch) end, function(err) ch:SendOrangeMessage("XenoBot", "Your list could not be recognised. Please check if you have separated every name with a comma") end ) elseif (depositlist) then xpcall( function() Settings.CreateDepositList(-1, 1, 2, cmd, ch) end, function(err) ch:SendOrangeMessage("XenoBot", "Your list could not be recognised. Please check if you have separated every name with a comma") end ) end else ch:SendOrangeMessage("XenoBot", "Your command could not be recognized. Please read the instructions carefully.") end end end function onClose(ch) print(ch:Name() .. " has been closed. \nPlease re-execute to continue.") end local ch = Channel.New("Loot Functions", onSpeak, onClose) ch:SendOrangeMessage("XenoBot", "Welcome to the Loot / Deposit List Creator!") ch:SendOrangeMessage("XenoBot", "Please type 'loot' to create your own list for XenoBot's Looter.") ch:SendOrangeMessage("XenoBot", "Please type 'deposit' to create your own list for XenoBot's Self.DepositItems() function.") ch:SendOrangeMessage("XenoBot", "Type 'restart' to go back to the start.") Desde já agradeço a colaboração de todos. lootFunctions.lua Editado Outubro 24, 2015 9 anos por Ohko (veja o histórico de edições)
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.