This doesn’t have anything with code or Javascript, but I just love playing the games I played when I was younger. The Settlers, Incubation and Sam and Max are at the top of the list, but in the racing section Carmageddon is just below Screamer and Ignition and even pulls ahead of Twisted Metal 2 and Destruction Derby.

And now they’re making a new game. In case you do not know: Carmageddon is a mixture of car racing and arena fighting, much like the better known Twisted Metal series. It’s also a very tasteless game where you get bonus points for running over pedestrians… you’ve got to realize that this game was made when the discussion about how violence in games influences people in real life was at an all time high. Carmageddon made fun of the whole discussion by making it clear that games have nothing to do with reality: Ironically it was censored in Germany with flying bombs instead of pedestrians because the consors were unable to see that.

Personally I think that the discussion about violence in games was (and still is) heading in entirely the wrong direction: Instead of educating people and teaching them that a computer is not a magic box we still act as if any of that stuff happening on screen was real.
The pixels we see on the screen have no more to do with real persons than children playing cops and robbers with a real gunfight. It’s just polygons, pixels and a bit of math… nothing more. That’s what we should get across and Carmageddon was a not-so-subtle nudge in that direction.

Anyway, they’re still trying to get the funding over at and while I think the concept of Kickstarter will have to evolve at some point beyond the non-monetary-reward thing they’re doing now, I think in this case there’s enough talent (and they have invested enough of their own money) that it’s likely that they’ll get the game done. They’re not asking for much… $15 for what amounts to preordering the game and I think that’s fair. I’ve given $25 because I want access to the beta, which I still think is very reasonable.

Kickstarter Project Page

Scripting the windows commandline with Spidermonkey made easy

I frequently have to automate really simple tasks, like moving files with a certain filename to another directory and the Spidermonkey shell that now comes with XULRunner (thank you for that Mozilla, building it yourself was time-consuming and annoying) has become an invaluable tool.

Few people know how easy it is to use any Mozilla-JS based program (yes, that includes XULRunner and Firefox) to work with commandline programs. As with any other programming environment you just need to be able to call the popen function of the OS, which runs any command and returns the output as a stream.

Mozilla-JS does not include POPEN. However it does support CTYPES, a system for calling libraries. On Windows POPEN and everything else you need is in MSVCRT.

Opening MSVCRT with CTYPES is easy:

var msvcrt ="msvcrt");

Now you just need to declare what functions you need (_popen, _pclose, feof and fgetc in our case) and what types these require (first parameter is the name, second the interface type, third is the return type and everything else is the type of each argument):

var popen=msvcrt.declare("_popen",ctypes.winapi_abi,
var pclose=msvcrt.declare("_pclose",ctypes.winapi_abi,,ctypes.void_t.ptr);
var feof=msvcrt.declare("feof",ctypes.winapi_abi,,ctypes.void_t.ptr);
var fgetc=msvcrt.declare("fgetc",ctypes.winapi_abi,

With this you can very easily build something like C’s SYSTEM call, just with the difference that it will return everything the program outputs through STDOUT:

function system(cmd,raw){
/* Open the program (Windows automatically
   uses cmd.exe for that), use raw mode
   if requested. */
    var file=popen(cmd,"r"+(raw?"b":""));

    var o=""; // STDOUT content
    var end=false; // End of STDOUT reached

/* Loop trying to get a character from STDOUT
   until feof informs us that the end of the
   stream has been reached */
        var c=fgetc(file);
             o+=c; //Append current char

    pclose(file); // Close pipe
    return o; // Return 

And that’s really all you need (in this case to call DIR, split by newline and output the first result):

var dirs=system('DIR /B /S');