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