Help, AS3 and Flash to lua operators?

Hi guys

I’m studying online code and I just can not convert this line( AS3 and Flash) into lua:

theValue = theValue \< mProps[theProp].value ? theValue : mProps[theProp].value;

precisely I do not understand what they are for “?” and “:” operatos

can someone help me?

It’s equivalent to

if theValue \< mProps[theProp].value then theValue = theValue -- obviously doesn't need to be the same else theValue = mProps[theProp].value end

Usually it may also be expressed as:

theValue = (theValue \< mProps[theProp].value) and theValue or mProps[theProp].value

However, this is not quite the same, since if theValue were false / nil this would give you mProps[theProp].value. (I assume from the less-than that these are numbers or strings.)

@StarCrunch has already answered as asked, but the “nuances” of the two languages suggest a different translation:

-- eliminating the redundant reassignment if (mProps[theProp].value \< theValue) then theValue = mProps[theProp].value end -- or, more succinctly (tho still potentially reassigning) theValue = math.min(theValue, mProps[theProp].value)

Thank you so much guys!

I will use the instruction without redundancy from @davebollinger

Thanks to @StarCrunch for the correct translation

It’s equivalent to

if theValue \< mProps[theProp].value then theValue = theValue -- obviously doesn't need to be the same else theValue = mProps[theProp].value end

Usually it may also be expressed as:

theValue = (theValue \< mProps[theProp].value) and theValue or mProps[theProp].value

However, this is not quite the same, since if theValue were false / nil this would give you mProps[theProp].value. (I assume from the less-than that these are numbers or strings.)

@StarCrunch has already answered as asked, but the “nuances” of the two languages suggest a different translation:

-- eliminating the redundant reassignment if (mProps[theProp].value \< theValue) then theValue = mProps[theProp].value end -- or, more succinctly (tho still potentially reassigning) theValue = math.min(theValue, mProps[theProp].value)

Thank you so much guys!

I will use the instruction without redundancy from @davebollinger

Thanks to @StarCrunch for the correct translation