Page 1 of 1

Change Profile Battle-Parameter in <onload> of th WP.

Posted: Thu Jul 05, 2012 3:17 am
by gloover
Hey rock.

Is it possible to change (to add) parameter like <ondeath> or <onLeavecombat> in onload part of the WP?

Reason: I have a segment such as "changechannel" in onleavecombat in my profile using one WP, so I have allways to delete this part, using another WP (killing mobs), otherwise it would change the channel after every kill (bad thing especailly using malatina survival ;-))

so back to the question: how can I add or change those parameters in WP onload part?

thx in advance!

Re: Change Profile Battle-Parameter in <onload> of th WP.

Posted: Thu Jul 05, 2012 4:05 am
by lisa
Well I'm not rock but I may be able to help lol

Code: Select all

settings.profile.events.onLeaveCombat = function() return 
--add code here
end 

Re: Change Profile Battle-Parameter in <onload> of th WP.

Posted: Thu Jul 05, 2012 6:06 am
by BillDoorNZ
you may also want to do:

Code: Select all

oldOnLeaveCombat = settings.profile.events.onLeaveCombat;

settings.profile.events.onLeaveCombat = function()
--add code here
--call profile on leave combat
  if (oldOnLeaveCombat and (type(oldOnLeaveCombat)=='function')) then
    oldOnLeaveCombat();
  end;
end

Re: Change Profile Battle-Parameter in <onload> of th WP.

Posted: Thu Jul 05, 2012 6:28 am
by rock5
To avoid nesting of functions I ALWAYS do it like this.

Instead of

Code: Select all

oldOnLeaveCombat = settings.profile.events.onLeaveCombat;
use

Code: Select all

if oldOnLeaveCombat = nil then oldOnLeaveCombat = settings.profile.events.onLeaveCombat; end
Of course nesting only happens if you reload the file, eg. when you change characters and reload the file to run another character through it. If the file is only run once, eg. a farming script that just loops until you stop it, then you don't need to do it this way. But it's probably good practice to always do it this way.

Re: Change Profile Battle-Parameter in <onload> of th WP.

Posted: Thu Jul 05, 2012 8:51 am
by gloover
Thx guys (and ladies) - it works fine.

Now I can create a fine Boss-farming -WP