Jump to content

easy, but tricky situation


kuwalda

Recommended Posts

Hello.

I have really easy, but tricky situation I can`t figure out how to write in code.

Code:

if tonumber(row["Record"]) > recordValueToCheckRally then 
    recordValueToCheck = recordValueToCheckRally / 1000 
    oldRecord = tonumber(row["Record"]) / 1000 
    starpiba = (tonumber(row["Record"]) - recordValueToCheck) / 1000 
elseif tonumber(row["Record"]) < recordValueToCheckDrift then 
    recordValueToCheck = recordValueToCheckDrift 
    oldRecord = tonumber(row["Record"]) 
    starpiba = tonumber(row["Record"]) - recordValueToCheck 
end 
    local oldRecordist = row["AccountName"] 
    outputChatBox("[RECORD=+=RECORD]", root, 0, 255, 255) 
    outputChatBox("Rec: "..getPlayerName(thePlayer).."", root, 0, 255, 255) 
    outputChatBox("Map: "..getElementData(thePlayer, "raceParticipate").."", root, 0, 255, 255) 
    outputChatBox("Old: "..oldRecord.."", root, 0, 255, 255) 
    outputChatBox("New: "..recordValueToCheck.."", root, 0, 255, 255) 
    outputChatBox("Difference: "..starpiba.."", root, 0, 255, 255) 
    outputChatBox("[RECORD=+=RECORD]", root, 0, 255, 255) 

Basicly, I want to put / 1000 under variable if first check is positive, and put something like / 1 if second check is positive. In this way I would be able to save up some lines in my code, which already is kinda messy. By saving up some lines I mean, that under each check there would be only 1 variable, defining this / 1000 and / 1, so later I can just type my lines like this:

outputChatBox("[RECORD=+=RECORD]", root, 0, 255, 255) 
outputChatBox("Rec: "..getPlayerName(thePlayer).."", root, 0, 255, 255) 
outputChatBox("Map: "..getElementData(thePlayer, "raceParticipate").."", root, 0, 255, 255) 
outputChatBox("Old: "..oldRecord [b]VARIABLE[/b].."", root, 0, 255, 255) 
outputChatBox("New: "..recordValueToCheck [b]VARIABLE[/b].."", root, 0, 255, 255) 
outputChatBox("Difference: "..starpiba [b]VARIABLE[/b].."", root, 0, 255, 255) 

I know its easy to do, but I have problems with syntax, so could someone please post the correct way to do it?

Link to comment

You can use the shortend if-statement for it. :)

outputChatBox ( "Old: ".. ( tonumber ( row [ "Record" ] ) > recordValueToCheckRally ) and tonumber ( row [ "Record" ] ) / 1000 or tonumber ( row [ "Record" ] ) .."", root, 0, 255, 255 ) 

note; I might missed a few )'s, sorry for that xD

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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