[Question: Answered] If free Inventory<3 goto X

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
Germangold
Posts: 276
Joined: Thu Oct 22, 2009 3:58 am

[Question: Answered] If free Inventory<3 goto X

#1 Post by Germangold » Fri Nov 05, 2010 3:03 pm

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?
Last edited by Germangold on Sat Nov 06, 2010 3:46 pm, edited 1 time in total.

User avatar
jduartedj
Posts: 599
Joined: Sat Dec 19, 2009 12:18 am
Location: Lisbon
Contact:

Re: [Question: Unanswered] If free Inventory<3 goto X

#2 Post by jduartedj » Fri Nov 05, 2010 6:01 pm

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.
Thanks for reading! :D

Some of you might find this useful: RoM-bot Wiki
User Functions Repository (and other useful files): Addon Repo
Latest SVN updates: SVN updates

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: [Question: Unanswered] If free Inventory<3 goto X

#3 Post by rock5 » Fri Nov 05, 2010 9:56 pm

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.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
jduartedj
Posts: 599
Joined: Sat Dec 19, 2009 12:18 am
Location: Lisbon
Contact:

Re: [Question: Unanswered] If free Inventory<3 goto X

#4 Post by jduartedj » Fri Nov 05, 2010 11:13 pm

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!
Thanks for reading! :D

Some of you might find this useful: RoM-bot Wiki
User Functions Repository (and other useful files): Addon Repo
Latest SVN updates: SVN updates

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: [Question: Unanswered] If free Inventory<3 goto X

#5 Post by rock5 » Fri Nov 05, 2010 11:30 pm

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

Code: Select all

if a < b then
you use

Code: Select all

if b > a then
Or instead of using

Code: Select all

if a <= b then
you use

Code: Select all

if b >= a then
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Germangold
Posts: 276
Joined: Thu Oct 22, 2009 3:58 am

Re: [Question: Answered] If free Inventory<3 goto X

#6 Post by Germangold » Sat Nov 06, 2010 3:47 pm

thanks guys!

new implemented code works like a cHARM :)

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests