Lots of variables

Hi all, need some help. I have a global variable called chardata with child’s. Chardata.1, chardata.2 the number are id’s with more child’s attached the them. Skills, fee, cut, name. Now. I also have a global variable called teams with child’s. 1, 2, 3 and 4. When a character is selected ( min 1 max 4 ). It grabs their unique I’d from object variables. What I need to do is compare the team child’s with the chardata and deduct the correct fee from the banks cash. I really hope this is possible as I have no other idea on how to do it.

So you’ve got a structure of structures? Then you can get the skills, fees, cut etc values using

VariableString(Chardata[VariableString(CharacterUniqueId)]["Fee"])

where CharacterUniqueId is the selected characters’ unique Id you mentioned.

1 Like

Thank you very much. Also, if it not to much of a bother. With the fee string you posted. How would I subtract a number from it?

Use Variable instead of VariableString (fortunately variables are weakly typed):

Variable(Chardata[VariableString(CharacterUniqueId)]["Fee"])

1 Like

Thanks again. I’ll let you know iv I got it to work tomorrow. Kinda tired. Gonna watch some tutorials. Nite

It’ll work - I copied it directly from a working demo project I rustled up.

1 Like

nope. Unless I did something wrong. Dynamic variables give me a headache lol
i checked the debugger. nothing happens with the for each child until i press hire or fire for some reason. but then all it does is add the chardata.4 to charID and CharName = 4 but i used char 1 as a test.

CharName holds the ID, not CharId. You said the structure id CharData, with children 1, 2, 3 & 4. Those numbers are the children’s names. CharId will hold the value of the children variable/nodes.

So the action should be

Variable(CharData[VariableString(CharName)][“Fee”]

1 Like

Nice one, thank you. Being old and slow I struggle understanding all the expressions and how they work together

1 Like

Yeah, that one took me a while to get to grips with too. A fair bit of trial and error, but once you break it down it’s a “Oh, of course” type realisation.

1 Like

Yeah, I bet, I’m assuming I can do the same with checking the skills. CharData.1.Skils.Driver=1 in the next scene?

Yes. And each level deeper of the structure just adds another ["…"] to the expression. So if you broke down the skills into further categories, you’d tack a ["<skill_category>"] onto the expression.

2 Likes

That makes sense. Thanks. Once this is all setup. I have the hardest job next. Work out how to store my 4 characters movements so that they can be played back.

Just to add some context here, you can also just append .Fee instead of [“Fee”], but both should work.

Closing this out per the OPs request.