{"id":165,"date":"2020-06-07T12:00:54","date_gmt":"2020-06-07T12:00:54","guid":{"rendered":"https:\/\/blogs.scummvm.org\/djsrv\/?p=165"},"modified":"2022-05-25T00:25:51","modified_gmt":"2022-05-25T00:25:51","slug":"charlie-and-the-object-factory","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/djsrv\/2020\/06\/07\/charlie-and-the-object-factory\/","title":{"rendered":"Charlie and the Object Factory"},"content":{"rendered":"<section class=\"body\">\u201cAn important room, this!\u201d cried Mr. Wonka, taking a bunch of keys from his pocket and slipping one into the keyhole of the door. \u201c<em>This<\/em> is the nerve center of the whole factory, the heart of the whole business! And so <em>beautiful<\/em>! I <em>insist<\/em> upon my rooms being beautiful! I can\u2019t <em>abide<\/em> ugliness in factories! <em>In<\/em> we go, then! But <em>do<\/em> be careful, my dear children! Don\u2019t lose your heads! Don\u2019t get overexcited! Keep very calm!\u201dMr. Wonka opened the door. Five children and nine grownups pushed their ways in\u2014and, <em>oh<\/em>, what an amazing sight it was that now met their eyes!<\/section>\n<section class=\"body\"><div style=\"width: 512px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-165-1\" width=\"512\" height=\"342\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blogs.scummvm.org\/djsrv\/wp-content\/uploads\/sites\/4\/2022\/05\/Director-2-Simple-Factory-oVb2VyXqwsE.mp4?_=1\" \/><a href=\"https:\/\/blogs.scummvm.org\/djsrv\/wp-content\/uploads\/sites\/4\/2022\/05\/Director-2-Simple-Factory-oVb2VyXqwsE.mp4\">https:\/\/blogs.scummvm.org\/djsrv\/wp-content\/uploads\/sites\/4\/2022\/05\/Director-2-Simple-Factory-oVb2VyXqwsE.mp4<\/a><\/video><\/div><\/p>\n<p>That\u2019s right, the Director 2 Simple Factory example now runs in ScummVM (with some modifications to account for broken button rendering)! I had to implement several Lingo features for this movie, but the most important is, of course, factories, which are essentially Lingo\u2019s first iteration of object-oriented programming.<\/p>\n<p>For example, here\u2019s a snippet from the <code>ballBoy<\/code> factory used in this movie:<\/p>\n<pre><code>factory ballBoy\r\n\r\nmethod mNew n, entry\r\n    instance ballNum,  spriteNum, count, entryNum\r\n\r\n    set entryNum = entry\r\n    set count = 0\r\n    set ballNum = n \r\n    set spriteNum = n + 1\r\n<\/code><\/pre>\n<p>When the button in the bottom-right corner is clicked, a new <code>ballBoy<\/code> object is created and associated with a ball sprite. This object becomes the control center of the sprite, giving it logic that keeps track of how many times it\u2019s been clicked, changing its appearance, and allowing it to be dragged around.<\/p>\n<p>Factories are used extensively throughout <em>Spaceship Warlock<\/em>, so now that they\u2019re implemented, I\u2019ll be working directly on that game in the near future.<\/p>\n<p>Besides factories, this week I implemented numerous event-handling features, and I discovered and fixed a bug that prevented certain scripts in Director 2 and 3 movies from being loaded. This caused a horrifying amount of unhandled Lingo syntax in <em>The Journeyman Project<\/em> to suddenly reveal itself:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-181\" src=\"https:\/\/blogs.scummvm.org\/djsrv\/wp-content\/uploads\/sites\/4\/2020\/06\/jman-failure.png\" alt=\"\" width=\"648\" height=\"339\" srcset=\"https:\/\/blogs.scummvm.org\/djsrv\/wp-content\/uploads\/sites\/4\/2020\/06\/jman-failure.png 648w, https:\/\/blogs.scummvm.org\/djsrv\/wp-content\/uploads\/sites\/4\/2020\/06\/jman-failure-300x157.png 300w, https:\/\/blogs.scummvm.org\/djsrv\/wp-content\/uploads\/sites\/4\/2020\/06\/jman-failure-480x251.png 480w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/>Luckily, sev has now fixed all of those errors.<\/p>\n<p>Onward to more Lingo!<\/p>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u201cAn important room, this!\u201d cried Mr. Wonka, taking a bunch of keys from his pocket and slipping one into the keyhole of the door. \u201cThis is the nerve center of the whole factory, the heart of the whole business! And so beautiful! I insist upon my rooms being beautiful! I can\u2019t abide ugliness in factories! [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-165","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/posts\/165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/comments?post=165"}],"version-history":[{"count":5,"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/posts\/165\/revisions"}],"predecessor-version":[{"id":237,"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/posts\/165\/revisions\/237"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/media?parent=165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/categories?post=165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/tags?post=165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}