Page 1 of 2

scripts\rom/bot.lua:681: bad argument #1

Posted: Thu Jan 31, 2013 2:25 pm
by abron1
keep getting this error on my wd/s but my m/p is running the same waypoint.

11:18am - scripts\rom/bot.lua:681: bad argument #1 to 'lower' (string expected,
got boolean)

i tried to run them at the same time i get this error on the second character

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Thu Jan 31, 2013 2:34 pm
by rock5
You set RELOAD_AMMUNITION to "true" in your profile but it's supposed to be "false", "arrow" or "thrown".

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Thu Jan 31, 2013 3:34 pm
by abron1
ok thanks rock

now why is it a option to set to true or false if i might ask?

because i use this and for some reason its not equiping the arrows

Code: Select all

if 999 > inventory:itemTotalCount("Runic Thorn") then
	inventory:useItem(212236) -- Use Rune Catapult 
	yrest(1000)
	RoMScript("UseEquipmentItem(10);")
	yrest(1000)
	inventory:useItem(213403) -- Use Shamrock Feather Bow
	yrest(1000)
	end

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Fri Feb 01, 2013 1:58 am
by rock5
I believe UseEquipmentItem(10) is the ammunition. Try 11. You may have got 10 from the bot but the bot uses different numbers.

If you wait for the bot to equip, it only checks the ammo every main bot loop. So that is not even after every fight. If you have to have arrows I would add a onPreSkillCast check, code copied from the bot

Code: Select all

				if inventory:getAmmunitionCount() == 0 then
					inventory:reloadAmmunition("arrow");
				end

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Fri Feb 01, 2013 2:37 am
by lisa
abron1 wrote:because i use this and for some reason its not equiping the arrows
that code you posted is fine as it is, it will create the arrows, the bot should be using arrows as it needs them, as long as you set the profile option correctly.

Code: Select all

<option name="RELOAD_AMMUNITION" 	value="arrow" />

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Fri Feb 01, 2013 3:01 am
by rock5
You're right. I was looking at a different command. So even the in-game functions use different numbers.

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Fri Feb 01, 2013 3:08 am
by lisa
code he posted switches ranged weapon and then uses the ranged weapon which creates the arrows and then switches the weapon back. So that code is fine.

The game itself used to equip arrows as it needed them, you would do an attack after running out and then the next time you try to attack it would equip arrows it found in inventory. Not sure if that changed at any stage, been a long time since I have gone through 999 arrows while playing manually.

Just tested it by splitting stacks with just 1 arrow and then manually attacking, it autoequiped more arrows.

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Fri Feb 01, 2013 3:26 am
by rock5
lisa wrote:code he posted switches ranged weapon and then uses the ranged weapon which creates the arrows and then switches the weapon back. So that code is fine.
I'm aware of that. The confusion was because I saw another command "EquipItem" uses 11 for the ranged weapon. Yeah, so, different in-game functions use different numbers.
lisa wrote:The game itself used to equip arrows as it needed them, you would do an attack after running out and then the next time you try to attack it would equip arrows it found in inventory.
You're right. Didn't think about (forgot about) that.

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Fri Feb 01, 2013 3:51 am
by abron1
thanks guys i got it going now with your help

next question is it possible for the bot not try to reload the ammo if there is not a scout class there... because of the three classes there are times you use the same profile but not with the scout class.. and the bot will try to reload arrows and because you don't have the scout in the combo it will just keep spamming trying to reload and causes your game to freeze up or run very slow...

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Fri Feb 01, 2013 4:11 am
by lisa
TBH I don't think the bot needs to reload arrows because the game does it automatically, well for scout as main class, not sure about scout as second class.

Could add in a class check in the reload ammo code I guess.
Pretty sure only scouts can use arrows, so class1 or class2 has to be scout in order to use them.

Just tested on a */S and it reloaded arrows automatically, so don't really need to reload arrows at all, well IMHO anyway.

Actually I remember now, it reloads an arrow that you had previously, if no arrow in the ammo slot then it doesn't put in an arrow.

So maybe something like this?

Code: Select all

		-- reloading ammunition
		if ( settings.profile.options.RELOAD_AMMUNITION ) then
			local ammo = string.lower(settings.profile.options.RELOAD_AMMUNITION);
			if  ammo == "thrown" then
				if inventory:getAmmunitionCount() == 0 then
					inventory:reloadAmmunition(ammo);
				end
			elseif ammo == "arrow" and (player.Class2 == CLASS_SCOUT or player.Class1 == CLASS_SCOUT) then
				if inventory:getAmmunitionCount() == 0 then
					inventory:reloadAmmunition(ammo);
				end	
			else
			    print("RELOAD_AMMUNITION can only be false, arrow or thrown!");
			end
		end

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Fri Feb 01, 2013 4:30 am
by rock5
There are 2 situations that the bot needs to equip the arrows, that I can think of. 1. is if you don't already have ammo equipped, eg. if you run out of arrows then later acquire some or if you use a Rune weapon so you always start with no arrows equipped. 2. If you run out of the arrows you are using and you need to equip some other type of arrows you have in your inventory.

