If the title made no sense let me explain. I want to add information to a string and then get that information out of the string. For example, lets say I have a string name="Lamp" Description="Just a lamp." now I want to use display the name Lamp in a text label and I want to display the description Just a lamp. in a text label how could I do this?
Ok thanks for your response I’ll say exactly what I’m trying to do. So I have a string value with the value of name="Lamp" Description="Just a lamp." like this
now I want to somehow just get the Lamp portion of it run a script that reads the value and sees the name="Lamp" and will return with Lamp
for index in ("name = 'Lamp' description = 'Just a lamp'"):gmatch("()'") do
print(index)
end
I don’t know would this work, but there are several things I recommend you do,
get rid of the double apostrophe, use some other kind of characters, like “_”, “-”, or “~”
therefore you can use string.split() instead, not only much more efficient, but also a lot simpler,
put a “,” or some kind of separator between the name = “Lamp” and description = "Just a lamp"
so that you can use string.split() again, which is again, much simpler
myString = "name-Lamp,description-Just a lamp"
local stringSections = string.split(myString, ",")
print(stringSections[1])
print(stringSections[2])
local lampName = string.split(stringSections[1], "-")[2] -- this might look complicated but trust me it's not
so you split “name-Lamp,description-Just a lamp” into
“name-Lamp” and “description-Just a lamp”
then
“name”, “Lamp”, “description”, “Just a lamp”
I am reading farther into the documentation and I believe I understand it somewhat. The way you mentioned with splitting would work for the first part but then I would still have to actually grab the Lamp and Just a lamp.
You could just make two string values instead of one in the object titled “TitleOfObject” and “DescriptionOfObject”, then manipulate them however you want that way.
It’s not the most efficient way, but it will save you the hassle of trying to understand string manipulation.
@NuclearHedgie
Well what im doing is im gonna put this one value in inspectable items then I will make a script that will remove the value save the information and add attributes to the object that will then use them for other scripts this struggle and learning curve will save me a lot of time in the long run.