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 10-31-2007, 10:21 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
weird bug [arrays]

well, it's odd.

Here's an array thing

HTML Code:
function onCreated() 
{
  temp.array = { {"Heya", "Fish"}, {"hiya", "Bull"} };
  temp.search = {"Heya", "Fish"};
  echo(temp.array.index(temp.search));
}
However, it'd return a negative number, indicating that it can't be found!
Although, if I am to do this

HTML Code:
function onCreated() 
{
  temp.array = { {"Heya", "Fish"}, {"hiya", "Bull"} };
  temp.search = {"Heya", "Fish"};
  echo(temp.array.index((@ temp.search)));
}
It'll give the correct array index... strange but true I must say
__________________
Reply With Quote
  #2  
Old 10-31-2007, 10:37 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Dynamic variables are fun.
__________________
Reply With Quote
  #3  
Old 10-31-2007, 11:33 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
It seems that var.index() only accepts strings as its parameter, so it's no bug.

Inverness: I don't think you caught what was being pointed out...
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #4  
Old 11-01-2007, 03:18 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Tolnaftate2004 View Post
Inverness: I don't think you caught what was being pointed out...
Don't worry, I did
Something about this was mentioned many months ago, its one of those weird Graal things.

Fix it Stefan >:O
__________________
Reply With Quote
  #5  
Old 11-01-2007, 12:12 AM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
PHP Code:
function onCreated() 
{
  
temp.array = { {"Heya""Fish"}, {"hiya""Bull"} };
  
temp.search = {"Heya""Fish"};
  echo(
temp.array.index( @temp.search ) );

Here you go, love.

This is just because you're interpreting the object as it's input. There was something about Stefan claiming this a while ago. It was in one of the threads.... I'll see if I can find it.
Reply With Quote
  #6  
Old 11-01-2007, 04:41 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
but abs() around to make it positive if it's the correct number XD lol, don't listen to me :P
__________________
Deep into the Darkness peering...
Reply With Quote
  #7  
Old 11-01-2007, 06:04 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Angel_Light View Post
but abs() around to make it positive if it's the correct number XD lol, don't listen to me :P
Wtf are you talking about?
__________________
Reply With Quote
  #8  
Old 11-03-2007, 12:49 AM
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
You can't compare arrays with the == operator, that's why index() is not working with arrays either. If you convert it to string then it's comparing each array member with a string comparison and is return the wished index. This can also help if you want to find an object in an array with the same name, just give @object or object.name as parameter to the index() function.
Reply With Quote
  #9  
Old 11-03-2007, 02:23 AM
bscharff bscharff is offline
Bloo
bscharff's Avatar
Join Date: Sep 2006
Location: San Antonio, Texas
Posts: 185
bscharff has a little shameless behaviour in the past
Send a message via AIM to bscharff Send a message via MSN to bscharff Send a message via Yahoo to bscharff
I was having issues with simple scripts not working because I didn't put a delimiter (@) in a place where it doesn't need to be.
Such As
player.chat = serverr.chat;
Would Have To Be
player.chat = @serverr.chat;
(Just an example - not necessarily one script with issues.)
__________________
Trying to be nice now...
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 01:51 AM.


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