Make SuperTuxKart GP more challenging

I guess I quite like this game ;o

Doing 1 lap GPs of a lot of tracks on expert with 19 karts is decent fun, but the challenge was a bit gone. In hopes of at least making the races more challenging (winning the GP is still easy), I edited a configuration file to reverse the starting order at each track. So rather than the first starting in first position etc, the last starts first, then the second to last, etc. At least this way, every race you got to try and get to the front.

To achieve it, in your STK installation folder edit the file

data/stk_config.xml

Look for this part

  <!-- Scores are the number of points given when the race ends, 
       order is most-points-first or most-points-last. -->
  <grand-prix order = "most-points-first">
    <!-- Karts on position 1 and 2 will have 3 more points than the next kart;
         a kart on position 3 and 4 will have two more points than the next;
         and all remaining karts will have one more point than the next. -->
    <points from="1" to="2" points="3"/>
    <points from="3" to="4" points="2"/>
    <points from="5"        points="1"/>
  </grand-prix>

and change that third line so it says <grand-prix order = "most-points-last"> instead.

Given that it’s in the configuration file I considered it to simply stand in a menu somewhere too, but that didn’t seem to be the case as far as I could tell.

Show GP position during a race in SuperTuxKart

After quite some time, here’s an update!

In SuperTuxKart, I’ve grown to like doing Grand Prix with

  1. 19 AI opponents
  2. Lots of races (for example, all of them and only 1 lap each)

This has sometimes lead to confusion during the race as to who my direct opponents were and who harmless flies. So I did what any sane person would do and dug in the source code to add it myself of course.

Before you get started, you’ll need to shiny up to date version straight from the STK svn repo, for which I conveniently present you an earlier post. After you’ve gone through all that, it’s time to dive in.

Note, I’ll use $STK_HOME to refer to the directory that is the repo clone. Which will be, if you followed my earlier post, /opt/supertuxkart/stk. Open the file $STK_HOME/src/states_screens/race_gui.cpp in your favourite text editor and look for this part in the code

    if (info[kart_id].m_text.size() > 0)
    {
        video::SColor color = video::SColor(255,
            (int)(255*info[kart_id].r),
            (int)(255*info[kart_id].g), 
            (int)(255*info[kart_id].b)   );
        core::rect<s32> pos(x+ICON_PLAYER_WIDTH, y+5, 
            x+ICON_PLAYER_WIDTH, y+5);
        core::stringw s=info[kart_id].m_text.c_str();

        font->draw(s.c_str(), pos, color, false, false, NULL, true /* ignore RTL */);
    }

    if (info[kart_id].special_title.size() > 0)
    {
        static video::SColor color = video::SColor(255, 255, 0, 0);
        core::rect<s32> pos(x+ICON_PLAYER_WIDTH, y+5, 
            x+ICON_PLAYER_WIDTH, y+5);
        core::stringw s(info[kart_id].special_title.c_str());
        font->draw(s.c_str(), pos, color, false, false, NULL, true /* ignore RTL */);
    }

Before this part in the code, add

    if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX
        && info[kart_id].m_text.size() == 0)
    {
        video::SColor color = video::SColor(255,
            (int)(255*info[kart_id].r),
            (int)(255*info[kart_id].g), 
            (int)(255*info[kart_id].b)   );
        core::rect<s32> pos(x+ICON_PLAYER_WIDTH, y+5, 
            x+ICON_PLAYER_WIDTH, y+5);
        char s[16];
        sprintf(s, "%d (%d)", race_manager->getKartGPRank(kart_id) + 1, race_manager->getKartScore(kart_id));

        font->draw(s, pos, color, false, false, NULL, true /* ignore RTL */);
    }

Next open $STK_HOME in a terminal and make again. You’ll now have in game information similar to this picture (format is Rank (Points))

Removing some subreddits from reddit’s r/all

