Jump to content

calculator: + works, * doesn't work


FSXTim

Recommended Posts

Hello,

I have a small problem with my script.

function ergebnisGet (state) 
    if state == "left" then 
        if(source == cGleich) then 
            local value1 = guiGetText(eingabe1) 
            local value2 = guiGetText(eingabe2) 
            local result = guiGetText(zwischeneingabe) 
            if result == "+" then 
                guiSetText(ergebnis,tonumber(value1)+tonumber(value2)) 
            end 
            if result == "x" then 
                guiSetText(ergebnis,tonumber(value1)*tonumber(value2)) 
            end 
        end 
    end 
end 
addEventHandler("onClientGUIClick", getRootElement(), ergebnisGet)   

The calculation with + works, but the calculation with * doesn't work. Why?

Greets

Link to comment

strange ...

try

  
    function ergebnisGet (state) 
        if state == "left" then 
            if(source == cGleich) then 
                local value1 = guiGetText(eingabe1) 
                local value2 = guiGetText(eingabe2) 
                local result = guiGetText(zwischeneingabe) 
                if result == "+" then 
                    guiSetText(ergebnis,tonumber(value1)+tonumber(value2)) 
                elseif result == "x" then 
                    guiSetText(ergebnis,tonumber(value1)*tonumber(value2)) 
                end 
            end 
        end 
    end 
    addEventHandler("onClientGUIClick", getRootElement(), ergebnisGet) 
  

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...