gearleaf

Viewing posts tagged 'vclua'

One Step Forward, Two Steps Back

Shamus

I had a particularly unproductive week and weekend. I intended to have VClua working with a handful of demos, and to have the first chunk of code set up on my first flixel project.

Unfortunately, I only managed to get VClua working with one demo -- Demon Lord Adventure I -- and then in the process of getting it working with the second target demo, I've broken it. It won't compile DLA1 anymore, and when it tries to compile my other demo it actually gets itself into an infinite loop spitting out Lua code. Eventually (after several minutes) it runs out of memory and crashes. Hyuu.

And I didn't get to my flixel game at all.

Good times in Gruedorf. I'll have something better next week.


Edit (~10 minutes later): Okay, guess I just needed to get that out of my system. A few minutes of looking at VCLua fixed the problem so that it now works with DLA1 again. My crappy space shooter demo that I dug up somewhere is still doing the infinite loop thing, but at least I'm not worse off than I was before.

Most of the changes that have happened have just been miscellaneous bug fixes. One biggish change I made was to the tokenizer though; the tokenizer will now (usually) look for the token you're asking for specifically, rather than looking for any token that it can. Honestly I'm not sure why I did it that way to begin with.

Since there was actually progress, I updated the git repo. https://github.com/speveril/VCLua, as usual.

On to Testing

Shamus

So, I've done the final stretch on what I think of as "blind implementation" for VCLua. I was writing small little test programs to try out each feature as I added it, but I hadn't yet done any trials on bigger, actual games that I know run on the VergeC VM.

