Page 1 of 1

use magic perfume

Posted: Thu Jan 16, 2014 3:48 am
by powerattack
hey all,

I can't seem to get my magic perfume (30 days) to auto use in my ks script...

Code: Select all

		if not player:hasBuff("Magic Perfume") then
			inventory:useItem(202879);
this is what I get when i try to run it:

Code: Select all

9:47am - scripts\rom/bot.lua:947: Failed to compile and run Lua code for waypoin
t #3
any idea's?

Re: use magic perfume

Posted: Thu Jan 16, 2014 3:59 am
by rock5
Did you add an "end" for that "if" statement?

Re: use magic perfume

Posted: Thu Jan 16, 2014 4:00 am
by powerattack

Code: Select all

		ksLog("At waypoint #1: kicking off...", LOGLEVEL_DEBUG);
		changeOptionFriendMob("mob", "IgnoreMePlease", "Add");
		unregisterTimer("KS_Timer");
		
		changeOptionFriendMob("friend", "Crow", "Add");
		changeOptionFriendMob("friend", "Valley Rock Scorpion", "Add");
		registerTimer("KS_Timer", 30000, KSCheckTiming);
		KS_StartTime = os.time();
		player:updateBuffs();
		if not player:hasBuff("May Establish Honor Party") then
			if (inventory:itemTotalCount(202879) > 0) then
				ksLog("Using Teaching scroll", LOGLEVEL_INFO);
				inventory:useItem(202879);
			end;
		end;
		
		KSApplyPots();
		
		sendMacro("/invite "..resetCharacter);
		yrest(3000);
		sendMacro("SetLootMethod(\"freeforall\")")
		KSSetLootValue();

     		if not player:hasBuff("Magic Perfume") then
     		inventory:useItem(202879);

		if (player:hasBuff("Magic Perfume")) then
			ksLog("Magic Perfume detected, disabling looting and bag checks", LOGLEVEL_INFO);
			KS_allow_loot =false; 
			KS_check_bag=true;
			KS_item_queue_size = 20;
		else
			KS_allow_loot =true; 
			KS_check_bag=true;
			KS_item_queue_size = 0;
		end;
this is what I had, now going to try with end; command

Re: use magic perfume

Posted: Thu Jan 16, 2014 8:39 am
by Ego95

Code: Select all

    if not player:hasBuff("Magic Perfume") then
		inventory:useItem(202879);
	end -- this is missing
The "end" is missing like rock said ;)

or you write the whole thing like this:

Code: Select all

    if not player:hasBuff("Magic Perfume") then
		inventory:useItem(202879);
    elseif (player:hasBuff("Magic Perfume")) then
		ksLog("Magic Perfume detected, disabling looting and bag checks", LOGLEVEL_INFO);
		KS_allow_loot =false; 
		KS_check_bag=true;
		KS_item_queue_size = 20;
    else
		KS_allow_loot =true; 
		KS_check_bag=true;
		KS_item_queue_size = 0;
    end;

Re: use magic perfume

Posted: Thu Jan 16, 2014 9:37 am
by lisa
Just thought I would poke my nose in ;)

Code: Select all

    if not player:hasBuff("Magic Perfume") then
      inventory:useItem(202879);
    elseif (player:hasBuff("Magic Perfume")) then
      ksLog("Magic Perfume detected, disabling looting and bag checks", LOGLEVEL_INFO);
      KS_allow_loot =false; 
      KS_check_bag=true;
      KS_item_queue_size = 20;
    else
      KS_allow_loot =true; 
      KS_check_bag=true;
      KS_item_queue_size = 0;
    end;
That code isn't so good, the 3rd part will never ever ever get done because the first 2 parts are true or false for the same thing. So you either have the buff or you don't have the buff and you will never do the 3rd section.

Maybe you could change it so that if you don't have the buff you try to use the item but if the item doesn't exist then change the values.

Code: Select all

    if not player:hasBuff("Magic Perfume") then
		if inventory:getItemCount(202879) ~= 0 then
			inventory:useItem(202879);
		else -- no buff and no item
			KS_allow_loot =true; 
			KS_check_bag=true;
			KS_item_queue_size = 0;	
		end
    else -- has buff
		ksLog("Magic Perfume detected, disabling looting and bag checks", LOGLEVEL_INFO);
		KS_allow_loot =false; 
		KS_check_bag=true;
		KS_item_queue_size = 20;
    end;

As for me I just put this in my profiles onleavecombat section

Code: Select all

	if not player:hasBuff(503479) then -- pet perfume 30 days
		--inventory:useItem(204514) -- 30 day
		inventory:useItem(207582) --1 day
	end	

Re: use magic perfume

Posted: Thu Jan 16, 2014 7:31 pm
by powerattack
tnx, I will try that in the morning. Its 1:30 am right now so I better fix the script with a clear head.