JeViCo Posted April 15, 2018 Share Posted April 15, 2018 (edited) Hello everyone! How can i transform a string to variable? For example i have "text" string and i want to make text variable. Is That possible? I need it for guiRadioButtonGetSelected I know that i can make it with third variable but code become longer then\\ Edited April 15, 2018 by Juuve Link to comment
SycroX Posted April 15, 2018 Share Posted April 15, 2018 41 minutes ago, Juuve said: Hello everyone! How can i transform a string to variable? For example i have "text" string and i want to make text variable. Is That possible? I need it for guiRadioButtonGetSelected I know that i can make it with third variable but code become longer then\\ i think that you can't convert a string to variable Link to comment
Discord Moderators Megadreams Posted April 15, 2018 Discord Moderators Share Posted April 15, 2018 (edited) Well technically you could do: _G["mystring"] = theValueYouWantToAssignIt After that the variable mystring becomes available just as any regular variable. Edited April 15, 2018 by Megadreams 1 Link to comment
Moderators IIYAMA Posted April 15, 2018 Moderators Share Posted April 15, 2018 Or you can use loadstring. local value = true loadstring("text = " .. tostring(value))() https://www.lua.org/pil/8.html @Megadreams hmm interesting, I didn't know that you could also make global variables like that. 2 Link to comment
JeViCo Posted April 15, 2018 Author Share Posted April 15, 2018 thank you both. Both codes work perfect. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now