ok, now that I've had a bit of time to think about this and I don't have any alcohol in my system...
vars = { var1="%1", var2="%2", var3="%3", var4="%4" }
divisor = 300 / ( "%1" + "%2" + "%3" + "%4" )
for i,v in pairs(vars) do
temp = v * divisor
if temp > 75 then
temp = (temp - 75) - 75
else
if temp < 75 then
temp = (75 - temp ) + 75
end
end
if temp < 0 then
temp = math.ceil( temp - 0.5 )
else
temp = math.floor( temp + 0.5 )
end
SetVariable( i, temp )
end -- loop
The main issue with the actual math is that how you tried stating what the logic is just is way too ambiguous. Seems like one of those things that are easier to think about than to explain. The best way to start explaining in this situation is to break it down into smaller chunks instead of trying to get the whole process out in one statement with no punctuation. Also breaking it down into sections that you can easily refer back to would help.
Quote:
And just to make it even more complicated i forgot to add after multiplying it by 300 if it is above 75 we minus 75 from it then minus that number from 75 and if it is below we minus it from 75 then add 75. And then round it to the nearest whole number. If that makes sense...
Could be easier to read in this format:
1) sum = sum of v1,v2,v3, and v4
2) temp = var / sum * 300
3) if temp at stage 2 is ___ then temp should be temp - 75 etc.