|
help with a text box
#335284
07/27/10 16:45
07/27/10 16:45
|
Joined: Jul 2009
Posts: 80 Area 51
fangedscorpion
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2009
Posts: 80
Area 51
|
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:
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;
}
"Pow! You are dead! Not big suprise!" -Heavy
|
|
|
Re: help with a text box
[Re: bodden]
#335467
07/28/10 18:18
07/28/10 18:18
|
Joined: Jul 2009
Posts: 80 Area 51
fangedscorpion
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2009
Posts: 80
Area 51
|
These are my global variable definitions:
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
"Pow! You are dead! Not big suprise!" -Heavy
|
|
|
Re: help with a text box
[Re: fangedscorpion]
#335538
07/29/10 00:20
07/29/10 00:20
|
Joined: Apr 2006
Posts: 737 Ottawa, Canada
Ottawa
User
|
User
Joined: Apr 2006
Posts: 737
Ottawa, Canada
|
Hi!
is something missing with the section STRING* clean_checking = "
From the manual : STRING* empty_str = "";
Hope this helps! Ottawa Ver 7.86.2 Pro and Lite-C
|
|
|
Re: help with a text box
[Re: Ottawa]
#335539
07/29/10 00:31
07/29/10 00:31
|
Joined: Jul 2009
Posts: 80 Area 51
fangedscorpion
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2009
Posts: 80
Area 51
|
No, I just made a super long empty string when I could have done it differently.
"Pow! You are dead! Not big suprise!" -Heavy
|
|
|
Re: help with a text box
[Re: fangedscorpion]
#335543
07/29/10 06:28
07/29/10 06:28
|
Joined: Sep 2007
Posts: 62 Germany
bodden
Junior Member
|
Junior Member
Joined: Sep 2007
Posts: 62
Germany
|
This
if ((checking_string_var = str_cmp(chat_text_line2, clean_checking)) == 1)
is always true. I think, what you want to do is
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?
|
|
|
Re: help with a text box
[Re: bodden]
#335588
07/29/10 14:34
07/29/10 14:34
|
Joined: Jul 2009
Posts: 80 Area 51
fangedscorpion
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2009
Posts: 80
Area 51
|
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?
Last edited by fangedscorpion; 07/29/10 17:57.
"Pow! You are dead! Not big suprise!" -Heavy
|
|
|
|