Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    2
  • comments
    0
  • views
    2130

Debugging my robot game on Facebook

Sign in to follow this  
Erin Margot Masterson

781 views

[code=html:1]

[color=#4b0082][font=Tahoma]This diary starts off where I have already setup the interface for user choice of robot type, robot name, and robot habitat, as well as a chat interface to chat with one's robot. I also modded a script for censorship and attributed it.[/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]I have to associate parts of sentence people say with more than one icon now, because the icons may have more meaning together if they were both in the sentence.[/color][/font][/color]

[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]////////////////////////////////////////////////////[/color][/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#ff8c00]$icons_written = "";
foreach($check_against as $key => $value) {
if(strpos($comb_unoriginal, $value) != false){
$comb_unoriginal = str_replace($value, $key, $comb_unoriginal); //replaced directly from $comb_unoriginal instead of $comb1
$icons_written = $key;
}
}[/color][/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#ff8c00]$the_array = combinations($comb1);
foreach ($the_array as $combinations_for_table){
$encode = json_encode($combinations_for_table);
if($icons_written != ""){
$sql = "INSERT INTO json_additions (addition, icons) VALUES ('" . $encode . "', '" . $icons_written . "')";
mysqli_query($conn, $sql);
}
else {
$sql = "INSERT INTO json_additions (addition, icons) VALUES ('" . $encode . "', 'none')";
mysqli_query($conn, $sql);
}
}[/color][/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]/////////////////////////////////////////////////////[/color][/font][/color]

[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]becomes:[/color][/font][/color]

[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]//////////////////////////////////////////////////////[/color][/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#ff8c00]foreach($check_against as $key => $value) {
if(strpos($comb_unoriginal, $value) != false){
$comb_unoriginal = str_replace($value, $key, $comb_unoriginal); //replaced directly from $comb_unoriginal instead of $comb1
$icons_written = array_push($icons_written, $key);
}
}[/color][/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#ff8c00]$the_array = combinations($comb1);
foreach ($the_array as $combinations_for_table){
$encode = json_encode($combinations_for_table);
if(count($icons_written)>0){
$sql = "INSERT INTO json_additions (addition, icons) VALUES ('" . $encode . "', '" . $icons_written . "')";
mysqli_query($conn, $sql);
}
else {
$sql = "INSERT INTO json_additions (addition, icons) VALUES ('" . $encode . "', 'none')";
mysqli_query($conn, $sql);
}
}[/color][/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#ff8c00]////////////////////////////////////////////////////////[/color][/font][/color]

[color=rgb(0,0,0)][font=Tahoma][color=#ff8c00]I've got to remove the toggle on and off of the emotes and icons display window and simply show the window on login.[/color][/font][/color]

[color=rgb(0,0,0)][font=Tahoma][color=#ff8c00]Removed:[/color][/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#ff8c00]////////////////////////////////////////////////////////[/color][/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#ff8c00]function toggleEmotes() {
$("#emoteToggle").click(function() {
$("#emotes").toggle("slow");
});
}[/color][/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]////////////////////////////////////////////////////////[/color][/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]and raw content of the function in another part of the file index.php[/color][/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]and removed all toggleEmotes() calls. Added $("emotes").fadeIn(); near the beginning of the login function.[/color][/font][/color]

[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]Reverted file back to containing the toggle, because I just realized that perhaps the document ready function that hid the emotes initially was also hiding it whenever toggle attempted to show it. Turned out I called the function multiple times, so the document ready function wasn't the problem. I kept a single toggle call directly within the code that occurs after login, and the unfortunate behavior of toggle making the emotes appear and then disappear, or disappear and then reappear, vanished.[/color][/font][/color]

[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]Then I remembered that I may have deleted the toggle button that shows up when coming to the game from the interface the user sees when first starting the game, namely the choice of robot and habitat. To test for this, I wiped clear the content of the tables that tell the checkidentity.php file that the identity of the person and their choices already exists in the game. It will always repopulate if I go through that interface again. Now the login button stopped working, but the first page of the interface remains intact. I must investigate.[/color][/font][/color]

[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]I reverted the file and got warnings appearing on the second interface page. The error is in check_bot_name, t he file that checks the bot's name. Boolean was given, the error says. I realized I shouldn't have used the triple-equals type operators, because they equate items to variable type as well as value. But that isn't the problem, after all. It's persisting. Then I looked at the table and realized I changed the table name and the table reference no longer exists and equated to false, causing "boolean given" error reprocussions.[/color][/font][/color]

[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]That problem is fixed; however, the main screen doesn't appear after the setup interface. The interface is broken, too. The program says that the naming of the robot is a success, and shows the next screen where one chooses an environment for the robot. But then when one chooses that, a blank screen comes up. I look at the database, and sure enough, there's an issue. The naming screen was saying that the name was taken, along with the "boolean given" warnings before I corrected that, but now it's saying "success" during a failure! And not showing the main screen. I know what's going on. I didn't change anything about the files surrounding the naming. The only thing I changed was the name of the table that records the bot names. Therefore, the reason why it said the name was taken when the name of the table was mismatching in the check_bot_name.php file was because I told the computer to do that if the number of rows in the table was not equal to zero, display that message. What I really meant was greater than zero, but the number wasn't zero or any other number, since the reference to the table itself was incorrect. Therefore, the true value was either false or null, making it fit the inequality condition.[/color][/font][/color]

[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]As for "success" popping up where there was no success, again the computer simply did what I told it to do: it found the right number of characters in the name input and zero number of rows in the datatable of names, which was supposed to indicate that the same name wasn't chosen. But the true success or failure occured immediately after the word "success" was thrown. The return of the word "success," into that particular part of the page (div) where it was supposed to appear, triggered an attempt to insert the word into the database, but it clearly failed, since the word never appeared there. I can only conclude that the table was misspelled in the insertion SQL commands into the database, as well. I corrected the misspelling. Then, I put back the document ready function and the latter half of the index.php script, and the issue was corrected.[/color][/font][/color]

[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]After that, I found that, upon entering the game through the setup interface, the emote display toggle button didn't work. Instead of placing the function directly in the login function, I should nest it deeper and in two locations. Then I realized that putting it in both places would counteract the functionaity of the other, since, necessarily, the first would not be nested further in than immediately inside the login block. At any rate, the button was unimportant, so I would remove it from checkidentity.php, where it originated, and then clean up the functions that operated on it in the homepage. Then I realized I need to remove some of the entries sending the emote window from the checkidentity.php file that handles database entries in order to synchronize the emotes appearing along with the flow of information, so I removed some of the emote variables from checkidentity.php. If it's not there at certain times, the page can't show it! First I have to remove it from the index.php page. It didn't show up on the main page because the index.php page doesn't check with the checkidentity.php file before it does what it does. I should correct that. Wait. That isn't the problem. I had the main screen showing up in two places in checkidentity.php. If I had re-selected using SQL to check in the middle of the previous condition. The previous condition needed to yield the same results. It's working now.[/color][/font][/color]

[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]I find that the censorship functionality I modded from the script I attributed, adding my own function, is now censoring the word "grass" because it contains a certain three-letter word. I'm going to remove it from the main list of curses, then explode the sentence, and if one of the words exactly matches (case insensitively) the three-letter word, then the word will have stars added to it, and regardless of whether any word in the for loop iterating through is profane or not, it gets added to a new array, which is then joined by spaces to form the revised sentence. When I come up with more words that should only be censored when alone or with a space or two surrounding them, I will make a list of such words, including the one I'm starting off with now.[/color][/font][/color]

[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]The bottom of the function was:[/color][/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]////////////////////////////////////////////////////////[/color][/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]$words = explode(",", $wordlist);[/color]
[color=#ff8c00]$comment_lower = strtolower($comment);
foreach($words as $word){
if(strpos($comment_lower, $word) !== false){
$comment = str_ireplace($word, addStars($word), $comment);
}
}
$comment = str_ireplace("h**lo", "hello", $comment);
return $comment;[/color][/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]////////////////////////////////////////////////////////[/color][/font][/color]

[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]and became:[/color][/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]/////////////////////////////////////////////////////////[/color][/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#ff8c00]$words = explode(",", $wordlist);
$comment_to_lower = strtolower($comment);
$sentence = explode(" ", $comment_to_lower);
$regular_case_sentence = explode(" ", $comment);
$insert_sentence_array = array();
for($i=0; $iif($sentence == "ass"){
array_push($insert_sentence_array, str_ireplace("ass", addStars("ass")));
}
else {
array_push($insert_sentence_array, $regular_case_sentence[$i]);
}
}
$comment = implode(" ", $insert_sentence_array);
$comment_to_lower = strtolower($comment);
foreach($words as $word){
if(strpos($comment_to_lower, $word) !== false){
$comment = str_ireplace($word, addStars($word), $comment);
}
}
$comment = str_ireplace("h**lo", "hello", $comment);
return $comment;[/color][/font][/color]
[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]////////////////////////////////////////////////////////////[/color][/font][/color]

[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]I have to update the local url to insert the image I moved to the bot_img folder from the assets_and_scenes image folder. The image source still reflects the first folder. When I tested the interface flow again, I found that the naming page would not display. It turned out I'd forgotten to empty the datatables, and because the program saw two entries instead of one in the robot names table, and it wasn't designed to support a situation in which there were more than one default robot, a blank page came up. I removed all the data from the user table, and sure enough, the interface was no longer broken. However, when I refreshed and logged in again, I got a different blank screen. In the database, the wrong name of the robot is entered. Now it's right, though, when I tested it again, and no matter which items are picked, I still get the blank screen.[/color][/font][/color]

[color=rgb(0,0,0)][font=Tahoma][color=#4b0082]Looks like I misplaced a bracket! A code block that means something different than the conditional block it's in won't function. Now that that's fixed, it's time to give the icons meanings. More soon![/color][/font][/color]

Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!