I've already implemented a textbox into my project, and here's what the function looks like right now.
Code: Select all
int showtextbox(const char* text, int delay = 0)
{
//show text box with text
if( delay != 0 )
{
Time TextBox Initiated = SDL_GetTicks();
TextBoxTimerStarted = 1;
Time After Which To Close Textbox = delay;
}
return 0;
}
This works fine for hard-coded function calls.
Calling showtextbox from lua:
Code: Select all
int luashowtextbox(lua_State *L)
{
//grab text and delay from lua stack
showtextbox( text, delay );
return 0;
}
I can only think of two solutions to this problem: 1) somehow tell the lua script to sleep for the same amount of time as the textbox's delay (not sure if sleeping is possible in lua?) or 2) create a queue that will store a predetermined number of textbox calls, and display one after another until the queue is empty (the only way i would know how to do this is an array of structs).
Which, if either method would you choose, or how would you change my textbox method altogether?
Feel free to provide support as your time allows. Any feedback is greatly appreciated :P.