My recent suggestion on reddit to allow the removal of some subreddits from my r/all view didn’t get any attention, so I ended up throwing a Greasemonkey script together to do just that.

It’s nothing special and I wrote it 5 minutes ago so it might still be buggy, but I figured I might as well throw it on here.

// ==UserScript==
// @name           No more...
// @namespace      reddit
// @description    Removes subreddits nobody wants to see. Nothing fancy.
// @include        http://www.reddit.com/r/all*
// ==/UserScript==

var blocked_subreddits = [
    "fffffffuuuuuuuuuuuu"
    , "trees"
    , "circlejerk"
];

// The table holding all the entries
// First one can be the sponsored link
var sitetable = document.getElementsByClassName("sitetable");
sitetable = sitetable[sitetable.length - 1];

// Every entry
var entries = sitetable.getElementsByClassName("subreddit");

for (var i = 0; i < entries.length; i++) {
    var sub = entries[i].firstChild.nodeValue;
    if (blocked_subreddits.indexOf(sub) != -1) {
        // Put entries's display to none (first need the encapsulating div)
        var daddy = entries[i].parentNode.parentNode.parentNode;
        daddy.style.display = "none";
    }
}

Digraphs and trigraphs in C++

TIL, as they say. This is completely valid C++ code, compiling without any errors.

#include <iostream>

int main() <%
    int a<:5:> = <% 1, 2, 3, 4, 5 %>;
    std::cout << a<:2:>;

    return 0;
%>

It all has to do with so called di- and trigraphs. Of course I wouldn’t use these anywhere unless, somehow, absolutely necessary. No doubt it would only get people confused about your code.

Keep SuperTuxKart up to date, revisited

I made a post a few weeks back about keeping Supertuxkart up to date. This has, above all, taught me one thing… Don’t publish stuff that you only wrote from memory.

So I just now took some time out to try things out myself again, starting from zero. Well, somewhat zero, I already have the correct header files and the likes installed and you’ll have to forgive me for not tracking those down one by one.

Important to note here is that the irrlicht requirement has gone up, so we will also be making that one from source. The following steps will be done with root access.

Read More

Changing SuperTuxKart Ingame Ranking Display

You know what’s so great about open source games? You can so easily tweak them to your liking! When I play SuperTuxKart, I like to play it with a lot of other karts in the race, 19 others to be precise. When I do so, I also tend to do championships since I find them generally more appealing than the other aspects of the race.

However, the ingame ranking tends to only show the first few karts due to the sheer size of each icon. It’s a bit annoying to see how you or your competitors are doing if only the first 7 karts out of 20 total show! So I went digging through the source code to find out how to change this to my liking.

Before picture

Read More

Keep SuperTuxKart to the latest version

Updated 2011-04-19, see this post.

I enjoy playing some SuperTuxKart, but I also enjoy keeping up with its development and seeing changes immediately as they are pushed. Random PPAs will try their best, but if you really want everything, you’ll need to use the svn repository directly. I’ll give basic instructions for Ubuntu here, but whatever your distro is, the options are most likely similar.

First you’ll have to install svn, which is as simple as issuing

sudo apt-get install svn

Next there will be some prerequisites you’ll have to install. Since I did all this a few weeks, I won’t be able to provide the exact details of what you’ll need, but you may find this page useful for that. Some things to keep in mind here is that when during compiling (see later) you get an error complaining about missing files, you will most likely have to install a library and its source files (for this you’ll need the libraryname-dev package in the Ubuntu repos, obviously substituting the proper library name). If you’re stuck on a particular issue you can always post here. Be sure to keep in mind that

aptitude search <name>

is your friend.

Read More

Autoreplace outgoing text in XChat with Python

Having grown to like some unicode characters while talking on xchat, I decided there was a better way to enter them than to use CTRL+SHIFT+U + Numbers (linux) every time again. So I dug into the Python XChat interface a bit and threw together a quick script that will check everything you write and replace certain things with prettier unicode variants. Figured I’d post it here in case someone somewhere can find it useful.

