reloadAmmunition Bot.Lua error

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
Valleyguy
Posts: 100
Joined: Wed Aug 04, 2010 11:34 pm
Location: Canada

reloadAmmunition Bot.Lua error

#1 Post by Valleyguy » Mon Aug 09, 2010 8:37 am

Well i decided to try the bot with a new scout today and i set up the profile but when i put the RELOAD_AMMUNITION = arrow i am getting the following error:

scripts\rom/bot.lua:409: attempt to call method 'reloadAmmunition' (a nil value)

Code: Select all

		inventory:reloadAmmunition(ammo);
I went to 409 this is a call for another function but i cannot find this function in the inventory.lua... is this not implemented yet?
Image

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

Re: reloadAmmunition Bot.Lua error

#2 Post by rock5 » Mon Aug 09, 2010 10:09 am

Valleyguy wrote:Well i decided to try the bot with a new scout today and i set up the profile but when i put the RELOAD_AMMUNITION = arrow i am getting the following error:

scripts\rom/bot.lua:409: attempt to call method 'reloadAmmunition' (a nil value)

Code: Select all

		inventory:reloadAmmunition(ammo);
I went to 409 this is a call for another function but i cannot find this function in the inventory.lua... is this not implemented yet?
Looks like it got omitted when the new inventory system was implemented in revision 478. I wonder why.
  • 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

VoidMain
Posts: 187
Joined: Wed Apr 21, 2010 12:21 pm

Re: reloadAmmunition Bot.Lua error

#3 Post by VoidMain » Mon Aug 09, 2010 10:42 am

Hmm, my bad probably, i will update it later.

VoidMain
Posts: 187
Joined: Wed Apr 21, 2010 12:21 pm

Re: reloadAmmunition Bot.Lua error

#4 Post by VoidMain » Mon Aug 09, 2010 11:10 am

Update to latest SVN, i uploaded the fix to add the missing function and its now there, needs testing tho because i don't have any ammo using chars ATM.

Valleyguy
Posts: 100
Joined: Wed Aug 04, 2010 11:34 pm
Location: Canada

Re: reloadAmmunition Bot.Lua error

#5 Post by Valleyguy » Mon Aug 09, 2010 12:23 pm

VoidMain wrote:Update to latest SVN, i uploaded the fix to add the missing function and its now there, needs testing tho because i don't have any ammo using chars ATM.
will do i'll test it out here now i am on the scout i'll just empty his arrows and see.
Image

Valleyguy
Posts: 100
Joined: Wed Aug 04, 2010 11:34 pm
Location: Canada

Re: reloadAmmunition Bot.Lua error

#6 Post by Valleyguy » Mon Aug 09, 2010 12:31 pm

VoidMain wrote:Update to latest SVN, i uploaded the fix to add the missing function and its now there, needs testing tho because i don't have any ammo using chars ATM.
ok i tested it it seems to work but poorly ... i had 2 quivers in my bag the code opened both quivers putting 2000 arrows in my bag then during my harvest path i ran it on it kept trying to equip more arrows at every stop in the path ... it works as intended but is there a way ti identify the quantity of arrows equipped and only try to equip more if the supply equipped is say less then 150? it might stop all the extra pausing the bot is doing trying to constantly equip more arrows when the slot is full ... as well you could code not to open a quiver unless you A. try to equip any arrows in inventory already and B. slot is less then 150?

I think i'll go look at the code you just put back and see if i can figure it out...
Image

Valleyguy
Posts: 100
Joined: Wed Aug 04, 2010 11:34 pm
Location: Canada

Re: reloadAmmunition Bot.Lua error

#7 Post by Valleyguy » Mon Aug 09, 2010 12:49 pm

Code: Select all

function CInventory:getAmmunitionCount()
	self.EquipSlots[ 9 ]:update(); -- 9 Ammunition slot
	local count = self.EquipSlots[ 9 ].ItemCount;
	if count == nil then
		count = 0;
	end;
	return count;
end;

-- return is true or false. false if there was no ammunition in the bag, type is "thrown" or "arrow"

I don't think this is returning the item count properly (True / False) for the next function to use... maybe this is broken because of the other inventory changes?

Code: Select all

