Jump to content
Joseph

I don't know how to process GUI responses

Recommended Posts

I trying to create a gui inside the game using the template in main.lua and menu.lua, but when i try to process the user response, it seems like the Main.lua take the event off the eventqueue so i connot process the event into my script. I didn't understand the logic to put the processing routine of my gui into my script.

Share this post


Link to post

You would need to send the event to your script.

Share this post


Link to post

I solved the problem with a global variable, but i don't know if it's the right way. I'm trying to create a menu that appears when a user click door and let the user choose a place to go (that is another map). So i did it that way:

1-I created the gui using Menu.lua as template

2-i wrote a code in the updatephysics of one object called computer that verifies if the user clicks the door (using camera:pick) and then shows the menu (that select the place to go)

3-i inserted a global variable in Main.lua called eventosGUI that stores the event

    while EventQueue:Peek() do
        local event
        event = EventQueue:Wait()
        eventosGUI = event
        event = gamemenu:ProcessEvent(event)
    end

4-then inside the updatephysics of the computer object, i compare eventosGUI.source with the button widget and if its true, i call changemapname = "name of the map"

But there is another problem. The cancel button that i put at the end of the menu is acting strangelly:

1-The player clicks the door

2-the menu opens normally

3- the player clicks the cancel button

4-the menu closes

5-the player click the door for the second time

6-the menu just flashes

7-the player click the door for the third time

8-the menu opens normally

So i solved this ploblem with a flag called corrigeQueue initially setted to false (but i don't know if it's the right way):

        if eventosGUI ~= nil then
...

            if eventosGUI.source == self.mudaLocalGui.botaoCancelar then
                if not self.corrigeQueue then
                    self.paineldegui = false
                    self.mouse_padrao = false
                    self.jogador.script.modoAndar = true
                    self.mudaLocalGui:Hide()
                    janela:HideMouse()
                    self.corrigeQueue = true
                else
                    self.corrigeQueue = false
                end
            end

            eventosGUI = nil

end
 

I tried to flushkeys but it doesn't solved the problem, and i put a Debug:Assert(false, tostring(eventosGUI)) before showing the menu and it returns nil, but i know that the flashing is occurring because eventosGUI ~=nil and eventosGUI.source == self.mudaLocalGui.botaoCancelar returns true

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...