Gamestudio Links
Zorro Links
Newest Posts
Alpaca Plugin v1.5.2 Release
by kzhao. 01/11/26 13:42
Alpaca Plugin v1.4.0
by kzhao. 01/11/26 13:38
separating groups of 3 digits by a comma
by joe_kane. 01/11/26 00:01
MRC.c and WFO
by joe_kane. 01/10/26 23:58
BarOffset (default = 940 for daily bars?
by joe_kane. 01/10/26 23:46
NOMAX undeclared identifier.
by Petra. 01/09/26 21:12
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (kzhao), 3,777 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
joe_kane, Namitha_NN, Syndrela, agasior, mosfet
19189 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
variable name as string #319159
04/12/10 17:03
04/12/10 17:03
Joined: May 2008
Posts: 62
México.
F
FcoElizalde Offline OP
Junior Member
FcoElizalde  Offline OP
Junior Member
F

Joined: May 2008
Posts: 62
México.
Hi everyone,
I there a way to turn the content of a string to the name of a variable and read the content of the variable as the number?

Im looking at this to a for() function:
for example:

for(c=1; c<npc.skill33; c++)
{
str_cpy(ent_skill,"npc.skill");
i=20+c;
str_for_num(skill_n,i);
str_cat(ent_skill,skill_n);

temp=(content of the variale named as the content of the string"ent_skill"
}

or if this isnt possible, could someone tell me another way to achieve a similar result, the idea is to read trough a list in an array without writing all the instruction for each member.

Thanks in advance.

Last edited by FcoElizalde; 04/12/10 17:23.
Re: variable name as string [Re: FcoElizalde] #319164
04/12/10 17:38
04/12/10 17:38
Joined: Jul 2008
Posts: 170
Germany, near Mainz
Nicotin Offline
Member
Nicotin  Offline
Member

Joined: Jul 2008
Posts: 170
Germany, near Mainz
If I remember it right there should be a function called "var_for_name(STRING* name);" which gives back the pointer to the Variable.
Try this.



Re: variable name as string [Re: Nicotin] #319166
04/12/10 17:42
04/12/10 17:42
Joined: Feb 2005
Posts: 3,687
Hessen, Germany
T
Tempelbauer Offline
Expert
Tempelbauer  Offline
Expert
T

Joined: Feb 2005
Posts: 3,687
Hessen, Germany

Re: variable name as string [Re: Tempelbauer] #319167
04/12/10 17:49
04/12/10 17:49
Joined: May 2008
Posts: 62
México.
F
FcoElizalde Offline OP
Junior Member
FcoElizalde  Offline OP
Junior Member
F

Joined: May 2008
Posts: 62
México.
Okay I dont get it, but, this function returns a pointer to a string?

I need to read a var with the name of the content of the string, not the other way around.

Ok ok, if it doesnt contain a "=", then the string transforms to the result right?
Then with str_clip I can cut the name and the "=", getting only the value
And with str_to_num I get the result. ok

thanks for the help guys

Last edited by FcoElizalde; 04/12/10 23:45.
Re: variable name as string [Re: FcoElizalde] #319202
04/12/10 23:41
04/12/10 23:41
Joined: May 2008
Posts: 62
México.
F
FcoElizalde Offline OP
Junior Member
FcoElizalde  Offline OP
Junior Member
F

Joined: May 2008
Posts: 62
México.
Sorry to bother again, but it appears I didnt get it right, because i cant get var_for_name to work.

Anyone there can help me by scripting an example, in the manual theres only 1 line of code:
var_for_name("camera.clip_far = 20000");

Actualy nevermind, my mistake:
This only works with global variables, I was using locals.
It appears this doesnt work with arrays too.
Thanks again.

Last edited by FcoElizalde; 04/13/10 00:12.

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1