Storing actor positions in a single table cell
Hey, I'm trying to build a game with tables, but having lots of levels and things to store is making it quite messy.
I was wondering if it's possible to store multiple values in a single cell. I know I could use %10, %100, etc if I combine the values into a single string, but was wondering if there were any other options - staring at lots of long numbers is a daunting prospect. Anyone been able to use a text cell and comma separated values? And if so, how well does that extend beyond just two values? Can you store a string that is 172,3,31 and be able to get the middle number, regardless of the size of the values? (i.e. in that example, the first value is 3 characters long, but would it still work if sometimes that number was only 2 characters long?).
Does any of that make any sense?
Comments
I used the padInt function to make all integers the same lenght and then used textSubStr function to split the value.
e.g. X 99, Y 87, Direction 100
-> padInt(99,5)..padInt(87,5)..padInt(100,5)
= 000990008700100
X = textSubStr(000990008700100,1,5)
Y = textSubStr(000990008700100,6,10)
Direction = textSubStr(000990008700100,11,15)
Perhaps it is a better idea than using comma separated strings.
Thanks @ThoPel - I'll do some testing with that.
It'll definitely work when I save attributes into the table and then call them out - my original plan though was to do all my table design in excel and import as a table. So I'm looking for a function to be able to turn 99,87,100 into x=99 y=87 d=100 rather than the other way around. For the solution above to work, I'd have to have the actors know in advance what the values were?
@imjustmike Ah, okay!
Yes, you need a known order for my solution. Perhaps you could summarize all your values with the "&" function in one field with Excel (e.g. =TEXT(A1;"00000")&TEXT(A2;"00000")&TEXT(A3;"00000")).
With textSubString and textFind you can do the comma separation with minimal fuss. I'll try to make a demo later if I have time and remember.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Damn! I had forgotten the "textFind(text,string,index)"-function
e.g.
x=99 y=87 d=100
= 99,87,100
TEXT = "99,87,100"
x = textSubStr(TEXT,1,textFind(TEXT,",",1))
y = textSubStr(TEXT,textFind(TEXT,",",1),textFind(TEXT,",",2))
d = textSubStr(TEXT,textFind(TEXT,",",2),textLength(TEXT))
@Armelline Do you mean something like that?
Something like that, yes. I don't think you can do it in quite the way you're trying to there, though.
y = textSubStr(TEXT,textFind(TEXT,",",1),textFind(TEXT,",",2))
When you say "textFind(TEXT,",",2)" you're not saying "start at the second instance that is found", you're saying "start at character 2". Also, the result of text find is the character that the comma is found at.
So the result of your y calculation will be:
,
This is because it starts the textSubStr at the 3rd character, where it locates the first comma. It ends it at the 3rd character, where it locates the fist comma found after character 2.
It gets a little more complicated than is ideal. I'll have a demo up shortly.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
@Armelline Okay I have misunderstood the word "startIndex" in the documentation
Yes, the example in the docs isn't very clear. startIndex means the starting character number, not starting instance of the text you're finding.
In the docs, 2 gives the result of 31 because it starts with "he", which is not "the", so it then finds the first instance at the end of the string.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
That was exactly my fault.