Hi lövers !
Do you know any way to use io.read() without blocking the game ? I have a console attached to my game and want the player to be able to enter commands in it while playing (to connect to a multiplayer server, change skin, etc... this will avoid me to overcharge my game with a UI layer).
When I use io.read(), it blocks everything and waits for the player input. It's fairly normal when you think about it twice, but how to do this the async way ? (always listen for user's input, and call a callback function when he has entered something)
Thanks guys
[Solved] Using io.read without blocking the game ?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[Solved] Using io.read without blocking the game ?
Last edited by Zamp on Mon Feb 10, 2014 12:55 pm, edited 1 time in total.
Re: Using io.read without blocking the game ?
Use a thread/channel to collect input, and send a message when the user input is completed.
Info on making channels in 0.9.0:
http://love2d.org/forums/viewtopic.php?f=4&t=76670
You can find the thread functions for 0.8.0 on the wiki if you're using that.
Info on making channels in 0.9.0:
http://love2d.org/forums/viewtopic.php?f=4&t=76670
You can find the thread functions for 0.8.0 on the wiki if you're using that.
Re: Using io.read without blocking the game ?
Cool, I will try that. Thanks
Edit: It works perfectly, thanks again !
Edit: It works perfectly, thanks again !
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 5 guests