Stonehouse Posted April 24, 2014 Posted April 24, 2014 Hi, I'm trying to parameterise the following line of lua local sidePlanes = mist.makeUnitTable( {'[blue][plane]'} ) so that it goes something like local _side = "blue" (eventually aiming to pass the value of _side as a function parameter) local sidePlanes = mist.makeUnitTable( {'[_side][plane]'} ) looking at lua manuals through my new to lua eyes this seems like it should work but it doesn't - looking around it seems other people have the same issue as they tend to do: if _side = red then local sidePlanes = mist.makeUnitTable( {'[red][plane]'} ) But while workable this seems like an inefficient approach and in other languages it's that I work with it's handled by passing a value via a variable - does lua allow this or do I have to use the if - then - else construct with separate calls to the mist function? Thanks, Stonehouse
Bushmanni Posted April 24, 2014 Posted April 24, 2014 You need to use string concatenation ie. string1 = '[blue]' string2 = '[plane]' string3 = string1 .. string2 Now string3 is '[blue][plane]' DCS Finland: Suomalainen DCS yhteisö -- Finnish DCS community -------------------------------------------------- SF Squadron
Stonehouse Posted April 24, 2014 Author Posted April 24, 2014 Ok thanks Bushmanni, I ended up wondering if that might be the case and will give it a go. I think I may still run into trouble however as I found that the mist function makeUnitTable is actually expecting to be passed a table as a parameter so I think passing it a string variable will give me grief. I'll keep on experimenting though. Cheers Stonehouse
Recommended Posts