Ah, looks like you figured it out while I was writing.

Code looks good. I wonder, do we need to do a check for class for the thrown ammo too?

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Fri Feb 01, 2013 4:39 am
by lisa
rock5 wrote:do we need to do a check for class for the thrown ammo too?
thrown is just rogue?

Code: Select all

		-- reloading ammunition
		if ( settings.profile.options.RELOAD_AMMUNITION ) then
			local ammo = string.lower(settings.profile.options.RELOAD_AMMUNITION);
			if  ammo == "thrown" and (player.Class2 == CLASS_ROGUE or player.Class1 == CLASS_ROGUE) then
				if inventory:getAmmunitionCount() == 0 then
					inventory:reloadAmmunition(ammo);
				end
			elseif ammo == "arrow" and (player.Class2 == CLASS_SCOUT or player.Class1 == CLASS_SCOUT) then
				if inventory:getAmmunitionCount() == 0 then
					inventory:reloadAmmunition(ammo);
				end	
			else
			    print("RELOAD_AMMUNITION can only be false, arrow or thrown!");
			end
		end

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Fri Feb 01, 2013 5:03 am
by rock5
An extra complication occurs to me. With Rogue as second class the Projectile Training skill is only available at level 12. So maybe

Code: Select all

        if  ammo == "thrown" and (player.Class1 == CLASS_ROGUE or (player.Class2 == CLASS_ROGUE and player.Level > 11 and player.Level2 > 11)) then

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Fri Feb 01, 2013 5:19 am
by lisa
So this?

Code: Select all

		-- reloading ammunition
		if ( settings.profile.options.RELOAD_AMMUNITION ) then
			local ammo = string.lower(settings.profile.options.RELOAD_AMMUNITION);
			if  ammo == "thrown" and (player.Class1 == CLASS_ROGUE or (player.Class2 == CLASS_ROGUE and player.Level > 11 and player.Level2 > 11)) then
				if inventory:getAmmunitionCount() == 0 then
					inventory:reloadAmmunition(ammo);
				end
			elseif ammo == "arrow" and (player.Class2 == CLASS_SCOUT or player.Class1 == CLASS_SCOUT) then
				if inventory:getAmmunitionCount() == 0 then
					inventory:reloadAmmunition(ammo);
				end	
			else
			    print("RELOAD_AMMUNITION can only be false, arrow or thrown!");
			end
		end

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Fri Feb 01, 2013 7:18 am
by rock5
Yep, looks good.

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Sat Feb 02, 2013 9:45 pm
by abron1
ok cool so am i to add this or are you guys going to add it to the bot?

and can we do a inventory check for the rune bow or xbow to use and make arrows in this code also. So if we don't have arrows in the backpack and we have rune bow or xbox then use and equip arrows?

and while we are at it. The posion the bot only buys the one used by s/r and not the one used by all rogues.

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Sat Feb 02, 2013 9:50 pm
by lisa
abron1 wrote:ok cool so am i to add this or are you guys going to add it to the bot?

and while we are at it. The posion the bot only buys the one used by s/r and not the one used by all rogues.
looks like I commited it in 747 ;)

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Sat Feb 02, 2013 9:56 pm
by abron1
hahha you fast

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Sat Feb 02, 2013 10:14 pm
by lisa
nah do that in your profile for that character, out of the 100000's of */S or S/* out there less than half would actually have a bow to make arrows.

Code: Select all

	<onLoad><![CDATA[
	if 999 > inventory:itemTotalCount("Runic Thorn") then
		inventory:useItem(212236) -- rune war bow, can't remember which
		yrest(1000)
		RoMScript("UseEquipmentItem(10);")
		yrest(1000)
		inventory:useItem(212871) -- actual bow you use
		yrest(1000)
	end
	]]></onLoad>
and same again in the onleavecombat.

Re: scripts\rom/bot.lua:681: bad argument #1

Posted: Mon Feb 04, 2013 3:35 am
by abron1
would this code work not sure how to use the "or" in my codes

Code: Select all

if player.Class1 == CLASS_SCOUT or player.Class2 == CLASS_SCOUT then
	if 1 > inventory:itemTotalCount("Rune Catapult" or "Rune War Bow") then
	if 999 > inventory:itemTotalCount("Runic Thorn") then
	inventory:useItem(212236) or inventory:useItem(212183) -- Use Rune Catapult or Rune War Bow
	yrest(1000)
	RoMScript("UseEquipmentItem(10);")
	yrest(1000)
	inventory:useItem(213403) -- Use Shamrock Feather Bow
	yrest(1000)
	inventory:useItem(212185) -- Use Arrows
	end