License from €75 Log in
DE EN FR ES IT CZ

Having two graphics.drawBox at the same time not working

This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials

  1. · 8 years ago
    The script is gonna look like this? (I've no programming background)

    graphics.addDrawFunc("draw()", 0)

    function drawHealthBar()

    health = math.floor(Values["MC_health"].Int / 100) * 600

    -- + --

    function draw() graphics.drawBox(293, 85, health, 40, 0x00ffff, 1) end

    end
    registerEventHandler("mainLoop", "drawHealthBar")

  2. · 8 years ago
    math.floor() is used to round up numbers containing decimal values to (integers) whole numbers, so instead of something like 1.21, you would convert it to 1.
  3. · 8 years ago
    It doesn't work, the bar keeps disappearing, is the code written right?
    local health

    graphics.addDrawFunc("draw()", 0)



    function drawHealthBar()

    health = math.floor(Values["MC_hp"].Int / 100) * 600

    -- + --

    function draw() graphics.drawBox(293, 85, health, 40, 0x00ffff, 1) end

    end



    registerEventHandler("mainLoop","drawHealthBar")



  4. · 8 years ago
    I even tried this, but it's not working
    local ragno_hp

    graphics.addDrawFunc("draw4()", 0)


    function drawRagno_hp()

    ragno_hp = (Values["ragno_hp"].Int / 100) * 600



    ragno_hp_integer = math.floor(ragno_hp)


    -- + --

    function draw4() graphics.drawBox(1027, 85, ragno_hp_integer, 40, 0x00ffff, 1) end

    end



    registerEventHandler("mainLoop","drawRagno_hp")





  5. · 8 years ago
    I don't know, but like I said... you don't actually need the mainLoop events.

    local health
    
    local fireball_level
    
    
    
    function draw()
    
    
    
       health = math.floor((Values["MC_hp"].Int / 100) * 600)
    
       fireball_level = math.floor((Values["MC_fireball_level"].Int / 100) * 100)
    
    
    
       graphics.drawBox(293, 85, health, 40, 0x00ffff, 1)
    
       graphics.drawBox(1780, 669, fireball_level, 40, 0x00ffff, 1)
    
    
    
    end
    
    
    
    graphics.addDrawFunc("draw()", 0)

    I'm a bit confused as to why you are sharing the fireball_level by 100, then multiplying it by 100, wouldn't that just restore it back to the same value?

    Quick note: you can kill the draw function by using this line...

    removeDrawFunc("draw()")

    or alternatively you can also kill it by replacing the draw function content, but that means you would need to add in the code again if you wanted to use it again, as it would be a destructive method.

    function draw() end -- destructive method
  6. · 8 years ago
    It works
    local mc_health

    local ragno_hp

    local fireball_level

    local fart_level


    function draw()

    -- + -- -- + -- -- + -- -- + -- -- + -- -- + -- -- + --

    mc_health = math.floor((Values["MC_hp"].Int / 100) * 600)

    ragno_health = math.floor((Values["ragno_hp"].Int / 100) * 600)

    fireball_level = math.floor((Values["MC_fireball_level"].Int / 100) * 100)

    fart_level = math.floor((Values["MC_fart_level"].Int / 100) * 100)

    -- + -- -- + -- -- + -- -- + -- -- + -- -- + -- -- + --

    graphics.drawBox(293, 85, mc_health, 40, 0x00ffff, 1)

    graphics.drawBox(1027, 85, ragno_health, 40, 0x00ffff, 1)

    graphics.drawBox(1780, 669, fireball_level, 40, 0x00ffff, 1)

    graphics.drawBox(1780, 816, fart_level, 10, 0x00ffff, 1)

    -- + -- -- + -- -- + -- -- + -- -- + -- -- + -- -- + --

    end

    graphics.addDrawFunc("draw()", 0)
    Thank you!
  7. · 8 years ago
    no problem, but still you don't need the shared by 100, multiplied by 100 bit. it's returning the original value. grin

    fart_level = math.floor((Values["MC_fart_level"].Int / 100) * 100)
    to...
    fart_level = Values["MC_fart_level"].Int
  8. · 8 years ago
    I am gonna take them out

This thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.

New thread

Really delete this post?