2011/01/25 (Villainmad): Reboot!
"Hey, Muffin, where's Villainmad been?" I am glad you asked, imaginary person who asks questions! The answer is that I have been 1. wrapping my head around Lua, and 2. basically starting the programming, if not from scratch, then certainly from sniff. (You may also have noticed that Create.swf Adventures is taking up a considerable amount of attention, too.) Another distraction is that it seems like every third time I start doing some Major Coding, I discover that I'd been spending like an hour doing entirely the wrong thing, because I'd overlooked some miniscule detail that was causing things to Not Work.1 That's cool, though; it means I'm catching that sort of thing early on. And it's not like I'm being paid for speed or anything ...
Anyway, my biggest challenge at the moment is figuring out exactly how I'm going to get "queue commands" from the Lua system into the C# system. The Easy Way™ is to implement LuaCode that looks something like:
which means "Execute that string six frames from now" without bothering itself with whether "stage.DoTheSpinnyThing(5)" is valid. (I'm going to decree that all variables and functions which are specific to a given stage (i.e. non-global) must belong to a Lua table named "stage" to make it easier to get rid of everything stage-specific at the end of the stage.) On the C# end of things, it stores "(current number of frames since stage began) + 6" in as integer and "stage.DoTheSpinnyThing(5)" as a string, and when the time comes, it goes, "Hey, Lua! Execute this string!" I suppose that works as well as anything else, and it isn't all that convoluted. You win some, you lose some, but I welcome suggestions from people who are more experienced with getting information between C# and Lua.
Now, the other thing is, Lua doesn't know object-oriented programming, but if you hum a few bars, Lua can definitely fake it. The problem, however, is this: how do you get it to point at this particular instance of the new object? The answer which immediately came to mind is that, when constructing a new object, you use the name of the variable to which you are constructing it in the instance itself! So you'd do something like:
--The second agument is named "this" stage.spoonerism = SpinnyThingObject:new(9, "spoonerism")
and then, within one of the object-functions itself:
spoonerism = QueueCommand(6, "stage."..self.this..":SpinOnce()")
And it will work just fine! See? It makes PERFECT sense! (Warning, link leads to TVTropes. Muffin will not be held responsible for hours of time lost as a result of following it.But see also this disclaimer)
... I need to start this whole plan over. It's a good thing I haven't actually coded any of this yet ...
1For example: I had a class for controlling "the current game." It had both a variable in the main Game class, and it had been added to the Game class's List Of Components. When I wanted to run the "start a new game" code, it created a new instance onto the variable and added it to the list of components ... but I didn't remove the old instance from the list of components, which meant that the system wasn't actually getting rid of it.
Previous: 2011/01/02 (Villainmad): Thinking Out Loud, Sequences, and Closed File Formats
Next: 2011/02/03 (Villainmad): Object-Disoriented Design
Back to Villainmad
Back to My Games
Back to Main Page