You mean like the table storage there already is?
T:setNumber("string index", number)
I've wanted this a number of times, coding both outside and inside Gmod.
Example:
Code:@name DynamicallyAssigningVariables @inputs Var_to_set:string What_to_set_it_as Set @persist A B C D somefunctiontosetvariablehere(Vartoset, What_to_set_it_as)
This would also be useful for calling particular functions (say, in Lua) based on, say, user input.
- Jonny
[URL="http://www.sloganizer.net/en/"][IMG]http://www.sloganizer.net/en/image,Wire,lblue,blue.png[/IMG][/URL]
You mean like the table storage there already is?
T:setNumber("string index", number)
Against stupidity the Gods themselves contend in vain.
-Friedrich Schiller
The flame puts me in the mood to "Do it!".
-Dart, Legend of Dragoon
It is not possible to dynamically set or ready variables, but as ZeikJT pointed out, you can use tables for similar effect (but it cannot be mapped to inputs or outputs).
I'm not just talking about Exp2, but you did give me an idea to use an enum to convert a string into a mapped integer which could be used to assign variables.
Meh, that's why I suggested the function :P Is it actually not possible, or just not done?
[URL="http://www.sloganizer.net/en/"][IMG]http://www.sloganizer.net/en/image,Wire,lblue,blue.png[/IMG][/URL]
Last edited by ZeikJT; 01-09-2009 at 03:46 PM. Reason: adding info
Against stupidity the Gods themselves contend in vain.
-Friedrich Schiller
The flame puts me in the mood to "Do it!".
-Dart, Legend of Dragoon
It is possible as in yes; of course it is possible... no as in; the current optimizations and "core" does not allow for it without bad sideeffects.
Additionally, I would consider this an extremely bad philosophy, sure, for the E2 it might not matter much, but the user of a function or module should never have such influence. If you need it for serious work, you are doing it wrong or being too lazy, or you should use arrays/tables.
[ame=http://en.wikipedia.org/wiki/Eval]eval - Wikipedia, the free encyclopedia[/ame]
Use CPU with ports, it's exactly what you want. You can input port number and port value and by doing out #port_number,#port_value; get the desired effect.
My programs: BIOS - Alcyone - Calculator - Notepad - Movie Player
My tutorials: applyTorque - Quaternions - PID controllers
Some other things I made: FT Chip - RK4 Solar System
Bookmarks