2 registered members (AndrewAMD, dr_panther),
1,282
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
[Solved] Pointing to variables
#245234
01/09/09 00:16
01/09/09 00:16
|
Joined: Jul 2008
Posts: 54 Taipei, Taiwan
PlaystationThree
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2008
Posts: 54
Taipei, Taiwan
|
This is kinda hard to explain in 3dgs terms because its from Adobe Flash's actionscript. Let's say I have a fer variables: var1 var2 var3. Say I want to go through all of them in sequence, setting each to a certain value. In actionscript I would do:
function goThrough(number){
var i = 1;
while(i<=number){
["var"+i] = random(10);
}
}
goThrough(3);
while in lite-c you would have to:
...
var1 = random(10);
var2 = random(10);
var3 = random(10);
...
Essencially what it does is go through all the vars and sets each to a random number. What the ["var"+i] section does is search for the variable "varX" where X is whatever i is. So if i == 2 then it searches for var2. Can you do something like that in lite-c? I read the sections in the manual about variables but nothing...
Last edited by PlaystationThree; 01/09/09 08:14.
Bet you don't know where Taiwan is lol.
"The Lord is my light and my salvation..." Psm 27:1
|
|
|
Re: Pointing to variables
[Re: PlaystationThree]
#245238
01/09/09 00:44
01/09/09 00:44
|
Joined: Oct 2008
Posts: 218 Nashua NH
heinekenbottle
Member
|
Member
Joined: Oct 2008
Posts: 218
Nashua NH
|
An array might work.
function goThrough(var number)
{
var myArray[128];
var i;
for(i = 0; i < number; i++)
{
myArray[i] = random(10);
diag_var("myArray: %f\n",myArray[i]);
wait(1);
}
} EDIT: My code had some C++ syntax that Lite-C did not like.
Last edited by heinekenbottle; 01/09/09 00:53.
|
|
|
Re: Pointing to variables
[Re: heinekenbottle]
#245240
01/09/09 00:48
01/09/09 00:48
|
Joined: Jul 2008
Posts: 54 Taipei, Taiwan
PlaystationThree
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2008
Posts: 54
Taipei, Taiwan
|
Good point, but actually what i'm doing is going through a set of TEXT* structs and changing their strings. I guess I should have made that clear in my first post. Sorry.
Bet you don't know where Taiwan is lol.
"The Lord is my light and my salvation..." Psm 27:1
|
|
|
Re: Pointing to variables
[Re: MMike]
#245265
01/09/09 05:57
01/09/09 05:57
|
Joined: Jul 2008
Posts: 54 Taipei, Taiwan
PlaystationThree
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2008
Posts: 54
Taipei, Taiwan
|
Yeah, I would have stuck with Flash because the script system is great, but it doesn't have 3d built in. The 3rd party API suck too.
Bet you don't know where Taiwan is lol.
"The Lord is my light and my salvation..." Psm 27:1
|
|
|
Re: Pointing to variables
[Re: pegamode]
#245281
01/09/09 08:14
01/09/09 08:14
|
Joined: Jul 2008
Posts: 54 Taipei, Taiwan
PlaystationThree
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2008
Posts: 54
Taipei, Taiwan
|
@pegamode That sounds what i'm looking for. Thanks for the post, and great contribution.
Bet you don't know where Taiwan is lol.
"The Lord is my light and my salvation..." Psm 27:1
|
|
|
|