Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...