|
6 registered members (TipmyPip, Martin_HH, JMMAC, Grant, Volkovstudio, AndrewAMD),
5,549
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
variable name as string
#319159
04/12/10 17:03
04/12/10 17:03
|
Joined: May 2008
Posts: 62 México.
FcoElizalde
OP
Junior Member
|
OP
Junior Member
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
Member
|
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: Tempelbauer]
#319167
04/12/10 17:49
04/12/10 17:49
|
Joined: May 2008
Posts: 62 México.
FcoElizalde
OP
Junior Member
|
OP
Junior Member
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.
FcoElizalde
OP
Junior Member
|
OP
Junior Member
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.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|