Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,014 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 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 | chip programmers | 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