Rob's blog
Using SWIG to connect C++ to Lua

I closed off my last post about adding Lua to an SDL application saying I’d look at a tool to do the bindings for me. I actually already had something in mind for the job. I looked at a couple but SWIG seems to be the most versatile. It’s not tied just to Lua so the work I put in to learning how to use SWIG will also apply partly to any other scripting languages I want to support. Any within the realm that SWIG supports, of course. Notably missing from the list so far is Javascript. Scheme is represented in the form of Guile (which is a specific Scheme interpreter as far as I understand).

The documentation for SWIG is pretty sizable but of course with all the combinations of host & script language out there they aren’t all explained clearly enough for a beginner like me. So I started to experiment. SWIG focuses on wrappers for C, C++ support seems more complex. So to understand things I had to scale back even from my simple SDL C++ test program then scaled back up once I got some communication between code written in both languages.

WoW: Self-Cast in KDE and Faster Performance in Wine

There are a couple things I've done to tweak World of Warcraft on my Linux box. I run OpenSuse 10.3 now but most of this will be the same for other distros, especially if you use KDE. These are just specific to what worked for me but I guess that some other Linux WoW players might benefit from the same settings.

First off I lost the ability to do a quick self-cast. Self-cast is done by just holding alt while clicking the icon for a spell. So, as a mage, every half-hour I want to self-cast Arcane Intellect. That's no big deal since it's not in combat. Remove Lesser Curse is a bigger problem. The second fastest way to use that is with a shortcut key or click followed by F1 (which also targets your own character). I thought the problem was because of some multi-language keyboard customization I had done but as it turns out it was a setting in KDE for moving windows by holding the Alt-key. To turn this off just follow the steps here - I included pictures, click each to get a bigger image.

Starting a Simple Example using Lua and SDL in C++

I’ve been poking around with a couple C++ programs recently and I started thinking again about how cool it is that you can hook in a scripting language. I’ve wanted to try setting up scripting for a few programs in the past but it always seems too far removed from any one project. This sounds kind of abstract, more concretely I’ve been thinking about scripting behaviours in a game or exposing a script interface from some simple graphics program.

Lua’s a popular scripting language for games. It’s used for add-ons in World of Warcraft and I’ve heard it brought up over and over again at the Game Developer’s Conference. I tried a short example of Lua a while back but I never went back to write any real code with Lua. Since the license is so liberal and writing a little Lua would help me out writing WoW macros and add-ons, I decided Lua would be a good place to start - have a look at yesterday's post about setting up an SDL project in Visual Studio.

Next for the test harness. I took some code to draw a Hilbert curve from Wikipedia about a week ago and converted it into something roughly equivalent in C++ using SDL. The code compiles and runs under Linux (I used KDevelop) or Visual Studio 2003. In the code I implemented a SimpleGraphics class which takes an SDL surface and gives some methods to draw lines on that surface. The HilbertCurve class uses a SimpleGraphics object to do the drawing. I decided this little program would be a great candidate to get scripted.

My first run-in with Managed Code

I've heard complaints about dealing with managed code and headaches dealing with mixing managed and unmanaged code but for the most part these problems have been just bits of conversation to me. Until now. See, the last version of Visual Studio that I used for really intense work was VC6. I still feel that the product's been riding down the crapwave ever since. In the interim most of my work has been in Linux or cross-platform script stuff. I've got a little project that I'm currently trying to get building on Visual Studio 2003. It uses SDL and Lua. Basically I want to build a little test harness, but more on that later.

I already had the project building in Linux using just the SDL libraries then I created a project in VS2003 to build the same source. I followed the description from this thread on GameDev.net. The SDL project built and all was well.

KDE Keyboard Shortcuts
A few awesome KDE keyboard shortcuts, some I forgot, some I never knew and just said "wow, what a great idea".
Installing the ThermalTake Ruby Orb on my Asus M2NPV-VM

Just in case anyone's wondering about the outcome from the parts I ordered the other day, I just installed my Ruby Orb fan on my Asus M2NPV-VM. It was a little scary, for one thing that heatsink & fan is really huge. I mean really. It's a 120mm fan, stock CPU fans are about 65mm if I remember right. The Ruby Orb is so big I don't think I could take the RAM out of the computer without removing the CPU heatsink. I will say it's very quiet for the amount of air that it moves. Still my computer overall seems about as loud as it was with just the one case fan. Of course now it's got two case fans running and with the old case fans I had the noise would've been unbearable. I've also got five hard drives in there now (just installed the 500GB Seagate Barracuda SATA drive).

Updated Firefox Search Plugin for WoWArmory.com

I've got a new update for the search plugins I wrote for the World of Warcraft Armory. Blizzard changed the search results URL slightly and that broke my old version. While I was at it I added a general search (all realms) that might work for Taiwan and Korean realms.

If you're a new user, the basic idea I've used is that sometimes people want to search all realms for a character name but usually you want to look for a character only on a specific realm. Looking on a specific realm is a lot more useful since most of us only play on one realm or at most a few. You can install the realm-specific search for each of the realms you play on and the name shows up when you pick which you want from Firefox's search box.

The search plugin shows up on the top right corner of Firefox. It might also work on Internet Explorer 7 since it's written as an OpenSearch plugin. It doesn't add anything to the browser except this new search engine provider - it's not as big as a normal Firefox add-on.

The Bill to Tax VoIP

Something came up a while ago on Slashdot about taxing Internet service in the US and the idea that VoIP would be excluded in a new bill that extends the tax free status of Internet access. As usual most of the details of the proposed law are completely lost in the movement from the bill as it's written to Infoworld to Slashdot. In the course of discussion when I asked about how to see the bill itself, someone kindly provided a link to Thomas, the legislative information resource at the Library of Congress. Unfortunately the search results there aren't RESTful - there's no way to get a permalink to HR 3678 (apparently the bill in question). Anyhow, after looking up that bill and seeing the sponsors I thought it would be informative to look up the politicians named on the bill at Open Secrets and see who funds their campaigns.

There were a number of names and what I found was interesting in relation to the changes outlined in this bill. I'll just quote the reply I made on Slashdot.

Flickr - Creative Commons

Click here to install the Flickr Creative Commons OpenSearch plugin

Late Night PC and the resources it provides are not affiliated with or endorsed by Flickr. Visit Flickr here. Flickr's a great photo-sharing site that you've probably heard of already. A lot of people don't know that you can restrict searches on Flickr to only find Creative Commons licensed photos. This is in the advanced options somewhere. Someone I know asked me to come up with a search plugin that would work in Firefox and make it easy to search for just photos available under a Creative Commons license. Unfortunately Flickr doesn't let you refine the search by exactly which CC license is chosen but at least this eases things somewhat.
Moving Multiple Files in Bash
It seems like the shorter the code is the longer it takes to write. I'm trying to rename a group of similarly-name directories using Bash and for no good reason I decided I'd like to do it all on one line. There are a bunch of ways to do it, not all fit on a line and some are more efficient than others. There's apparently a package out there called mmv that I haven't looked for which does stuff like this. There's also sed. With sed I got something close:
Syndicate content