changing profile option, friend and mob

Additional botting resources. Addons may be either for the game itself or for the RoM bot.
Forum rules
Only post additional bot resources here. Please do not ask unrelated questions.
Message
Author
User avatar
lisa
Posts: 8330
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

changing profile option, friend and mob

#1 Post by lisa » Mon Mar 12, 2012 2:00 am

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 998 times
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
silinky
Posts: 213
Joined: Mon Nov 23, 2009 5:07 am

Re: changing profile option, friend and mob

#2 Post by silinky » Mon Mar 12, 2012 2:29 am

thankies!
exactly what i was looking for :)

Louis
Posts: 22
Joined: Sat Dec 17, 2011 4:52 pm

Re: changing profile option, friend and mob

#3 Post by Louis » Sun Apr 29, 2012 1:43 am

thanks :)

User avatar
Ego95
Posts: 564
Joined: Tue Feb 28, 2012 12:38 pm
Contact:

Re: changing profile option, friend and mob

#4 Post by Ego95 » Sun Jul 22, 2012 12:05 pm

How do i use it, if i want to change a a skill in the wp onload?

User avatar
gloover
Posts: 304
Joined: Wed Jul 07, 2010 4:31 am

Re: changing profile option, friend and mob

#5 Post by gloover » Sun Jul 22, 2012 5:42 pm

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.

User avatar
Ego95
Posts: 564
Joined: Tue Feb 28, 2012 12:38 pm
Contact:

Re: changing profile option, friend and mob

#6 Post by Ego95 » Sun Jul 22, 2012 7:20 pm

Thank you :)

User avatar
lisa
Posts: 8330
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: changing profile option, friend and mob

#7 Post by lisa » Tue Mar 05, 2013 1:26 am

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
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: changing profile option, friend and mob

#8 Post by rock5 » Tue Mar 05, 2013 1:37 am

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.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
lisa
Posts: 8330
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: changing profile option, friend and mob

#9 Post by lisa » Tue Mar 05, 2013 2:11 am

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.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

C3PO
Posts: 109
Joined: Sun Jul 10, 2011 2:45 pm

Re: changing profile option, friend and mob

#10 Post by C3PO » Fri Apr 05, 2013 2:17 am

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")

User avatar
lisa
Posts: 8330
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: changing profile option, friend and mob

#11 Post by lisa » Fri Apr 05, 2013 3:11 am

yes you are correct, a copy/paste failure ;)
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

C3PO
Posts: 109
Joined: Sun Jul 10, 2011 2:45 pm

Re: changing profile option, friend and mob

#12 Post by C3PO » Fri Apr 05, 2013 5:40 am

... 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?

User avatar
lisa
Posts: 8330
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: changing profile option, friend and mob

#13 Post by lisa » Fri Apr 05, 2013 8:42 am

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.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: changing profile option, friend and mob

#14 Post by rock5 » Fri Apr 05, 2013 9:22 am

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.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

C3PO
Posts: 109
Joined: Sun Jul 10, 2011 2:45 pm

Re: changing profile option, friend and mob

#15 Post by C3PO » Fri Apr 05, 2013 3:12 pm

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

C3PO
Posts: 109
Joined: Sun Jul 10, 2011 2:45 pm

Re: changing profile option, friend and mob

#16 Post by C3PO » Sat Apr 06, 2013 7:15 am

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 ...

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: changing profile option, friend and mob

#17 Post by rock5 » Sat Apr 06, 2013 8:18 am

Can I have a look at your relogging code?
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

C3PO
Posts: 109
Joined: Sun Jul 10, 2011 2:45 pm

Re: changing profile option, friend and mob

#18 Post by C3PO » Sun Apr 07, 2013 4:10 am

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

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: changing profile option, friend and mob

#19 Post by rock5 » Sun Apr 07, 2013 7:03 am

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.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
lisa
Posts: 8330
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: changing profile option, friend and mob

#20 Post by lisa » Sun Apr 07, 2013 6:08 pm

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.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest