Log in

View Full Version : [Request] Script to Auto use an item on a list of items



Y2Quake
06-21-2016, 01:37 PM
Hello peeps, currently playing on an OTS that has this item that allows you to sell loot by using it on the loot in question....

09:34 You see a Magical Orb.
Use this item to sell items for gold, only items sold to npcs. [ID 8822]

I would like to make a lua script that checks from a list of items and when they are found in your backpack it will sell them via the Magical Orb.
If this was elfbot id be set but im a bit rusty with lua. Anyone care to help?

Example of random items i'd like to sell:

Royal Helmet
Warrior Helmet
Medusa Shield
Knight Armor
...etc

EDIT: Ended up figuring it out



CONFIG = {
PRIMARY = 8822,
SECONDARY = {3392, 3369, 3436, 3370, 3079, 3371}
}

Module.New("USING ITEM ON OTHER ITEM.", function(moduleObject)
local PRIMARY, SECONDARY, SPOTS = nil, nil, {}
for i = 0, 15 do
local cont = Container.New(i)
if not table.contains({"The", "Demonic", "Dead", "Slain", "Dissolved", "Remains", "Elemental"}, string.match(cont:Name(), "%a+")) then
for SPOT = cont:ItemCount() - 1, 0, -1 do
local tmp = cont:GetItemData(SPOT)
if (tmp.id == CONFIG.PRIMARY) then
PRIMARY = cont
SPOTS[1] = SPOT
elseif (table.contains(CONFIG.SECONDARY, tmp.id)) then
SECONDARY = cont
SPOTS[2] = SPOT
end
end
end
end
if (PRIMARY ~= nil and SECONDARY ~= nil) then
PRIMARY:UseItemWithContainerItem(SPOTS[1], SECONDARY:Index(), SPOTS[2])
end
moduleObject:Delay(1000)
end)

Y2Quake
06-21-2016, 07:49 PM
Bumps

Trykon
06-21-2016, 07:55 PM
If I were you I would use rust remover function and just change it a bit ;)