function CInventory:reloadAmmunition(type) 
	item = self:bestAvailableConsumable(type);
	-- if theres no ammunition, open a ammunition bag
	if not item then
		if type == "arrow" then
			openItem = self:bestAvailableConsumable("arrow_quiver");
		elseif type == "thrown" then
			openItem = self:bestAvailableConsumable("thrown_bag");
		end
		
		if not openItem then
			return false;
		end

		local checkItemName = openItem.Name;
		self:update();
		yrest(200);
		item = self:bestAvailableConsumable(type);
		if( item and checkItemName ~= item.Name ) then
			cprintf(cli.yellow, language[18], tostring(checkItemName), tostring(item.Name));
			openItem:update();
		else
			openItem:use();
			yrest( 500 ); --give time to server to respond with the opened item
		end
		
		-- after opening, update the inventory (this takes about 10 sec)
		self:update();
		
		item = self:bestAvailableConsumable(type);
	end
	
	if item then
		-- use it
		-- local unused,unused,checkItemName = RoMScript("GetBagItemInfo(" .. item.SlotNumber .. ")");
		local checkItemName = item.Name;
		item:update();
		if( checkItemName ~= item.Name ) then
			cprintf(cli.yellow, language[18], tostring(checkItemName), tostring(item.Name));
			item:update();
		else
			item:use();
		end
	end
end;
I am kinda lost in this string I don't see where your pulling in the "true / false" from function CInventory:getAmmunitionCount() first to see if it needs to continue with opening a bag quiver and equipping it ... I am a back seat amateur coder so maybe i'll leave this to someone that knows this snippet better...

from what i can tell function CInventory:getAmmunitionCount() checks to see if i have ammo equipped = True / False .. then function CInventory:reloadAmmunition(type) goes about trying to equip ammo... it should work this way but it seems to be ignoring the ammo check and going to a looped repeat of the reload function...

I may be wrong like I said I am fairly new to this code learning as i go last language i worked with was FORTRAN :P
Image

VoidMain
Posts: 187
Joined: Wed Apr 21, 2010 12:21 pm

Re: reloadAmmunition Bot.Lua error

#8 Post by VoidMain » Mon Aug 09, 2010 4:28 pm

No, you looking at it in wrong sequence.

Code: Select all

-- return is true or false. false if there was no ammunition in the bag, type is "thrown" or "arrow"
function CInventory:reloadAmmunition(type)
reloadAmmunition is the function returning true or false, getAmmunitionCount returns a number and there is the problem, it was returning always 1, now its fixed and should work as expected, update to latest SVN.

Valleyguy
Posts: 100
Joined: Wed Aug 04, 2010 11:34 pm
Location: Canada

Re: reloadAmmunition Bot.Lua error

#9 Post by Valleyguy » Mon Aug 09, 2010 5:30 pm

VoidMain wrote:No, you looking at it in wrong sequence.

Code: Select all

-- return is true or false. false if there was no ammunition in the bag, type is "thrown" or "arrow"
function CInventory:reloadAmmunition(type)
reloadAmmunition is the function returning true or false, getAmmunitionCount returns a number and there is the problem, it was returning always 1, now its fixed and should work as expected, update to latest SVN.
Yea i was confused by the note placement in the code i guess lol cause i seen the result of return count and that var is usually always a number :) but the comment line threw me for a loop i guess. thanks for the fix i'll try it out soon as i log in and test it again.

Gonna go peek at your fix first its prolly gonna be a head slapper "Duh" moment for me :P
Image

Valleyguy
Posts: 100
Joined: Wed Aug 04, 2010 11:34 pm
Location: Canada

Re: reloadAmmunition Bot.Lua error

#10 Post by Valleyguy » Mon Aug 09, 2010 5:39 pm

so was slot 9 and 10 reversed (bow and ammo) ?

if so you may need to do a little fix to function "CInventory:isEquipped" as you ref slot 9 as ammo there as well ... and 10 as bow..

just FYI....
Image

VoidMain
Posts: 187
Joined: Wed Apr 21, 2010 12:21 pm

Re: reloadAmmunition Bot.Lua error

#11 Post by VoidMain » Mon Aug 09, 2010 5:47 pm

Valleyguy wrote:so was slot 9 and 10 reversed (bow and ammo) ?

if so you may need to do a little fix to function "CInventory:isEquipped" as you ref slot 9 as ammo there as well ... and 10 as bow..

just FYI....
No, its ok there:

Code: Select all

elseif (_space == "ammo") then
		slot = 10;
	elseif (_space == "bow") then
		slot = 11;

Post Reply

Who is online

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