help with a text box

Posted By: fangedscorpion

help with a text box - 07/27/10 16:45

I have created a simple textbox code, but whenever I use the code, it works for about 3 times and then freezes the game. Any ideas? Here is the code:

Code:
function check_line_text()
{
	
	checking_string_var = str_cmp(chat_text_line1, clean_checking); //checks the string line against the clean string to see if it is used already (1 is a yes  0 is a no)
	if(checking_string_var == 1)
	{
		chat_line_number = 1;
		str_cpy(chat_text_line1, chat_text);
		make_playername_string(1);
	}
	if((checking_string_var = str_cmp(chat_text_line2, clean_checking)) == 1)
	{
		chat_line_number = 2;
		str_cpy(chat_text_line2, chat_text);
		make_playername_string(2);
	}
	if((checking_string_var = str_cmp(chat_text_line3, clean_checking)) == 1)
	{
		chat_line_number = 3;
		str_cpy(chat_text_line3, chat_text);
		make_playername_string(3);
	}
	if((checking_string_var = str_cmp(chat_text_line4, clean_checking)) == 1)
	{
		chat_line_number = 4;
		str_cpy(chat_text_line4, chat_text);
		make_playername_string(4);
	}
	if((checking_string_var = str_cmp(chat_text_line5, clean_checking)) == 1)
	{
		chat_line_number = 5;
		str_cpy(chat_text_line5, chat_text);
		make_playername_string(5);
	}
	if((checking_string_var = str_cmp(chat_text_line6, clean_checking)) == 1)
	{
		chat_line_number = 6;
		str_cpy(chat_text_line6, chat_text);
		make_playername_string(6);
	}
	if((checking_string_var = str_cmp(chat_text_line7, clean_checking)) == 1)
	{
		chat_line_number = 7;
		str_cpy(chat_text_line7, chat_text);
		make_playername_string(7);
	}
	if((checking_string_var = str_cmp(chat_text_line8, clean_checking)) == 1)
	{
		chat_line_number = 8;
		str_cpy(chat_text_line8, chat_text);
		make_playername_string(8);
	}
}

function init_textbox()
{
	
	if(is(show_chat, SHOW))//if the main chat is shown
	{
	toggle(show_chat,SHOW);//turns off the main chat text box (if it is visible)
	}
	
//	make_playername_string(); 
	
	set(text_box, SHOW);//shows the type in chat box
	
	inkey_value = inkey(text); //gets the chat text
	
	str_cpy(chat_text, text);//copies the chat text for the main chat text box
	
	blank_chat_text = str_cmp(chat_text, chat_text_plain);//checks to see if the chat_text is blank in case pressed esc or something returns 1 if it is blank 0 if it is different
	
	
	//str_cpy(chat_text_line1, chat_text);//sends the chat line to the 1st line display on the chat_text panel
	
	toggle(text_box,SHOW); //hides the type in chat text box
	
	if (blank_chat_text != 1 && inkey_value != 27)//if the chat_Text is empty dont show a blank text
	{
	check_line_text();
	set(show_chat, SHOW);//unhides the main text box
	}
	
	str_cpy(text, clean);
	
	//pan_setdigits(show_chat, 0, value_x, value_y, "%.f", courier, 1, 0);
	//value_y += 18;
}


Posted By: bodden

Re: help with a text box - 07/28/10 06:55

Could you post the definition of the global vars as well? If blank_chat_text is a string, I think, you cannot use

Code:
if (blank_chat_text != 1


Posted By: fangedscorpion

Re: help with a text box - 07/28/10 18:18

These are my global variable definitions:

Code:
STRING* text = "                                                                                                                               ";
STRING* chat_text = "                                                                                                                                ";
STRING* chat_text_plain = "                                                                                                                                ";
//string for emptying the textbox when it is shown again
STRING* clean = "                                                                                                                               ";


/////////////////////////////////////////////////
//these chat_text_lines correspond to the lines of text
//from the chat text box
//
////////////////////////////////////////////////
STRING* clean_checking = "                                                                                                                               ";
STRING* chat_text_line1 = "                                                                                                                               ";
STRING* chat_text_line2 = "                                                                                                                               ";
STRING* chat_text_line3 = "                                                                                                                               ";
STRING* chat_text_line4 = "                                                                                                                               ";
STRING* chat_text_line5 = "                                                                                                                               ";
STRING* chat_text_line6 = "                                                                                                                               ";
STRING* chat_text_line7 = "                                                                                                                               ";
STRING* chat_text_line8 = "                                                                                                                               ";


FONT* arial = "arial#20bi";

STRING* playername = "FANGED SCORPION"; //this sets up the string for getting the player's name
//STRING* playername2 = "FANGED SCOPRION"
STRING* playername1 = "";
STRING* playername2 = "";
STRING* playername3 = "";
STRING* playername4 = "";
STRING* playername5 = "";
STRING* playername6 = "";
STRING* playername7 = "";
STRING* playername8 = "";

STRING* DEBUG_STRING = ""; ///REMOVE THIS BEFORE RELEASE!!!!!!!!!!!!!!
 
var blank_chat_text = 0; //this value is used to compare the updated chat_text to the original chat_text (1 means strings are same 0 is no)

var inkey_value;//checks the inkey value if the inkey functio nwas terminated

var chat_line_number = 1; //this var helps to scroll the text as the var is increased, higher number = next line of text on chat_text panel

var checking_string_var;//string is empty if this is 1 ((((can put in the check line text if need to)

int value_x = 0; //the x value of the digits for the main chat box
int value_y = 16; //the y value of the digits for the main chat box


Posted By: Ottawa

Re: help with a text box - 07/29/10 00:20

Hi!

is something missing with the section
STRING* clean_checking = "

From the manual : STRING* empty_str = "";
Posted By: fangedscorpion

Re: help with a text box - 07/29/10 00:31

No, I just made a super long empty string when I could have done it differently.
Posted By: bodden

Re: help with a text box - 07/29/10 06:28

This
Code:
if ((checking_string_var = str_cmp(chat_text_line2, clean_checking)) == 1)



is always true. I think, what you want to do is

Code:
if (str_cmp(chat_text_line2, clean_checking) == 1)



This does not cause the freezing of the game, but it may help you at another place.

Freezing often happens, because you've forgotten to place a wait(1) inside a loop. There is no loop inside your posted code, but maybe, somewhere else?
Posted By: fangedscorpion

Re: help with a text box - 07/29/10 14:34

I think I figured out what the error was. Whenever I was trying to add the string format (": %s") to the end of a player's name, it would give me an error by the 3rd time through.

Also does anyone know a way to make some of the text on the panel disappear after 10 seconds or so?
© 2024 lite-C Forums