 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Sun Mar 21, 2010 6:43 pm
Local Variables not clearing? |
Here are some images:
If you look really closely in this, you can see something like:
... [ Shalonesti ] Nathaniel ...
[ Bloodlust ]
Nathaniel added
... ( Dragon ) Anbraxas ...
[ Slayers ]
Anbraxas added
This is a very inconsistent error in my new script that seems to be related to the local variables. Sometimes it doesn't error at all. However, sometimes it seems that the local variables in the script don't clear and are carrying their values over to the next entry, most notably in the variables associated with class and clan ($_sel_class) and ($_new_trim_clan), though it has also done it with rank ($_new_trim_rank). Any values not associated with a local variable (name and level) seem to be just fine.
Here's the code:
Code: |
#if (%ismember(%4, @c_name))
{
$_trim_rank = %replace(%5, "(Leader)", "")
$_trim_rank = %replace($_trim_rank, "(Recruiter)", "")
$_trim_rank = %trim($_trim_rank)
$_trim_clan = %replace(%3, "[", "")
$_trim_clan = %replace($_trim_clan, "]", "")
$_trim_clan = %replace($_trim_clan, "(", "")
$_trim_clan = %replace($_trim_clan, ")", "")
$_trim_clan = %trim($_trim_clan)
$_member_num = %ismember(%4, @c_name)
$_curr_lvl = %item(@c_lvl, $_member_num)
$_curr_class = %item(@c_class, $_member_num)
$_curr_clan = %item(@c_clan, $_member_num)
$_curr_rank = %item(@c_rank, $_member_num)
#if ($_curr_lvl != %1)
{
$_old_lvl = $_curr_lvl
#VAR c_lvl %replaceitem(%1, $_member_num, @c_lvl)
$_new_lvl = %item(@c_lvl, $_member_num)
#show "Level changed from "$_old_lvl" to "$_new_lvl" for: "%4
}
$_sel_class = "NULL"
#switch (%2)
("War") {$_sel_class = "Warrior"}
("Ran") {$_sel_class = "Ranger"}
("Bar") {$_sel_class = "Barbarian"}
("Swb") {$_sel_class = "Swashbuckler"}
("Arm") {$_sel_class = "Armsman"}
("Cle") {$_sel_class = "Cleric"}
("Cru") {$_sel_class = "Crusader"}
("Dru") {$_sel_class = "Druid"}
("Sha") {$_sel_class = "Shaman"}
("Pri") {$_sel_class = "Priest"}
("Mag") {$_sel_class = "Mage"}
("Wit") {$_sel_class = "Witch"}
("Wlk") {$_sel_class = "Warlock"}
("Ill") {$_sel_class = "Illusionist"}
("Enc") {$_sel_class = "Enchantor"}
("Brd") {$_sel_class = "Bard"}
("Jng") {$_sel_class = "Jongleur"}
("Cha") {$_sel_class = "Charlatan"}
("Skd") {$_sel_class = "Skald"}
("Thi") {$_sel_class = "Thief"}
("Asn") {$_sel_class = "Assassin"}
("Bnd") {$_sel_class = "Bandit"}
("Nsh") {$_sel_class = "Nightshade"}
("Inv") {$_sel_class = "Invoker"}
("Tra") {$_sel_class = "Transmuter"}
("Bmg") {$_sel_class = "Battlemage"}
("Nec") {$_sel_class = "Necromancer"}
("Pal") {$_sel_class = "Paladin"}
("Skn") {$_sel_class = "Shadowknight"}
("Bla") {$_sel_class = "Bladesinger"}
("Eld") {$_sel_class = "Eldritch"}
("Bat") {$_sel_class = "Battlerager"}
("Run") {$_sel_class = "Runesmith"}
("Mon") {$_sel_class = "Monk"}
("Slr") {$_sel_class = "Dragonslayer"}
("Dra") {$_sel_class = "Dragon"}
("Ang") {$_sel_class = "Angel"}
("Dem") {$_sel_class = "Demon"}
("Gia") {$_sel_class = "Giant"}
{#show "No class value found"}
#if ($_sel_class != $_curr_class)
{
$_old_class = $_curr_class
#VAR c_class %replaceitem($_sel_class, $_member_num, @c_class)
$_new_class = %item(@c_class, $_member_num)
#show "Class changed from "$_old_class" to "$_new_class" for: "%4
}
#if ($_curr_clan != $_trim_clan)
{
$_old_clan = $_curr_clan
#VAR c_clan %replaceitem($_trim_clan, $_member_num, @c_clan)
$_new_clan = %item(@c_clan, $_member_num)
#show "Clan changed from "$_old_clan" to "$_new_clan" for: "%4
}
#if ($_curr_rank != $_trim_rank)
{
$_old_rank = $_curr_rank
#VAR c_rank %replaceitem($_trim_rank, $_member_num, @c_rank)
$_new_rank = %item(@c_rank, $_member_num)
#show "Rank changed from "$_old_rank" to "$_new_rank" for: "%4
}
}
{
#ADDI c_name %4
#VAR c_lvl %additem(%1, @c_lvl)
#switch (%2)
("War") {#VAR c_class %additem("Warrior", @c_class)}
("Ran") {#VAR c_class %additem("Ranger", @c_class)}
("Bar") {#VAR c_class %additem("Barbarian", @c_class)}
("Swb") {#VAR c_class %additem("Swashbuckler", @c_class)}
("Arm") {#VAR c_class %additem("Armsman", @c_class)}
("Cle") {#VAR c_class %additem("Cleric", @c_class)}
("Cru") {#VAR c_class %additem("Crusader", @c_class)}
("Dru") {#VAR c_class %additem("Druid", @c_class)}
("Sha") {#VAR c_class %additem("Shaman", @c_class)}
("Pri") {#VAR c_class %additem("Priest", @c_class)}
("Mag") {#VAR c_class %additem("Mage", @c_class)}
("Wit") {#VAR c_class %additem("Witch", @c_class)}
("Wlk") {#VAR c_class %additem("Warlock", @c_class)}
("Ill") {#VAR c_class %additem("Illusionist", @c_class)}
("Enc") {#VAR c_class %additem("Enchantor", @c_class)}
("Brd") {#VAR c_class %additem("Bard", @c_class)}
("Jng") {#VAR c_class %additem("Jongleur", @c_class)}
("Cha") {#VAR c_class %additem("Charlatan", @c_class)}
("Skd") {#VAR c_class %additem("Skald", @c_class)}
("Thi") {#VAR c_class %additem("Thief", @c_class)}
("Asn") {#VAR c_class %additem("Assassin", @c_class)}
("Bnd") {#VAR c_class %additem("Bandit", @c_class)}
("Nsh") {#VAR c_class %additem("Nightshade", @c_class)}
("Inv") {#VAR c_class %additem("Invoker", @c_class)}
("Tra") {#VAR c_class %additem("Transmuter", @c_class)}
("Bmg") {#VAR c_class %additem("Battlemage", @c_class)}
("Nec") {#VAR c_class %additem("Necromancer", @c_class)}
("Pal") {#VAR c_class %additem("Paladin", @c_class)}
("Skn") {#VAR c_class %additem("Shadowknight", @c_class)}
("Bla") {#VAR c_class %additem("Bladesinger", @c_class)}
("Eld") {#VAR c_class %additem("Eldritch", @c_class)}
("Bat") {#VAR c_class %additem("Battlerager", @c_class)}
("Run") {#VAR c_class %additem("Runesmith", @c_class)}
("Mon") {#VAR c_class %additem("Monk", @c_class)}
("Slr") {#VAR c_class %additem("Dragonslayer", @c_class)}
("Dra") {#VAR c_class %additem("Dragon", @c_class)}
("Ang") {#VAR c_class %additem("Angel", @c_class)}
("Dem") {#VAR c_class %additem("Demon", @c_class)}
("Gia") {#VAR c_class %additem("Giant", @c_class)}
{#show "No class value found"}
$_new_trim_clan = %replace(%3, "[", "")
$_new_trim_clan = %replace($_new_trim_clan, "]", "")
$_new_trim_clan = %replace($_new_trim_clan, "(", "")
$_new_trim_clan = %replace($_new_trim_clan, ")", "")
$_new_trim_clan = %trim($_new_trim_clan)
#VAR c_clan %additem($_new_trim_clan, @c_clan)
$_new_trim_rank = %replace(%5, "(Leader)", "")
$_new_trim_rank = %replace($_new_trim_rank, "(Recruiter)", "")
$_new_trim_rank = %trim($_new_trim_rank)
#VAR c_rank %additem($_new_trim_rank, @c_rank)
$_new_member = %ismember(%4, @c_name)
$_lvl = %item(@c_lvl, $_new_member)
$_class = %item(@c_class, $_new_member)
$_rank = %item(@c_rank, $_new_member)
#switch (%item(@c_clan, $_new_member))
("Justice") {#say %ansi(7) %ansi(7)"[ "%ansi(1)"Justice"%ansi(7)" ] ["$_lvl" "$_class"] "%4" ("$_rank") - added"%ansi(reset)}
("Bloodlust") {#say %ansi(7) "[ "%ansi(4)"Bloodlust"%ansi(reset)%ansi(7)" ] ["$_lvl" "$_class"] "%4" ("$_rank") - added"%ansi(reset)}
("Knighthood") {#say %ansi(7) "[ "%ansi(9)"Knighthood"%ansi(reset)%ansi(7)" ] ["$_lvl" "$_class"] "%4" ("$_rank") - added"%ansi(reset)}
("Shadow") {#say %ansi(7) "[ "%ansi(8)"Shadow"%ansi(reset)%ansi(7)" ] ["$_lvl" "$_class"] "%4" ("$_rank") - added"%ansi(reset)}
("Slayers") {#say %ansi(7) "[ "%ansi(14)"Slayers"%ansi(reset)%ansi(7)" ]["$_lvl" "$_class"] "%4" ("$_rank") - added"%ansi(reset)}
("Conclave") {#say %ansi(7) "[ "%ansi(14)"Conclave"%ansi(reset)%ansi(7)" ]["$_lvl" "$_class"] "%4" ("$_rank") - added"%ansi(reset)}
("Red Robes") {#say %ansi(7) "[ "%ansi(12)"Red Robes"%ansi(reset)%ansi(7)" ] ["$_lvl" "$_class"] "%4" ("$_rank") - added"%ansi(reset)}
("White Robes") {#say %ansi(7) "[ "%ansi(15)"White Robes"%ansi(reset)%ansi(7)" ] ["$_lvl" "$_class"] "%4" ("$_rank") - added"%ansi(reset)}
("Black Robes") {#say %ansi(7) "[ "%ansi(8)"Black Robes"%ansi(reset)%ansi(7)" ] ["$_lvl" "$_class"] "%4" ("$_rank") - added"%ansi(reset)}
("Shalonesti") {#say %ansi(7) "[ "%ansi(2)"Shalonesti"%ansi(reset)%ansi(7)" ] ["$_lvl" "$_class"] "%4" ("$_rank") - added"%ansi(reset)}
("Wargar") {#say %ansi(7) "[ "%ansi(11)"Wargar"%ansi(reset)%ansi(7)" ] ["$_lvl" "$_class"] "%4" ("$_rank") - added"%ansi(reset)}
("Loner") {#say %ansi(7) "[ "%ansi(15)"Loner"%ansi(reset)%ansi(7)" ] ["$_lvl" "$_class"] "%4" ("$_rank") - added"%ansi(reset)}
("Renegade") {#say %ansi(7) "[ "%ansi(15)"Renegade"%ansi(reset)%ansi(7)" ] ["$_lvl" "$_class"] "%4" ("$_rank") - added"%ansi(reset)}
("Dragon") {#say %ansi(7) "( "%ansi(10)"Dragon"%ansi(7)" ) ["$_lvl" "$_class"] "%4" ("$_rank") - added"%ansi(reset)}
("Angel") {#say %ansi(7) "( "%ansi(10)"Angel"%ansi(7)" ) ["$_lvl" "$_class"] "%4" ("$_rank") - added"%ansi(reset)}
("Demon") {#say %ansi(7) "( "%ansi(10)"Demon"%ansi(7)" ) ["$_lvl" "$_class"] "%4" ("$_rank") - added"%ansi(reset)}
}
|
|
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Mon Mar 22, 2010 4:49 pm |
An update on this. I noticed that if the variables were changing from one to another, so, the first part of the main #IF, they were always correct. I tried using those locals $_trim_clan, $_trim_rank and now everything seems to work perfectly.
Any idea why the others wouldnt? |
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Mon Mar 22, 2010 5:26 pm |
What exactly was wrong with the output in the first place? It looks like the code printed out "Anbraxas [Member] - added". Wasn't it supposed to do that? What variable do you think was wrong here?
|
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Mon Mar 22, 2010 6:33 pm |
If you look at the :
Code: |
[29 Sha] [ Shalonesti ] Nathaniel Sha'enlas
[ Bloodlust ]
[29 Shaman] Nathaniel (Sha'enlas) - added
|
In the first image, then look at the second image.
The code was supposed to put Nathaniel as in Shalonesti, but it put him as in Bloodlust because Amena ( a little further up) was added to Bloodlust just a few lines before. Eventually it stopped doing it for clans and started doing it for rank, but I don't have screenshots of that. I would imagine that the reason for both is similar or the same. Like I said though, I changed the local variables a little and now it seems to be working just fine:
Code: |
#if (%ismember(%4, @c_name))
{
$_trim_rank = @trimrank(%5)
$_trim_clan = @trimclan(%3)
$_member_num = %ismember(%4, @c_name)
$_curr_lvl = %item(@c_lvl, $_member_num)
$_curr_class = %item(@c_class, $_member_num)
$_curr_clan = %item(@c_clan, $_member_num)
$_curr_rank = %item(@c_rank, $_member_num)
#if ($_curr_lvl != %1)
{
$_old_lvl = $_curr_lvl
#VAR c_lvl %replaceitem(%1, $_member_num, @c_lvl)
$_new_lvl = %item(@c_lvl, $_member_num)
#show "Level changed from "$_old_lvl" to "$_new_lvl" for: "%4
}
$_sel_class = @selclass(%2)
#if ($_sel_class != $_curr_class)
{
$_old_class = $_curr_class
#VAR c_class %replaceitem($_sel_class, $_member_num, @c_class)
$_new_class = %item(@c_class, $_member_num)
#show "Class changed from "$_old_class" to "$_new_class" for: "%4
}
#if ($_curr_clan != $_trim_clan)
{
$_old_clan = $_curr_clan
$_old_color = @clancolor(@c_clan, $_member_num)
$_old_brack = @isbrackets(@c_clan, $_member_num)
#VAR c_clan %replaceitem($_trim_clan, $_member_num, @c_clan)
$_new_clan = %item(@c_clan, $_member_num)
$_new_color = @clancolor(@c_clan, $_member_num)
$_new_brack = @isbrackets(@c_clan, $_member_num)
#show "Clan changed from "%if($_old_brack, "[ ", "( ")%ansi($_old_color)$_old_clan%ansi(reset)%if($_old_brack, " ]", " )")" to "%if($_new_brack, "[ ", "( ")%ansi($_new_color)$_new_clan%ansi(reset)%if($_new_brack, " ]", " )")" for: "%4
}
#if ($_curr_rank != $_trim_rank)
{
$_old_rank = $_curr_rank
#VAR c_rank %replaceitem($_trim_rank, $_member_num, @c_rank)
$_new_rank = %item(@c_rank, $_member_num)
#show "Rank changed from "$_old_rank" to "$_new_rank" for: "%4
}
}
{
#ADDI c_name %4
#VAR c_lvl %additem(%1, @c_lvl)
#VAR c_class %additem(@selclass(%2), @c_class)
$_trim_clan = @trimclan(%3)
#VAR c_clan %additem($_trim_clan, @c_clan)
$_trim_rank = @trimrank(%5)
#VAR c_rank %additem($_trim_rank, @c_rank)
$_new_member = %ismember(%4, @c_name)
$_lvl = %item(@c_lvl, $_new_member)
$_class = %item(@c_class, $_new_member)
$_rank = %item(@c_rank, $_new_member)
$_member_num = %ismember(%4, @c_name)
$_c_color = @clancolor(@c_clan, $_member_num)
$_brackets = @isbrackets(@c_clan, $_member_num)
#say %ansi(7)%if($_brackets = 1, "[ ", "( ")%ansi($_c_color)%item(@c_clan, $_member_num)%ansi(7)%if($_brackets = 1, " ]", " )")" ["$_lvl" "$_class"] "%4" ("$_rank") has been added!"%ansi(reset)
}
|
|
|
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|