scripts\rom/bot.lua:409: attempt to call method 'reloadAmmunition' (a nil value)
Code: Select all
inventory:reloadAmmunition(ammo);
Code: Select all
inventory:reloadAmmunition(ammo);
Looks like it got omitted when the new inventory system was implemented in revision 478. I wonder why.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)
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?Code: Select all
inventory:reloadAmmunition(ammo);
will do i'll test it out here now i am on the scout i'll just empty his arrows and see.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?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.
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"
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;
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)
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.VoidMain wrote:No, you looking at it in wrong sequence.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.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)
No, its ok there: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....
Code: Select all
elseif (_space == "ammo") then
slot = 10;
elseif (_space == "bow") then
slot = 11;
Users browsing this forum: Ahrefs [Bot] and 4 guests