Topic: Making menus

Hey, Is there some easy way to redo this?

When I make menus I write:

function onSceneUpdate()

if onKeyDown("I") or inventory == true then

setText(text_inv, "Inventory: ")

end

end

But in order to make it pop away by pressing the same key I'm thinking I could write:

function onSceneUpdate()

if onKeyDown("I") or inventory == true then

setText(text_inv, "Inventory: ")

      if onKeyDown("I") then
     
      inventory = false
     
      end

end

end

But I can't since it doesn't sense that I'm pressing I once. And it goes directly onto the next function and says it's false vice versa and the menu just stays on all the time (nothing happens).

Is there some better way to do it? I want to be able to use the same key while in menus.

Pär

Re: Making menus

Hi,

you should use your variable inventory in a different way :

inventory = false

function onSceneUpdate()

    if onKeyDown("I") then
        inventory = not inventory -- set inventory to it's reverse
    end

    if inventory == true then
        setText(text_inv, "Inventory: ")
    else
        setText(text_inv, "nothing")
    end

end

Re: Making menus

That's perfect.