Jump to content

Que llene solo hasta 100%


aka Blue

Recommended Posts

Posted

Bueno, pongo esto rápidamente porque es que no me sale. A ver, quiero hacer que al hacer x cosa, rellene +10 de 100% y que al llegar a 95 por ejemplo, no rellene 105, sino, hasta 100% máximo.

Espero que alguien me haya entendido xD.

Gracias de antemano y lo siento pero estoy con prisas :S

yDORrdn.png

Posted

Podrias hacer esto:

if ( value > 100 ) then 
    value = 100 
end 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Lo que tengo es esto y lo que quiero hacer es que al tomar una barrita, solo le suba 10 pero si no pongo algo que calcule que solo suba hasta 100, me lo sube hasta 110, 200, 300...

addEventHandler ( "onTomarEnergía", getRootElement ( ), 
    function ( ) 
        setElementData ( localPlayer, "energia", 100 ) 
    end 
) 

yDORrdn.png

Posted

Y el codigo que usas para subirle +10?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
math.min ( 95 + 10, 100 ) -->> 100 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Aún no pude solucionarlo... me siento putamente estúpido, en serio xD. Tengo esto únicamente:

addEventHandler ( "onTomarEnergía", getRootElement ( ), 
    function ( ) 
        local miEnergia = getElementData ( local, "energia" ) 
        setElementData ( localPlayer, "energia", miEnergia + 10 ) 
    end 
) 

yDORrdn.png

Posted
setElementData ( localPlayer, "energia", math.min ( miEnergia + 10, 100 ) ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Quizá si intentes usar algoritmos tendrias menos problemas, en el foro arabe circula un libro de programación en Lua en formato pdf descargalo.

El unico limite en la vida, es tu imaginacion.

Programar es la mejor forma de aprender a pensar.

  • Recently Browsing   0 members

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