printf

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
S3v3n11
Posts: 91
Joined: Thu Jul 09, 2009 7:37 am

printf

#1 Post by S3v3n11 » Mon Oct 19, 2009 6:02 pm

Simple question. I am trying to print out the count of an item in my bags.

Code: Select all

    itemCount = inventory:getItemCount(204833);
   
   printf ("We have %d tools\n", itemCount );
I am getting the error:
scripts\rom\inv.lua:37: bad argument #1 to 'printf' (got nil)
Any ideas?

S3v3n11
Posts: 91
Joined: Thu Jul 09, 2009 7:37 am

Re: printf

#2 Post by S3v3n11 » Mon Oct 19, 2009 6:18 pm

I think I know what is going on. itemCount is not getting set properly.

Code: Select all

inventory = CInventory();


	while(true) do

    if( keyPressedLocal(key.VK_SPACE) ) then
      break;
    end
    
    itemCount = inventory:getItemCount(204833);
    
   
   printf ("We have %d tools\n", itemCount );


		yrest(100);
	end


end
Here is my code snippet. Can someone tell me what I am doing wrong when I am trying to get the items counts for that item?

TIA!

User avatar
droppen
Posts: 179
Joined: Mon Aug 03, 2009 10:32 pm

Re: printf

#3 Post by droppen » Mon Oct 19, 2009 6:29 pm

try

Code: Select all

RoMScript("GetBagItemCount("..itemId..")");
if that don't work, theres something wrong with the function that inventory has.

you can allso try

Code: Select all

itemTotalCount(itemNameOrId)
this function uses the bot's saved values of the item. for that you need to run inventory:update() first

S3v3n11
Posts: 91
Joined: Thu Jul 09, 2009 7:37 am

Re: printf

#4 Post by S3v3n11 » Mon Oct 19, 2009 6:55 pm

That does not seem to work either. Anyone have an example of

Code: Select all

inventory:getItemCount(204833)
that works?

Or some other way I can get inventory item counts?

Thanks!

User avatar
droppen
Posts: 179
Joined: Mon Aug 03, 2009 10:32 pm

Re: printf

#5 Post by droppen » Mon Oct 19, 2009 7:29 pm

S3v3n11 wrote:That does not seem to work either. Anyone have an example of

Code: Select all

inventory:getItemCount(204833)
that works?

Or some other way I can get inventory item counts?

Thanks!
as i said,

Code: Select all

inventory:update();
local count = inventory:getItemTotalCount(204833);

d003232
Posts: 1252
Joined: Wed Jun 03, 2009 4:27 pm

Re: printf

#6 Post by d003232 » Tue Oct 20, 2009 12:50 am

S3v3n11 wrote:That does not seem to work either. Anyone have an example of

Code: Select all

inventory:getItemCount(204833)
that works?

Or some other way I can get inventory item counts?

Thanks!
At which time or coding place are you doing that item count?
As droppen said, 'Inventory:getItemCount(itemId)' is the same as 'RoMScript("GetBagItemCount("..itemId..")");' and reads the value directly from the client. And it would return 0 if the item id isn't found.

e.g. test it with

Code: Select all

	<onLoad>
		-- Additional Lua code to execute after loading the profile
		-- and before the bot starts. e.g. You could overwrite profile settings here
		-- like: changeProfileOption("HP_REST", 60);
		printf("TEST: %s\n", inventory:getItemCount(454545) );

	</onLoad>
in the profiles onLoad event. You should get a 'TEST: 0' printout.
The RoM Bot Online Wiki needs your help!

User avatar
droppen
Posts: 179
Joined: Mon Aug 03, 2009 10:32 pm

Re: printf

#7 Post by droppen » Wed Oct 21, 2009 10:27 pm

actually, inventory:getItemTotalCount(204833); uses the bot's database of the items you have, it does not read the item count directly from the game, thats why you need to update inventory to have accurate data.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests