Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-27-2006, 04:33 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Problem with obj.index()

Can anyone tell me why the index gets returned as -1 all the time?


List of my warp rings:

PHP Code:
Warp Rings/Bearnt Warp Ring
Warp Rings
/Clatton Warp
Warp Rings
/Cloud City
Warp Rings
/Ethereal Lobby
Warp Rings
/Europa Warp
Warp Rings
/Events Island
Warp Rings
/Everton Warp Ring
Warp Rings
/Freenand Warp
Warp Rings
/Kendee Warp
Warp Rings
/MainTown
Warp Rings
/Pennix Warp Ring
Warp Rings
/Phantasma Warp
Warp Rings
/Spenn Warp
Warp Rings
/test
Warp Rings
/Touran Warp
Warp Rings
/Triton Warp
Warp Rings
/Warper3 

The script.

NPC Code:

this.warpingrings = {
"Warp Rings/Bearnt Warp Ring",
"Warp Rings/Clatton Warp",
"Warp Rings/Cloud City",
"Warp Rings/Ethereal Lobby",
"Warp Rings/Europa Warp",
"Warp Rings/Events Island",
"Warp Rings/Everton Warp Ring",
"Warp Rings/Freenand Warp",
"Warp Rings/Kendee Warp",
"Warp Rings/MainTown",
"Warp Rings/MoInt Warp",
"Warp Rings/Pennix Warp Ring",
"Warp Rings/Phantasma Warp",
"Warp Rings/Spenn Warp",
"Warp Rings/test",
"Warp Rings/Touran Warp",
"Warp Rings/Triton Warp",
"Warp Rings/Warper3",
};

for (i = 0; i < this.warpingrings.size(); i ++) {
echo( "[" @ this.warpingrings[i] @ "] [" @ player.weapons.index(this.warpingrings[i]) @ "]");
}





RC.

PHP Code:
[Warp Rings/Bearnt Warp Ring] [-1]
[
Warp Rings/Clatton Warp] [-1]
[
Warp Rings/Cloud City] [-1]
[
Warp Rings/Ethereal Lobby] [-1]
[
Warp Rings/Europa Warp] [-1]
[
Warp Rings/Events Island] [-1]
[
Warp Rings/Everton Warp Ring] [-1]
[
Warp Rings/Freenand Warp] [-1]
[
Warp Rings/Kendee Warp] [-1]
[
Warp Rings/MainTown] [-1]
[
Warp Rings/MoInt Warp] [-1]
[
Warp Rings/Pennix Warp Ring] [-1]
[
Warp Rings/Phantasma Warp] [-1]
[
Warp Rings/Spenn Warp] [-1]
[
Warp Rings/test] [-1]
[
Warp Rings/Touran Warp] [-1]
[
Warp Rings/Triton Warp] [-1]
[
Warp Rings/Warper3] [-1


ADD: Any why doesnt if (hasweapon(weaponname)) work anymore?
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #2  
Old 05-27-2006, 05:20 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
player.weapons is a list of objects I think, not names.
__________________
Skyld
Reply With Quote
  #3  
Old 05-27-2006, 07:10 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Wrong. I tried echo ( player.weapons); and it displayed all my Weapons + some global Weapons.


And I also tried something like this.var = player.weapons; and to use index on that, didnt work either.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #4  
Old 05-27-2006, 07:13 PM
Snakeandy7 Snakeandy7 is offline
"Member ID=2610"
Snakeandy7's Avatar
Join Date: Mar 2003
Posts: 987
Snakeandy7 is on a distinguished road
findweapon("name") == value [1/NULL]

Very weird... I've just tried this too, same error. Although it works on other things... [not players.weapons]
__________________
"Freedom is best I tell thee
of all things to be won
then never live within the bond
of slavery my son".



Last edited by Snakeandy7; 05-27-2006 at 07:36 PM..
Reply With Quote
  #5  
Old 05-27-2006, 07:52 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
player.weapons is an array. When you output an array then it's outputing its content as string, most objects print their name when you just print the object. I can check this though, to make sure its working correctly.

The function hasweapon(oldstring) is still working, in new scripting it would be findweapon(string)!=NULL. findweapon(string) is searching for a weapon with the specified name in the players inventory. There is also findweaponnpc(string) for finding any existing weapon, although you can also just access the weapons by name, you need to use the correct case though.
Reply With Quote
  #6  
Old 05-28-2006, 12:29 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Is

NPC Code:
echo( this.warpingrings[i] @ ": " @ findweapon(this.warpingrings[i]));



supposed to show i.e.

PHP Code:
Warp Rings/Clatton WarpWarp Rings/Clatton Warp 
?


Shouldnt it show this instead:

PHP Code:
Warp Rings/Clatton Warp1/null 
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
Reply


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 04:10 PM.


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