Page 1 of 2

changing profile option, friend and mob

Posted: Mon Mar 12, 2012 2:00 am
by lisa
For some reason I thought this was already posted, guess not lol



changeOptionFriendMob(arg1, arg2, arg3)
arg1 = "mob" or "friend"
arg2 = name of what ever your adding or removing from list
arg3 = "Add" or "Remove"

Code: Select all

changeOptionFriendMob("mob", "Wolf", "Add") 
changeOptionFriendMob("friend", "Hokeypokey", "Remove")
Add file to rom/userfunctions/
userfunction_profilechange.lua
V 1.1 checks if name exists before adding it again.
(1.63 KiB) Downloaded 1134 times

Re: changing profile option, friend and mob

Posted: Mon Mar 12, 2012 2:29 am
by silinky
thankies!
exactly what i was looking for :)

Re: changing profile option, friend and mob

Posted: Sun Apr 29, 2012 1:43 am
by Louis
thanks :)

Re: changing profile option, friend and mob

Posted: Sun Jul 22, 2012 12:05 pm
by Ego95
How do i use it, if i want to change a a skill in the wp onload?

Re: changing profile option, friend and mob

Posted: Sun Jul 22, 2012 5:42 pm
by gloover

Code: Select all

changeProfileSkill("YOUR_SKILL", "AutoUse", true);
 or something like this
changeProfileSkill("YOUR_SKILL", "pullonly", true);
depending on what you want to do with your skill options.

Re: changing profile option, friend and mob

Posted: Sun Jul 22, 2012 7:20 pm
by Ego95
Thank you :)

Re: changing profile option, friend and mob

Posted: Tue Mar 05, 2013 1:26 am
by lisa
Rock mentioned about going back to the profile default values, try this out.

Code: Select all

--=== Created by Lisa 	===--
--=== 		V 1.2 		===--

local oldfriends , oldmobs


function changeOptionFriendMob(_type,_name,_addremove)

--examples	changeOptionFriendMob("mob", "Wolf", "Add")
--examples	changeOptionFriendMob("friend", "Hokeypokey", "Remove")
--examples	changeOptionFriendMob("friend", "reset") 	-- goes back to profile for friend
--examples	changeOptionFriendMob("mob", "reset")		-- goes back to profile for mob

	if _name == nil or _name == "" then
		printf("Need to specify name.\n")
	end

	if _addremove == nil then _addremove = "add" end
	
	addremove = string.lower(_addremove)
	
	if addremove ~= "add" and addremove ~= "remove" then
		printf("Wrong usage of arg#3, _addremove")
	end

	if( _name ) then name = trim(_name) end;
	if _type == "friend" then 
		if oldfriends == nil then
			oldfriends = settings.profile.friends
		end	
		if _name == "reset" then
			settings.profile.friends = oldfriends
			return
		end
		if addremove == "add" then 
			for k,v in ipairs(settings.profile.friends) do
				if v == name then return end
			end
			table.insert(settings.profile.friends, name);
			for k,v in ipairs(settings.profile.friends) do
				printf(k.." "..v.."\n")
			end
		end

		if addremove == "remove" then 
			for k,v in ipairs(settings.profile.friends) do
				if v == name then
				table.remove(settings.profile.friends,k);
				printf("Removing friend "..v.."\n")
				end
				printf(k.." "..v.."\n")
			end
		end
	end
	if _type == "mob" then 
		if oldmobs == nil then
			oldmobs = settings.profile.mobs
		end
		if _name == "reset" then
			settings.profile.mobs = oldfriends
			return
		end
		if addremove == "add" then 
			for k,v in ipairs(settings.profile.mobs) do
				if v == name then return end
			end
			table.insert(settings.profile.mobs, name);
			for k,v in ipairs(settings.profile.mobs) do
				printf(k.." "..v.."\n")
			end
		end

		if addremove == "remove" then 
			for k,v in ipairs(settings.profile.mobs) do
				if v == name then
					table.remove(settings.profile.mobs,k);
					printf("Removing friend "..v.."\n")
				end
				printf(k.." "..v.."\n")
			end
		end	
	end
end

Re: changing profile option, friend and mob

Posted: Tue Mar 05, 2013 1:37 am
by rock5
What? No I didn't. Maybe I made you think of it.

Anyway, I see a bug in your code. What if initially the mob or friends list is empty? You go to add 1 mob. #oldmobs == 0 so it does oldmobs = settings.profile.mobs. mobs is empty so #oldmobs still == 0. It adds the mob. Then you add another mob. #oldmobs still == 0 so it does oldmobs = settings.profile.mobs which adds the first mob to oldmobs which is not what you want. The initial mob list was empty so oldmobs should remain empty.

Maybe you could start with oldmobs/friends == nil and do

Code: Select all

      if oldmobs == nil then
         oldmobs = settings.profile.mobs
      end
Then it should save an empty table too.

Re: changing profile option, friend and mob

Posted: Tue Mar 05, 2013 2:11 am
by lisa
rock5 wrote:I see a bug in your code. What if initially the mob or friends list is empty?
rock5 wrote:What? No I didn't. Maybe I made you think of it.
Yeah I missunderstood what you said in other topic, I thought you wanted to go back to profile but you wanted to completely clear the table.

Good point, I usually try to define a table if it is actually a table because of issues I've had previously when I use table.insert which you can of course only use on a table. In this case though what you said is much better because I am not using insert and I am merely backing up an existing table.

