Charlie and the Object Factory
“An important room, this!” cried Mr. Wonka, taking a bunch of keys from his pocket and slipping one into the keyhole of the door. “This 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’t abide ugliness in factories! In we go, then! But do be careful, my dear children! Don’t lose your heads! Don’t get overexcited! Keep very calm!”
Mr. Wonka opened the door. Five children and nine grownups pushed their ways in—and, oh, what an amazing sight it was that now met their eyes!
That’s 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’s first iteration of object-oriented programming.
For example, here’s a snippet from the ballBoy
factory used in this movie:
factory ballBoy
method mNew n, entry
instance ballNum, spriteNum, count, entryNum
set entryNum = entry
set count = 0
set ballNum = n
set spriteNum = n + 1
When the button in the bottom-right corner is clicked, a new ballBoy
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’s been clicked, changing its appearance, and allowing it to be dragged around.
Factories are used extensively throughout Spaceship Warlock, so now that they’re implemented, I’ll be working directly on that game in the near future.
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 The Journeyman Project to suddenly reveal itself:
Luckily, sev has now fixed all of those errors.
Onward to more Lingo!