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 07-11-2002, 10:38 AM
konidias konidias is offline
Old Bee
konidias's Avatar
Join Date: Jul 2001
Location: Orlando, FL
Posts: 7,222
konidias will become famous soon enough
Send a message via AIM to konidias
Why does this not seem to work? (array)

NPC Code:
 setarray this.items,sarraylen(client.invitems);
for (a=0;a<this.items;a++ {
this.items[a] = a;
}



I'm trying to make it set a variable array for "this.items".

client.invitems is just a string:
client.invitems=0,1,2,3,4

Now, it should set the array length to the string array length, which is 5. Then it runs a for loop to set each array slot to the proper value corresponding the string array.

So basically it should go:
client.invitems=0,1,2,3,4

translates to:
this.items{0,1,2,3,4}


But it isn't working. Any suggestions?
__________________

Put this image in your sig if you support Bomy Island! (g2k1 revision)
play bomberman while you wait!


Reply With Quote
  #2  
Old 07-11-2002, 11:10 AM
Falcor Falcor is offline
Darth Cucumber
Falcor's Avatar
Join Date: Mar 2001
Location: At School
Posts: 2,874
Falcor is on a distinguished road
Send a message via ICQ to Falcor Send a message via AIM to Falcor Send a message via MSN to Falcor Send a message via Yahoo to Falcor
Re: Re: Why does this not seem to work? (array)

Quote:
Originally posted by Kaimetsu
NPC Code:
 setarray this.items,sarraylen(client.invitems);
for (a=0;a<this.items;a++) {
this.items[a] = a;
}



When did you set this.items?
yeah, arraylen(this.items)

hehe, such little mistakes, such huge problems.
__________________

subliminal message: 1+1=3
Reply With Quote
  #3  
Old 07-11-2002, 11:10 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
when you set an array, it usually looks something like this:
0/{0,0,0,0}
(that was if i set an array with a length of 4)
the 0 in front (the 0/) is actually the this.items (the rest being the array parts)
so your for loop right now is basically
for(a=0;a<0;a++)
Reply With Quote
  #4  
Old 07-11-2002, 11:15 AM
Falcor Falcor is offline
Darth Cucumber
Falcor's Avatar
Join Date: Mar 2001
Location: At School
Posts: 2,874
Falcor is on a distinguished road
Send a message via ICQ to Falcor Send a message via AIM to Falcor Send a message via MSN to Falcor Send a message via Yahoo to Falcor
no hes referencing the value of this.items. This items has no value at all. no matter if the array contained data or not. this.items will never contain data unless it is set to contain it.
__________________

subliminal message: 1+1=3
Reply With Quote
  #5  
Old 07-11-2002, 11:16 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Quote:
Originally posted by Falcor
no hes referencing the value of this.items. This items has no value at all. no matter if the array contained data or not. this.items will never contain data unless it is set to contain it.
that's why I said the for loop is basically doing nothing since this.items isnt set to anything (which is 0), I probably shoud've used better wording for my post above
Reply With Quote
  #6  
Old 07-11-2002, 12:39 PM
Falcor Falcor is offline
Darth Cucumber
Falcor's Avatar
Join Date: Mar 2001
Location: At School
Posts: 2,874
Falcor is on a distinguished road
Send a message via ICQ to Falcor Send a message via AIM to Falcor Send a message via MSN to Falcor Send a message via Yahoo to Falcor
well every variable defaults to zero. meaning false. So no data would be zero.
__________________

subliminal message: 1+1=3
Reply With Quote
  #7  
Old 07-11-2002, 08:50 PM
konidias konidias is offline
Old Bee
konidias's Avatar
Join Date: Jul 2001
Location: Orlando, FL
Posts: 7,222
konidias will become famous soon enough
Send a message via AIM to konidias
NPC Code:
 setarray this.items,sarraylen(client.invitems);
for (a=0;a<arraylen(this.items));a++ {
this.items[a] = a;
}



Okay, well isn't "set array this.items,..." setting the array length of this.items? So now that I have it comparing a to the arraylength of this.items, why is it still not working? The array length would be five, since I'm setting the arraylength of this.items to the client strings array length.

It's still not working, can someone tell me what I need to do instead of what I'm not doing right?
__________________

Put this image in your sig if you support Bomy Island! (g2k1 revision)
play bomberman while you wait!


Reply With Quote
  #8  
Old 07-12-2002, 01:36 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Quote:
Originally posted by konidias
NPC Code:
 setarray this.items,sarraylen(client.invitems);
for (a=0;a<arraylen(this.items));a++ {
this.items[a] = a;
}



Okay, well isn't "set array this.items,..." setting the array length of this.items? So now that I have it comparing a to the arraylength of this.items, why is it still not working? The array length would be five, since I'm setting the arraylength of this.items to the client strings array length.

It's still not working, can someone tell me what I need to do
instead of what I'm not doing right?
NPC Code:

setarray this.items,4;
for (a=0;a<arraylen(this.items);a++) {
this.items[a] = a;
}


that worked for me, maybe yours didnt because you had a simple typo or client.invitems wasnt set yet, you had
a<arraylen(this.items));a++
should be
a<arraylen(this.items);a++)
Reply With Quote
  #9  
Old 07-12-2002, 09:41 AM
Aknts Aknts is offline
Level Designer
Aknts's Avatar
Join Date: Apr 2001
Location: USofA
Posts: 3,340
Aknts will become famous soon enough
Send a message via AIM to Aknts
NPC Code:

setarray this.items,sarraylen(client.items);
for (a=0;a<arraylen(this.items);a++) {
this.items[a] = strtofloat(#I(client.items,a));
}
this.items=arraylen(this.items);



I fixed it. It seems I have to use setarray before setting all the variable array values in the for loop, and then set the array to the it's own array length.

This works wonderfully, and it's the only way I know of converting a string array to a variable array.
__________________
Reply With Quote
  #10  
Old 07-12-2002, 09:55 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
it's like a konidias poser :O
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 05:37 AM.


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