# -*- coding: utf-8 -*-

__module_name__ = "Unicode"
__module_version__ = "0.1.20100130"
__module_description__ = "Replaces random smileys with Unicode variants"

import xchat

def intercept_print(word, word_eol, userdata):
    line = word_eol[0] \
        .replace("<3", "♥") \
        .replace("=)", "ツ") \
        .replace("^^", "^̮^") \
        .replace("!!", "‼") \
        .replace("°C", "℃") \
        .replace("->", "→") \
        .replace("=>", "⇒")
    xchat.command(" ".join(["msg", xchat.get_info("channel"), line]))
    return xchat.EAT_ALL

# Empty command means catching normal text apparently
xchat.hook_command("", intercept_print)

Note that I have neither much experience in Python, nor in XChat programming so I’d not be surprised if there are cleaner/more efficient ways to go at it.

XChat’s Python interface

This is probably a nobrainer for a lot of people, but given my limited knowledge of Python I found this useful to write. Load the script and issue /inspect to see all the public methods of the xchat object.

# -*- coding: utf-8 -*-

__module_name__ = "XChat Inspect"
__module_version__ = "0.1.20100130"
__module_description__ = "Print the interface of the xchat object"

import xchat

def inspect(word, word_eol, userdata):
    methods = xchat.__dict__
    for key in methods:
        print chr(2), key, chr(2), methods[key]
    return xchat.EAT_NONE

xchat.hook_command("inspect", inspect)

Tags: xchat python tech

WhatPulse starts up too soon

I am still faithfully running WhatPulse. However, when installing it on a fresh Ubuntu install on my laptop, I encountered that “good old” problem again where WhatPulse starts too soon. That is, after adding WhatPulse to the start up applications, it starts before the notification-area-applet which is a bit problematic since WhatPulse resides there by default.

In the old days, I used to fix this by adding in this small script that would sleep for 30 seconds before starting up WhatPulse. Instead of adding WhatPulse directly, I would then simply add that script to the start up applications and voila.

#!/bin/bash

sleep 30
/home/ward/.whatpulse/WhatPulse

The last line there is obviously the way to my WhatPulse executable.

This method worked, or I don’t remember an occasion anyway where it didn’t work. Upon inspection though… it looks a bit hacked together (excusez-moi le mot, it feels odd to call three pretty standard lines a hack). So I rewrote it a bit to be more foolproof.

Here’s how I have things set up now:

  • A folder ~/.whatpulse where I extracted the WhatPulse binary
  • A script in that folder wp.sh

    #!/bin/bash
    
    while [ -z `pgrep notification-ar` ]; do
        sleep 5
    done
    
    # Change the following line so it matches the location of your WhatPulse file
    /home/ward/.whatpulse/WhatPulse
    

    And that script added to my start up applications.

Note that I look for notification-ar instead of the full name due to it appearing like that in ps -e output.

Bouncing balls in Masm 6.11

For my computer systems class, we have to write something in asm for the 80x86. I’m working on some bouncing balls (as in: it’s not finished yet) and I’d thought I’d share with the world in case someone else can learn anything from it.

It is hosted in its entirety @ https://github.com/Wardje/compsys .

I’ll probably add the DOSBox setup I use to the wiki one of these days (assuming I have enough time).

Adding own Emblems to folders in Nautilus

Pro tip:

Are the available emblems in Nautilus not enough for you? You can easily add more by going to Edit->Backgrounds and Emblems. A window will open that allows you to add emblems at will. It’s really self-explanatory, but you might haven’t noticed that functionality yet, enjoy!

Coloured Git Output

Pro tip:

You can enable git’s output to be coloured by issuing

git config --global --unset-all color.ui
git config --global --add color.ui auto

Note that you can view all set configuration options with

git config -l