'LinKin Posted April 28, 2014 Posted April 28, 2014 Hello, I want to insert some values to a table, one of these values must be typed by the client first. Here's the idea: for i = 1, 5, 1 do table.insert(someTable, {idx = i, text = myFunction()}) end function myFunction() --I'd create an editBox in a window here, and a button "OK" addEventHandler("onClientGUIClick", aButton, doClick, false) end function doClick() return guiGetText(anEditBox) end That's wrong, but that's the idea of what I want to do. How can I make the for loop not move to the next iteration but only untill the player clicks the OK button in a window?
Toffbrown Posted April 28, 2014 Posted April 28, 2014 getEventHandlers ( onClientClick, aButton ) unsure if that's what you mean?
BlueBerry Posted April 28, 2014 Posted April 28, 2014 Try using coroutines http://lua-users.org/wiki/CoroutinesTutorial
ixjf Posted April 28, 2014 Posted April 28, 2014 No, no, no. Coroutines make no sense for this purpose. What you need to do is count the times the player has clicked the button "OK" - every time it is pressed, you grab the text from the edit box and you add it to the table. Once it reaches 5, you stop it - you handle it however you want. So, something like this: local someTable = {} local GUI = {} local clickedTimes = 0 function createGUI () -- Create the GUI however you want GUI.editBox = guiCreateEdit ( ... ) GUI.buttonOk = guiCreateButton ( ... ) addEventHandler ( "onClientGUIClick", GUI.buttonOk, onOkClick, false ) end function onOkClick () if clickedTimes < 5 then -- You can handle user input here, for instance, check if the player has actually -- written anything on the edit box at all by checking if the length of the string returned from guiGetText is higher than 0 table.insert ( someTable, guiGetText ( GUI.editBox ) ) clickedTimes = clickedTimes + 1 end end
xXMADEXx Posted April 28, 2014 Posted April 28, 2014 getEventHandlers ( onClientClick, aButton ) unsure if that's what you mean? getEventHandlers is only from 1.4+
Castillo Posted April 28, 2014 Posted April 28, 2014 No, that function is working on current release ( 1.3.5 ).
Karuzo Posted April 29, 2014 Posted April 29, 2014 No, that function is working on current release ( 1.3.5 ). Someone should update the wiki page if so.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now