problem witha function im trying to write
Posted: Wed Jan 14, 2015 3:33 am
I'm not very good with coding so could someone please help, thank you in advanced.
What im trying to do is have the bot check items in my backpack and look at the stats and if the stats are not part of my list it sells them.
I get "attempt to index field 'stat' <a nil value>" every time i try and execute this version the main change i made was in Backchack() up to inventory:useItem("Salioca Upheaval Cloak") i added itemHasStat("Salioca Upheaval Cloak", "Guardian of the Basin") to try to specify what items i want to keep and sale, because the rest of the Backcheck() sales all items regardless of stats.
sorry for the trouble.
What im trying to do is have the bot check items in my backpack and look at the stats and if the stats are not part of my list it sells them.
I get "attempt to index field 'stat' <a nil value>" every time i try and execute this version the main change i made was in Backchack() up to inventory:useItem("Salioca Upheaval Cloak") i added itemHasStat("Salioca Upheaval Cloak", "Guardian of the Basin") to try to specify what items i want to keep and sale, because the rest of the Backcheck() sales all items regardless of stats.
sorry for the trouble.
Code: Select all
function itemHasStat(item, stat)
if (item.Stats[1] and item.Stats[1].Name == "Ability of the Basin") or -- Str/pa
(item.Stats[2] and item.Stats[2].Name == "Guardian of the Basin") or --Stam/Pa
(item.Stats[3] and item.Stats[3].Name == "Illusion of the Basin") or -- Int / MA
(item.Stats[4] and item.Stats[4].Name == "Sorcery of the Basin") or -- Int / Stam
(item.Stats[5] and item.Stats[5].Name == "Triumph of the Basin") or -- Dex PA
(item.Stats[6] and item.Stats[6].Name == "Protection of the Basin") or -- Stam / Def
(item.Stats[7] and item.Stats[7].Name == "Ability of the Jungle") or -- Str/PA
(item.Stats[8] and item.Stats[8].Name == "Guardian of the Jungle") or -- Stam/ PA
(item.Stats[9] and item.Stats[9].Name == "Illusion of the Jungle") or -- Int MA
(item.Stats[10] and item.Stats[10].Name == "Sorcery of the Jungle") or -- Int / Stam
(item.Stats[11] and item.Stats[11].Name == "Triumph of the Jungle") or -- Dex PA
(item.Stats[12] and item.Stats[12].Name == "Protection of the Jungle") then -- Stam / Def
return true
end
end
function Backcheck()
for slot = 61,120 do
local item = inventory.BagSlot[slot]
if item.Name == "Salioca Upheaval Cloak" then
inventory:update()
if itemHasStat("Salioca Upheaval Cloak", "Guardian of the Basin") or
itemHasStat("Salioca Upheaval Cloak", "Protection of the Basin") then
shells()
else
player:openStore("Byron - Archeologist")
inventory:useItem("Salioca Upheaval Cloak")
end
elseif item.Name == "Hortek Subversion Shoulder Armor" then
if #item.Stats == 8 then
elseif #item.Stats == 12 then
-- send to mule 2
else
player:openStore("Byron - Archeologist")
if player:openStore("Byron - Archeologist") then
inventory:useItem("Hortek Subversion Shoulder Armor")
end
end
elseif item.Name == "Salioca Crush Cloak" then
if #item.Stats == 1 then
else
player:openStore("Byron - Archeologist")
if player:openStore("Byron - Archeologist") then
inventory:useItem("Salioca Crush Cloak")
end
end
elseif item.Name == "Hortek Crush Shoulder Armor" then
if #item.Stats == 7 then
else
player:openStore("Byron - Archeologist")
if player:openStore("Byron - Archeologist") then
inventory:useItem("Hortek Crush Shoulder Armor")
end
end
elseif item.Name == "Salioca Vengeance Cloak" then
if #item.Stats == 5 then
else
player:openStore("Byron - Archeologist")
if player:openStore("Byron - Archeologist") then
inventory:useItem("Salioca Vengeance Cloak")
end
end
elseif item.Name == "Hortek Vengeance Shoulder Armor" then
if #item.Stats == 11 then
else
player:openStore("Byron - Archeologist")
if player:openStore("Byron - Archeologist") then
inventory:useItem("Hortek Vengeance Shoulder Armor")
end
end
elseif item.Name == "Salioca Wisdom Cloack" then
if #item.Stats == 3 then
elseif #item.Stats == 4 then
-- send to mule 2
else
player:openStore("Byron - Archeologist")
if player:openStore("Byron - Archeologist") then
inventory:useItem("Salioca Wisdom Cloack")
end
end
elseif item.Name == "Hortek Wisdom Shoulder Guards" then
if #item.Stats == 9 then
elseif #item.Stats == 10 then
-- send to mule 2
else
player:openStore("Byron - Archeologist")
if player:openStore("Byron - Archeologist") then
inventory:useItem("Hortek Wisdom Shoulder Guards")
end
end
end
end
end