question get bag item count

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
swietlowka
Posts: 316
Joined: Wed Jun 16, 2010 8:16 am

question get bag item count

#1 Post by swietlowka » Fri Jan 14, 2011 4:05 am

when i use:

Code: Select all

occupiedSlots, totalSlots = sendMacro("GetBagCount();");
sometimes i get an error that i cannot sompare unmber with nil value, since i use it like this:

Code: Select all

if occupiedSlots <60 blah blah
the only thing that vould be nil is occupiedSlots... so my question is can i use it like that for this purpose

Code: Select all

local occupiedSlots = sendMacro("GetBagCount();"); repeat until occupiedSlots
will that fix those errors? i dont use totalSlots anywhere... is it needed there?

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

Re: question get bag item count

#2 Post by jduartedj » Fri Jan 14, 2011 5:08 am

swietlowka wrote:when i use:

Code: Select all

occupiedSlots, totalSlots = sendMacro("GetBagCount();");
sometimes i get an error that i cannot sompare unmber with nil value, since i use it like this:

Code: Select all

if occupiedSlots <60 blah blah
the only thing that vould be nil is occupiedSlots... so my question is can i use it like that for this purpose

Code: Select all

local occupiedSlots = sendMacro("GetBagCount();"); repeat until occupiedSlots
will that fix those errors? i dont use totalSlots anywhere... is it needed there?
What you want should be this:

Code: Select all

repeat local occupiedSlots = sendMacro("GetBagCount();"); until occupiedSlots
but why not use

Code: Select all

inventory:itemTotalCount(0);
?

this counts empty spaces!
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

swietlowka
Posts: 316
Joined: Wed Jun 16, 2010 8:16 am

Re: question get bag item count

#3 Post by swietlowka » Fri Jan 14, 2011 5:09 am

lol never though of that lol...
but is

Code: Select all

inventory:itemTotalCount(0);
error proof? i mean like nil value or such?

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

Re: question get bag item count

#4 Post by jduartedj » Fri Jan 14, 2011 5:12 am

swietlowka wrote:lol never though of that lol...
but is

Code: Select all

inventory:itemTotalCount(0);
error proof? i mean like nil value or such?
Guessing it was done by a developer I'd say YES! Never gave me 1 error... ever!
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
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: question get bag item count

#5 Post by lisa » Fri Jan 14, 2011 5:17 am

swietlowka wrote:

Code: Select all

if occupiedSlots <60 blah blah
Just wanted to point out u are better off using > and not <, it can mess up

Code: Select all

if 60 > occupiedSlots then ......
Even though this won't help your problem, it is good to know.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

swietlowka
Posts: 316
Joined: Wed Jun 16, 2010 8:16 am

Re: question get bag item count

#6 Post by swietlowka » Fri Jan 14, 2011 5:41 am

was posting out of head without my script ofc i have 60 > blah blah, and i would use reapet local blah blah,
nice to know it doesnt give errors ;) ill test that out tonight :d

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

Re: question get bag item count

#7 Post by rock5 » Fri Jan 14, 2011 7:19 am

jduartedj wrote:

Code: Select all

repeat local occupiedSlots = sendMacro("GetBagCount();"); until occupiedSlots
That should be

Code: Select all

local occupiedSlots
repeat occupiedSlots = sendMacro("GetBagCount();"); until occupiedSlots
Otherwise the 'occupiedSlots' value wont leave the 'repeat' loop.
swietlowka wrote:lol never though of that lol...
but is

Code: Select all

inventory:itemTotalCount(0);
error proof? i mean like nil value or such?
Any functions that read values from memory are more reliable. sendMacro (and RoMScript) can, as you've discovered, sometimes fail and return nil. So if you are ever using them and nil is not a possible value then use the repeat loop trick above. Although it might be better to use "until thevalue ~= nil" to cover functions that return true or false.
  • 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

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests