Jump to content
  • Advertisement

Erin Margot Masterson

  • Content count

  • Joined

  • Last visited

Community Reputation

101 Neutral

About Erin Margot Masterson

  • Rank
  1. Erin Margot Masterson

    Debugging my robot game on Facebook

    [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; $i
  2. [color=#4b0082][font=Tahoma]The second week of June 2014, I am debugging an eCard application in Flash Actionscript 3.0, where the goal is to superimpose dynamic text on a specific purpose (including fonts).[/font][/color] [color=rgb(0,0,0)][font=Tahoma][color=#4b0082]The first few hundred errors were mostly related to typing errors, since it it a long program, but some were also illegal coercions to other types, usually when I had attempted to employ function arguments of a different type than their execution. I fixed many mismatched return statements, missing return statements, missing argument types, and missing output types. The compiler error window generally showed me series of errors for each class one-by-one, although a few of the errors were involving relationships between the classes, especially when I thought I was going down the home stretch after 2 days on 1500 lines of code.[/color][/font][/color] [color=rgb(0,0,0)][font=Tahoma][color=#4b0082]At around 12:40 on June 12, 2014, I eliminated all of the errors. My Hello World! test worked out and outputted just fine, but there was still a problem or two, and the superimposed text would not appear. The issue was with a null object related to properties or methods in three different methods. I was taken aback at first, but realized easily that I had to attend the classes upon the order of their dependency on one other, which is common, I think, in debugging practice. That is to say, one method called another and that called the third, so I should go in reverse 3, 2, 1. I found that I was missing some type definitions in my parameters, and when I corrected that, I found that it was throwing three more errors related to the content in that function. I was pleased. Normally those problems in the function should have been detected instantly, which meant I had just opened up a door to code that had been blocked off.[/color][/font][/color] [color=rgb(0,0,0)][font=Tahoma][color=#4b0082]Still had the same problem. I decided to enter Debug mode. I hadn't used it before, but hoped it would show me what line my error was at, and turns out it did. I thought at first it was a problem with the "this" keyword, but that didn't make sense, since the keyword should be able to be used freely throughout the class to reference itself. So, that eliminated, I looked at the variable I was assigning this's properties to, and sure enough, they weren't initialized. One more runtime error I corrected: a dot had to be replaced with a + sign after migrating to Actionscript. Then it worked perfectly, and the words appeared on the movie dynamically! Still there were some type-mismatch glitches and grammar in the text itself was improved by me, as well.[/color][/font][/color] [color=rgb(0,0,0)][font=Tahoma][color=#4b0082]New: I tried to compile my UnityScript (Javascript) for my game and got this syntax error: BCE0044: expecting :, found ','. I fixed it by removing a bracket and adding whitespace on the sides of my colons. Then I got this error: BCE0044: expecting ], found ':'. I corrected this and several others by inserting a missing key and curly bracket before it. BCE0044: expecting }, found 'funnySerious'. (Missing comma.) BCE0044: expecting }, found 'name2'. (Added missing concantenation operator.) Next I replaced a concantenation operator with a comma. Removed a curly brace. After some time, I got rid of the syntax errors, and the regular errors began to appear. I had an error involving trying to concantenate into an Object with += and I corrected this by declaring the type of the brackets as an Array and using the push method. I replaced some properties references with brackets and keys in quotes, fixing some "is not a member of 'Boo.Lang.Hash'" errors.[/color][/font][/color] [color=rgb(0,0,0)][font=Tahoma][color=#4b0082]I progressed through a great deal of restructuring of my code, moving from arrays to Lists when the compiler interpreted my arrays containing a specific type as Object.[/color][/font][/color]
  • 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!