Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-14-2007, 07:00 PM
calani calani is offline
Scriptess
calani's Avatar
Join Date: Aug 2003
Location: asmgarden.gmap
Posts: 606
calani is on a distinguished road
Send a message via AIM to calani
Post fun with .index(), or rather a distinct lack thereof

i've run into problems using .index() before, namely with weapon checking.
yet again, i ran into a similar problem doing the same thing. surprise, surprise.
anyway! this time i decided to investigate instead of just writing a hack to work around the problem.
here's the script followed by the output so you can puzzle over it, and hopefully offer an explination:

PHP Code:
public function onTest_func(acct) {
  
this.temp_test0="";
  
this.temp_test1=0;
  
this.temp_test2=0;
  
this.temp_test3=0;
  
this.temp_test4="";
  
this.temp_test5=0;
  
this.temp_test6=0;
  
this.temp_test7=0;
  
with(findplayer(acct)) {
    for(
iplayer.weaponsthiso.temp_test0@="|"@i;
    echo(
"element 74 is: "@player.weapons[73]);
    if (
player.weapons.index("+System")>=0thiso.temp_test1=true;
    if (
player.weapons.index("+WeaponControl")>=0thiso.temp_test2=true;
    for (
iplayer.weapons) if (i=="+System"thiso.temp_test3=true;
    for (
iplayer.weaponsthis.temp_test4@="|"@(player.weapons.index(i)>=0);
    if (
player.weapons.index(player.weapons[0])>=0thiso.temp_test5=true;
    
thiso.temp_test6=("+System"==player.weapons[0]);
    
thiso.temp_test7=("+WeaponControl"==player.weapons[1]);
    
  }
  echo(
"----------------");
  echo(
"Weapon list is: "@thiso.temp_test0);
  echo(
"test for \"+System\" with .index() returns "@this.temp_test1);
  echo(
"test for \"+WeaponControl\" with .index() returns "@this.temp_test2);
  echo(
"test for \"+System\" with loop check returns "@this.temp_test3);
  echo(
"loop .index test returns "@this.temp_test4);
  echo(
"test for element [0] with .index() returns "@this.temp_test5);
  echo(
"\"+System\"==player.weapons[0] returns "@this.temp_test6);
  echo(
"\"+WeaponControl\"==player.weapons[1] returns "@this.temp_test7);

PHP Code:
Element 73 is$Frenzy
----------------
Weapon list is: |+System|+WeaponControl|+ArmorControl|+Class|+Crafting|+CTF|+Events|+GUI|+Guild|+Inventory|+ItemControl|+PetControl|+Radio|+SpellControl|+Status|+Target|+Trade|+SkillMenu|+Shop|+Options|+Message|+Party|+Macro|+Movement|+Nation|$Tailor|+JobsControl|+Environment|+Hacker|+ClassTrainer|+Map|+Misc|+PartyMaking|+ClassMasteryPoints|+CharacterSlots|+Ganis|+JChat|+Time|+Mail|+Swim|+Instrument|+Quest|+HouseSystem|+Event|+Icons|+IconShop|$Bash|+ShoutColors|+ChatColors|+GuildColors|$Enrage|$Sword Mastery|$Hard Strike|$Taunt|+Nationlog|$Magic Shot|$Minor Heal|$Iron Wall|$Exorcise|$Fist Mastery|+BloodLust|+DrawStar|$Farming|$Fireball|$Mug|$Dodge|$Stealth|$Feign Death|$Steal|$Chill|$Axe Mastery|$Rush|$Bash II|$Frenzy||$Acid Blast|$Agility|$Scamper|$Backstab|$Sand Swipe|$Payout|Gambet/BH System|$Cobra Fist|$Tough Skin|$Backstab II|$Scavenge|$Spy|$Earth Slam|$Tiger Claw|$Charge|$Throw Shuriken|$Irixyu|$Kemuri Beru|$Katana Mastery|$Seal of Incapacitation|$Tataki Koto|$Bolt|$Blight|$Blind|$Pick Lock|$Transfixion|$Throw Dagger|$Shadowbind|$Throw Pinwheel|$Viper Bite|$Finishing Blow|$Cloak of Shadows|$Frozen Lance|$Ice Coffin|$Wildfire|$Step|$Blast Wave|$Crush|$Explosion|$Grim Reaper|$Drain|$Siphon|$Seeking Missile|$ImbueFire|$ImbueEarth|$Sprint|$Split Shot|$ImbueWind|$Battle Shriek|$Throat Stab|+gecko|$Ki Blast|$Recharge|$Blessing of Stamina|$Restore|$Dark Wave|$Sleep|$Absorb|$Shadowguard|$Shadow Swipe|$Nightmare|$Focus|$Discipline|$Pigeon Peck|$Chakra|$Entangle|$Pathfinding|$Eye of the Hawk|$Regenerate|$Dragon Fang|$War Cry|$Cleanse|$Heal|$Blessing of Strength|$Rebirth|$Blessing of Dexterity|$Energy Freeze|$Revitalize|$Revive|$Egress|$Scythe Mastery|$Mental Conditioning|$Smasher
test 
for "+System" with .index() returns 0
test 
for "+WeaponControl" with .index() returns 0
test 
for "+System" with loop check returns 1
loop 
.index test returns |1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|0|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1
test 
for element [0with .index() returns 1
"+System"==player.weapons[0returns 1
"+WeaponControl"==player.weapons[1returns 1 
puzzle away.

edit: due to the php field's scrollbar, you may miss the 0 in the loop .index test at element 73
edit: also renamed the function to test_func since it gets *'d out without the _
__________________
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:21 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.