Page 1 of 1
code to change channel after killin a mob
Posted: Mon Oct 25, 2010 7:36 am
by bankaikid
i found on this forum the code to change channel, but i dont manage to make it work for my bot (goal is to farm a specific mob, loot it and change chanel every time it's killed ):
<onLeaveCombat><![CDATA[
sendMacro("ChangeParallelID(1)");
]]></onLeaveCombat>
is workin, but what i try to do is like :
<onLeaveCombat><![CDATA[
if( 1 = GetCurrentParallelID() )then sendMacro("ChangeParallelID(2)");
else sendMacro("ChangeParallelID(1)");
]]></onLeaveCombat>
and this one doesnt work. where is the mistake, i need some help ?
edit : in the end
<onLeaveCombat><![CDATA[
sendMacro("ChangeParallelID(1)");
sendMacro("ChangeParallelID(2)");
]]></onLeaveCombat>
works fine, but now the issue is i change channel before looting, is there a code for loot i could use before ?
Re: code to change channel after killin a mob
Posted: Mon Oct 25, 2010 8:22 am
by swietlowka
Re: code to change channel after killin a mob
Posted: Mon Oct 25, 2010 8:43 am
by bankaikid
i didnt seen, thx for the link.
but it doesnt solve the actual problem, i can already change channel after killing the mob i want, but it change channel before looting it ! rest function just make it wait before changing chan
what i need is code to say "loot mob" before the "sendMacro("ChangeParallelID(1)");"
Re: code to change channel after killin a mob
Posted: Mon Oct 25, 2010 8:47 am
by swietlowka
oh, i didnt see anything about it in previouse post, maybe i didnt get u well

i would go for player:loot(); and then switch channel function in the onleavecombat section
Re: code to change channel after killin a mob
Posted: Mon Oct 25, 2010 9:11 am
by bankaikid
thx !!! it was that one "player:loot();" i was lookin for , it works now !
Re: code to change channel after killin a mob
Posted: Mon Oct 25, 2010 6:55 pm
by rock5
bankaikid wrote:Code: Select all
<onLeaveCombat><![CDATA[
if( 1 = GetCurrentParallelID() )then sendMacro("ChangeParallelID(2)");
else sendMacro("ChangeParallelID(1)");
]]></onLeaveCombat>
BTW, I can tell you how to fix this, for future reference.
1. When making comparisons you use '==' not '='.
2. 'If' statements finish with an 'end'.
3. 'GetCurrentParallelID' is an ingame function so you need to use RoMScript or sendMacro.
So this should work.
Code: Select all
<onLeaveCombat><![CDATA[
if( 1 == RoMScript("GetCurrentParallelID()") ) then sendMacro("ChangeParallelID(2)");
else sendMacro("ChangeParallelID(1)"); end
]]></onLeaveCombat>
Re: code to change channel after killin a mob
Posted: Tue Oct 26, 2010 1:34 am
by Giram
Does it work differently if you write those commands inside cdata tags? I have always written my code outside of cdata tags.
Re: code to change channel after killin a mob
Posted: Tue Oct 26, 2010 7:15 pm
by rock5
Giram wrote:Does it work differently if you write those commands inside cdata tags? I have always written my code outside of cdata tags.
I don't think so. I also don't use cdata tags. I believe the main advantage to using them is you don't get errors when using xml symbols like '<' in your lua code. (Don't quote me though)
Re: code to change channel after killin a mob
Posted: Tue Oct 26, 2010 8:25 pm
by Administrator
Yes, CDATA tags are just to prevent any confusion in the XML parser when using certain symbols (such as '<'). Any code that is longer than a few lines should probably be inside CDATA tags, but it is not necessary.