I edited the code in previous post.

Re: changing profile option, friend and mob

Posted: Fri Apr 05, 2013 2:17 am
by C3PO
Hi Lisa,

I found a little failure ;)

line 77

Code: Select all

printf("Removing friend "..v.."\n")
should be

Code: Select all

printf("Removing mob "..v.."\n")

Re: changing profile option, friend and mob

Posted: Fri Apr 05, 2013 3:11 am
by lisa
yes you are correct, a copy/paste failure ;)

Re: changing profile option, friend and mob

Posted: Fri Apr 05, 2013 5:40 am
by C3PO
... and I have an additional problem.

I made a script to do the dailies with all characters. Each time the script runs the first round it doesn't attack the mobs in the list. I put in

Code: Select all

print("fighting against:\n")
table.print(settings.profile.mobs)
print("================================\n")
to see whats in the list and it shows the correct entries. After finishing the first round manually (let the script run and attack manually) the mobs are targeted and attacked as expected.

do you have an idea what could be wrong?

Re: changing profile option, friend and mob

Posted: Fri Apr 05, 2013 8:42 am
by lisa
without knowing what and how you did it I would only be guessing, only thing comes to mind in what you said is if profile is loaded after the WP onload, which is kind of weird.
Maybe look at the profile for the first character and see if it has anything in it that might cause the issue, or just run the WP using default profile for all chars.

Re: changing profile option, friend and mob

Posted: Fri Apr 05, 2013 9:22 am
by rock5
Well if he does a loadProfile after changing the settings then that would explain it. If that is the case he just has to make sure he doesn't change the settings until after loading the profile.

Re: changing profile option, friend and mob

Posted: Fri Apr 05, 2013 3:12 pm
by C3PO
the first Char is fine, the first DQ with the 2nd, 3rd ... 8th char has the same problem (as mentioned) so the loadProfile is right before

Re: changing profile option, friend and mob

Posted: Sat Apr 06, 2013 7:15 am
by C3PO
I tried it the other way round and let the chars attack everything and if the quest is finished I change them to friends. And it happens the same way. The first Char is fine and after change to nextChar it doesn't attack till the first time.

so it looks like that the problem is not changeprofileoption but maybe nextchar ...

Re: changing profile option, friend and mob

Posted: Sat Apr 06, 2013 8:18 am
by rock5
Can I have a look at your relogging code?

Re: changing profile option, friend and mob

Posted: Sun Apr 07, 2013 4:10 am
by C3PO
these are the functions from the onLoad Section of the WP file

Code: Select all

		local function reInitPlayer()
			-- Re-initialize player
			player = CPlayer.new();
			settings.load();
			settings.loadProfile(convertProfileName("TwinkDQ"))
		end
		
		function checkDQCount()
			local dailyQuestCount, dailyQuestsPerDay= RoMScript("Daily_count()")
			
			cprintf(cli.lightblue,"%s quests completed.\n",tostring(dailyQuestCount));
			--	  if player.Level == 70 then
			--        sendMacro("Logout();"); 
			--	  end
			if (dailyQuestCount == 10) then
				cprintf(cli.lightblue,"Completed max number of daily quests, trying to use a daily reset card.\n");
				inventory:update();
				player:update();
				 
				-- note #202434 is the daily reset card
				if useDQCard == 1 and inventory:itemTotalCount(202434) > 0 and 76 >= player.Level then
					inventory:useItem(202434);
				else
					SetCharList({
						{account=19 , chars= {1,2,3,4,5,6,7,8}},
					})
					--AccountNumber = RoMScript("LogID")									--AccountName = RoMScript("GetAccountName()")
					CharacterNumber = RoMScript("CHARACTER_SELECT.selectedIndex")			--CharacterName = player.Name
					local timeval = os.date("*t")
					if CharacterNumber == 8 then
						while 6 > timeval.hour or timeval.hour > 10
						do			
							player:rest(10*60)												-- 10min pause
							timeval = os.date("*t")
						end
						ChangeChar(1, AccountNumber)						
					else
						LoginNextChar()
					end
					reInitPlayer()
					logInfo("TwinkDQ","running with " .. player.Name .. "/" .. RoMScript("GetAccountName()") .. "(" .. CharacterNumber .. "/" .. RoMScript("LogID") .. ")",true,"TwinkDQ")
					loadPaths("DQTwink");
				end
			end   
		end

Re: changing profile option, friend and mob

Posted: Sun Apr 07, 2013 7:03 am
by rock5
I don't see any code to change the friends or mobs list. Do you do it elsewhere or are you just changing the lists in the "TwinkDQ" profile?

By the way, you don't need the reInitPlayer function. You can just use

Code: Select all

loadProfile("TwinkDQ")
It does basically what your function does but it also runs the profile onload which yours doesn't.

loadProfile works just like the "profile:name" option you use when starting the bot. If you specify a profile name then it loads that. If you don't specify one, it attempts to find the profile for that "character" or, if that doesn't exist, the userdefault.xml profile.

Re: changing profile option, friend and mob

Posted: Sun Apr 07, 2013 6:08 pm
by lisa
rock5 wrote:It does basically what your function does but it also runs the profile onload which yours doesn't
So the profile onload would only be done on the first character, my guess is that the issue is there then. He said first char doesn't work but the rest do.