Page 1 of 1

Print Buff to File

Posted: Wed Sep 07, 2011 3:20 pm
by sdude13
For the current event it's nice to login with every character and get the story-buff.
before login next tron i'd like to print it to a file.
So after all characters are done, i can check the list an login the correct character.
How can I actually print the right buff to the file (not all buffs if possible only the story buff).

Waypoint

Code: Select all

		player:target_NPC(119137);
		player:rest(2);
		sendMacro("ChoiceOption(2);"); -- get Buff
		player:rest(2);
		player:update();
		local filename = getExecutionPath() .. "/logs/buffs.log";
		local file, err = io.open(filename, "a+");
		if file then
			file:write(" Character name: " ..player.Name.. ". \tDate: " .. os.date() .. ". \t Buff: ".. THEBUFF .. "\n")
			file:close();
		end
               sendMacro("}LoginNextToon=true;a={")
               sendMacro("Logout();");
               waitForLoadingScreen();
		player = CPlayer.new();
		settings.load();
		settings.loadProfile("xxxxxx");
                loadPaths("xxxx");

Re: Print Buff to File

Posted: Wed Sep 07, 2011 6:57 pm
by lisa
untested but something like this, not sure if the buff is story or Story, could probably make it lower I guess then it won't matter.

userfunction

Code: Select all

function logbuffevent()
	local filename = getExecutionPath() .. "/logs/eventbuff.log";
	local file, err = io.open(filename, "a+");
	for i, buff in pairs(player.Buffs) do
		if string.find("story", string.lower(buff)) then
			if file then
				file:write(" Character name: " ..player.Name.. "   \tDate: " .. os.date() .. " Buff: "..buff.."\n")
				file:close();
			end
		end
	end
end

in WP

Code: Select all

logbuffevent()
sendMacro("}LoginNextToon=true;a={")
sendMacro("Logout();");
waitForLoadingScreen();
This is under the assumption the buff has "story" in it, I can't remember if it does or not.
If it doesn't then you will need to create a table of all of the buff names and do a search of the buff names against the players current buffs. Little bit more involved but still very doable.

Re: Print Buff to File

Posted: Thu Sep 08, 2011 12:59 am
by sdude13
thx so far, however i get the problem with the table:

[string "..."]:6: bad argument #1 to 'lower' (string expected, got table)

Re: Print Buff to File

Posted: Thu Sep 08, 2011 1:05 am
by rock5
Try changing

Code: Select all

string.lower(buff)
to

Code: Select all

string.lower(buff.Name)

Re: Print Buff to File

Posted: Thu Sep 08, 2011 1:23 am
by sdude13
no error but also no output:

i changed to:

Code: Select all

 file:write(" Character name: " ..player.Name.. "   \tDate: " .. os.date() .. " Buff: "..buff.Name.."\n")
that seems to work
if i disable the

Code: Select all

if if string.find("erz", string.lower(buff.Name)) then
The buff has a German Special character its called "Erzählerisches Element..."
so i tryed with "erz" and "Erz".. but none working.

Re: Print Buff to File

Posted: Thu Sep 08, 2011 1:42 am
by lisa
In english they used
Story Element
Maybe we can just do check for Element:
Also I didn't realise buff wasn't the actual name, so this should work

Code: Select all

function logbuffevent()
   local filename = getExecutionPath() .. "/logs/eventbuff.log";
   local file, err = io.open(filename, "a+");
   for i, buff in pairs(player.Buffs) do
      if string.find("Element:", buff.Name) then
         if file then
            file:write(" Character name: " ..player.Name.. "   \tDate: " .. os.date() .. " Buff: "..buff.Name.."\n")
            file:close();
         end
      end
   end
end
I did concider getting a list of all the buff id's but when I logged lots of alts and got buffs I got to over 10 different names before i stopped counting.
There is probably a list in the US forums regarding buff names and how many.

Re: Print Buff to File

Posted: Thu Sep 08, 2011 1:47 am
by sdude13
no, it seems it does not search in the String.
"Element" is not working.

I'll be away for some hours now. will try to get it work when back.

Re: Print Buff to File

Posted: Thu Sep 08, 2011 1:55 am
by lisa
Sorry had it backwards for the search =(

Tested and works.

Code: Select all

function logbuffevent()
   local filename = getExecutionPath() .. "/logs/eventbuff.log";
   local file, err = io.open(filename, "a+");
   for i, buff in pairs(player.Buffs) do
   printf(buff.Name.."\n")
      if string.find(buff.Name , "Element") then
         if file then
            file:write(" Character name: " ..player.Name.. "   \tDate: " .. os.date() .. " \tBuff: "..buff.Name.."\n")
            file:close();
         end
      end
   end
end
file print looks like this

Code: Select all

Character name: XXXXX	Date: 09/08/11 16:54:00 	Buff: Story Element: Innocent Girl

Re: Print Buff to File

Posted: Thu Sep 08, 2011 6:52 am
by sdude13
I will test it, when back at my gaming pc. I guess it works here too,
so thank you in advance !

Re: Print Buff to File

Posted: Thu Sep 08, 2011 7:01 am
by lisa
there are 3 mage buffs with Element in the name, so you may get some stray prints to the file. Wouldn't be many though.

Re: Print Buff to File

Posted: Thu Sep 08, 2011 3:21 pm
by sdude13
its working.

how can I add the current logged in "account name" to the character ?
I've seen that in some post here but did not find it any more.

Re: Print Buff to File

Posted: Thu Sep 08, 2011 7:50 pm
by lisa
wiki
So in the bot it would be like this

Code: Select all

accountname = sendMacro("GetAccountName()")