To quickly sum up, I've added...

  • Switch statements
  • Operator chaining (so you can now say x = 1 + 2 + 3; before you were limited to just one operator with a left-hand side and right-hand side)
  • Unless statements (which I didn't even realize Verge had until today)
  • Multiple declarations on a single line
  • Small miscellaneous bug fixes

So with that stuff done, I've moved on to actually testing out support for using this within Verge. I set my sites, to begin with, on Demon Lord Adventure, a tutorial written by Glambourine a while back. It's small and simple, so it's a good place for me to start.

Unsurprisingly, it didn't run right away. It didn't take me too long to iron out the immediate bugs, though, and before long I had it actually running! ... Until it needed to load the map. I completely neglected to take into account the fact that the maps need to load VC code as well. Anyway, a quick work around there, and the map is loading. Now I need to deal with v3's builtin structs, like curmap and entity. I thought this might just work, but I was wrong.

In any case, things are looking good so far, so I'm optimistic that I'll be able to wrap this project up by the end of January. You can check out my progress over at github, https://github.com/speveril/VCLua.

I've already started concept work on my first game for the year. Don't have a lot to say about it other than it will be Flixel-based game (so, in Flash) with an actiony Zelda-style gameplay, and I'm working on it with at least one other dude, possibly two. I'll have more to talk about on that in the coming weeks. I've also been mentally churning away on ideas for a second game, which I will probably be starting in tandem with this one, and working on solo. It will be a short RPG built in Verge, probably with the VCLua as a way to exercise it.

Have a good one!

No More Excuses

Shamus

On the VCLua front, two new big things: actual preprocessor support (#includes and #defines, and also #undef for good measure) and bit-wise operators. Also, in an under-the-hood change, I changed my straight up naive recursive-descent parser to a packrat parser. You can read more about those elsewhere, but the bottom line is that it is an order of magnitude (or two) faster. I've worked on a few other things but they aren't working completely yet, so they aren't pushed up to github.

You can check out my current work-in-progress at https://github.com/speveril/VCLua.

Aside from that, a new year started. Hooray and all that, I suppose. As cliché as it is, I find myself getting unnecessarily introspective around the new year. I take time off so I have more time to think, and I often end up visiting my parents -- being in the place that I grew up always fills me with a mix of nostalgia, introspection, and unrest.

Anyway, a few weeks ago when this was beginning again, I came to a decision about 2011. Historically speaking I am terrible at finishing the games I start, and sometimes I'm terrible about starting them at all. I'm sick of this. As soon as I finish VClua (which should be soon; it's very close to being usable and I'm getting pretty tired of it), I am going to throw myself at my goal for the year:

I will make and complete at least six games in 2011.

Six games is a laughably small number when I look at the output of more seasoned indies, but it's more than the total number of completed games that I've produced to date. I figure that for me at the moment, it is a tough but achievable goal. And I mean it when I say "at least"; if I finish six games before the year is out I won't rest on my laurels. I'll make more and then take it as a sign to set my goal number higher for 2012. On the other hand, I am fully aware that I may find myself needing to make four Ludum Dare-style 48 hour games next December. We'll see what happens.

It is questionable whether any of these games will be Geas. I'm certainly not abandoning Geas, but I have been strongly considering working on smaller side games before jumping back onto that train so I can get better and faster at making games and art, so I can get a few finished projects under my belt and out there, and so I can try out some of the systems and ideas I've got for Geas in a smaller testbed.

I've already drummed up a few handfuls of ideas, so I'm going to be sorting through them and deciding which are best, and what order I'd like to work on them. I should have something to say about my first project(s) in the next couple of weeks.

So anyone interested in taking up this challenge and making 2011 a 6+ game year with me?

Structs

Shamus

Sorry about the late update. I was pretty crazy busy for the week after my last post, and then my Christmas vacation started and I ended up travelling and computerless for a few days. Then yesterday, when I intended to finally make good on my missed Gruedorf, I ended up sleeping for pretty much the whole day.

Anyway, I've just added in basically one straight shot just now, support for structs. As described in the Verge docs, a struct basically lets you declare a new data type. You can then declare a variable of this new data type.

Like with arrays, the structs are already slightly more flexible than "real" VergeC. You must declare the struct in a global scope, but you can declare instances of that struct globally or locally. Also like with arrays, there aren't particularly strong locks on structs yet: you can add parameters not defined in the struct to a particular instance if you want, and it won't stop you. I will probably add these checks later -- VergeC is supposedly a strongly typed language and so that's the route I should go with these things.

Here is where I'd normally go into more detail, but the implementation is currently kind of gross and honestly I'm not sure how brittle it is, so it may change. In short: When I encounter the struct declaration, I save that chunk of the AST into VergeC.typedefs with a key of the name. Then, whenever I declare a variable of that type, I compile that AST chunk right into the source, producing a table with all of the defaults filled as detailed in the struct declaration.

A tangential thing that I had to get working was supporting index (both as an array and as an object) chaining. In other words, you can now write...

foo[5].bar.baz[2][3] = 7;

... and assuming everything actually does make sense there, it should work.

My next big thing, I think, will be making the preprocessor actually do something. #defines should be fairly straightforward, but #include will be trickier from the standpoint of error reporting. I'm currently torn between doing a for-reals include and just patching the other file right into my working source, or doing an actual separate compile pass on the #included file. They each have their benefits. I'm sure I'll figure it out.

I intend to update again this coming weekend to try and get myself back on my previous updating schedule. Maybe on New Year's. We'll see!

You can check out my current work-in-progress at https://github.com/speveril/VCLua.

Continue

Shamus

Been somewhat braindead this week so I have a relatively small update. I've basically accomplished one thing: a continue statement.

A continue statement may not seem like a big deal, but it turns out: Lua doesn't have one. It's fairly common in other languages, and was included in VergeC. Turns out it's actually a tricky beast to implement if it's not built in to your target language.

So at first I thought I'd just be tricky and use goto to jump to the end of the loop. This idea was pretty quickly discarded when I realized that Lua doesn't have that either.

Next, visions of directly access Lua's stack danced through my head (is it even possible? how would I do it?). Or maybe going into Verge and just adding a continue statement right into the language (how would this work?).

Anyway in true VCLua fashion the final working product is way more hackish and gross, but it works and it works now. Basically, I now double all of my loops. The outside loop is your usual while-loop (with extra trappings if it's actually a for-loop). The inner loop is a repeat-until-loop, with the "until" being true. The actual loop code goes inside there. This loop will always run exactly once; repeat-until will always run at least once, but it runs only until its clause is true. Since the clause is literally true it will only run the once. Anyway, this means that my continue just becomes a break; it breaks out of the inner loop and lets the outer loop keep running. A break statement sets a flag and then does an extra break to get out of the outer loop as well.

So in the end it means that...

    for (int i = 0; i < 10; i++) {
        if ( i == 5) continue;
        if ( i == 7) break;
        log(i);
    }

... becomes ...

do                                                                 -- keep a local scope
   local i = 0                                                     -- int i = 0
   while VergeC.runtime.truth(VergeC.runtime.op.OP_LT(i, 10)) do   -- the outer loop (i < 10)
      repeat                                                       -- the inner loop
         if VergeC.runtime.truth((i) == (5) ) then                 -- if (i == 5) continue
            do break end;
         end;
         if VergeC.runtime.truth((i) == (7) ) then                 -- if (i == 7) break
            do VergeC.fullbreak = true; break end;
         end;
         v3.log(i);                                                -- log(i)
      until true                                                   -- end of the inner loop
      (function() i = i + 1; return i - 1; end)();                 -- i++
      if VergeC.fullbreak then VergeC.fullbreak=false; break end   -- handle actual breaks
   end                                                             -- end of the outer loop
end;                                                               -- end our local scope

Eventually I will probably do some inspection on the AST to check to see if I NEED the double loop and the fullbreak handling. Later though.

You can check out my current work-in-progress at https://github.com/speveril/VCLua.

Older »