Page 1 of 1
[Question: Answered] If free Inventory<3 goto X
Posted: Fri Nov 05, 2010 3:03 pm
by Germangold
Dear MM guys!
I have a problem regarding loading another path when there are only 3 spaces in bag left.
Following code is within a waypoint
Trigger for mainhands duration is allready set and working like a charm!
Code: Select all
(..)
if( inventory:getItemCount(0) > 58 ) then
loadPaths("ravenfell_sellnpcl"); end
Isnt it true that inventory:getItemCount(0) returns the value of total items occupied in the bag?
How can i solve my problem?
Re: [Question: Unanswered] If free Inventory<3 goto X
Posted: Fri Nov 05, 2010 6:01 pm
by jduartedj
Germangold wrote:Dear MM guys!
I have a problem regarding loading another path when there are only 3 spaces in bag left.
Following code is within a waypoint
Trigger for mainhands duration is allready set and working like a charm!
Code: Select all
(..)
if( inventory:getItemCount(0) > 58 ) then
loadPaths("ravenfell_sellnpcl"); end
Isnt it true that inventory:getItemCount(0) returns the value of total items occupied in the bag?
How can i solve my problem?
HI!
You have 2 issues here.... lets analyze!
1. did you test inventory:getItemCount(0) ? try printf(inventory:getItemCount(0));
--> It returns the number of empty spaces, thus it solves your problem!
2. If it returned the number of occupied slot it would work fine if you have a 60 items back, to account for any bagsize you should use a variable that gives you the bag sizea dn decrease it by 3 instead of "58".
Use:
Code: Select all
if( inventory:getItemCount(0) < 4 ) then
loadPaths("ravenfell_sellnpcl");
end
EDIT: I'm guessing 0 stands for "Empty space" item-ID.
Re: [Question: Unanswered] If free Inventory<3 goto X
Posted: Fri Nov 05, 2010 9:56 pm
by rock5
jduartedj wrote:Code: Select all
if( inventory:getItemCount(0) < 4 ) then
loadPaths("ravenfell_sellnpcl");
end
Because of the '<' symbol that probably wont work. You can just flip it around, though, like this.
Code: Select all
if( 4 > inventory:getItemCount(0) ) then
loadPaths("ravenfell_sellnpcl");
end
jduartedj wrote:EDIT: I'm guessing 0 stands for "Empty space" item-ID.
That is correct. getItemCount can accept a name or id but because empties have a '<' symbol in their names ("<EMPTY>") using the name will cause problems so we can just use the empty id, which is "0", instead.
Re: [Question: Unanswered] If free Inventory<3 goto X
Posted: Fri Nov 05, 2010 11:13 pm
by jduartedj
Thx for that correction, rock!
I didn't know that lua didn't support that symbol because I never used it in lua, yet it seemed logical that if > worked then < would too. But thanks for that!
Hope you have a better botting XP now, Gold!
Re: [Question: Unanswered] If free Inventory<3 goto X
Posted: Fri Nov 05, 2010 11:30 pm
by rock5
Lua supports '<' just fine so you can use them in .lua documents. It is because it is in an .xml document that it causes trouble. It gets interpreted as a beginning of a tag so you get a "malformed tag" error.
There are 2 ways to avoid it.
1. Use CDATA tags eg.
Code: Select all
<waypoint x="nnnn" z="nnnnn"><![CDATA[
-- Lua code here with '<' symbols
]]></waypoint >
2. Or just flip the condition around so instead of
you use
Or instead of using
you use
Re: [Question: Answered] If free Inventory<3 goto X
Posted: Sat Nov 06, 2010 3:47 pm
by Germangold
thanks guys!
new implemented code works like a cHARM
