Playlog Displayer
I never did show you the full source code for the playlog page, so here you go! One day I’ll comment it for you ![]()
(more…)
I never did show you the full source code for the playlog page, so here you go! One day I’ll comment it for you ![]()
(more…)
Recently, I had to compile and package my SourceMod extension, Viper, on Linux. I’ve had Ubuntu on my other hard drive since the first day I used it, so I just booted into it. I never really appreciated Ubuntu, mostly because my stays in it were short. I wanted my games, and my games were on Windows, kicking it on Steam, running natively with great FPS (if you didn’t catch that, I’m saying I get bad FPS under wine). Plus, it takes six hours to boot Vista, so if I switched over to Ubuntu for a day, it meant I’d have to wait for Vista to load up later.
For about 6-8 hours, I worked on Viper. I was having the same trouble as I was on Windows with it: getting my Python library to load. After 7 hours and 58 minutes of searching Google for some answers or documentation, I tried a few things to get it working. Failed miserably. At least it compiles
When the extension wouldn’t load, I just slacked off. I downloaded Shrek and watched it. After that, I was aching for some music. Google and the Ubuntu forums being my advisor, I picked up Amarok. It’s a great player, but something was terribly wrong with it: it was slow as hell. Opening up a context menu took 5-10 seconds. I looked around Amarok’s menus and settings, and I found the Script Manager. A music player with a scripting interface? That’s awesome!
That reminded me XChat (an IRC client; my favorite on Linux, but the Windows version is horrible) had plugins, too. Google found me the documentation for xchat-python (http://labix.org/xchat-python), and I set forth to make a Steam ID to Community ID converter. Good fellow CShadowRun had created a similar script for mIRC, but it was lacking something I really wanted: the ability to find user names, too. With his script, you could only exchange “STEAM_0:1:337” or “http://steamcommunity.com/profiles/762827591735028491” with each other. It was great for what it did, but a lot of the time, one only knows a person’s user ID.
Luckily, one can find a person’s user ID through this URL: http://steamcommunity.com/id/USER/. Bada-bing, bada-boom, I had a working script. With some more tweaks, it was almost perfect, save that if I use the command (”!steam user”), it replies with the answer before it sends my original message, so I get an output like this:
<theY4Kman> theY4Kman -> STEAM_0:1:10553940
<theY4Kman> !steam theY4Kman
Next, I wanted to see what scripts there were for Amarok. With their snazzy script manager, I found a neat script called “Playlog” that uploaded song information and play times to a MySQL database. Wow! Unfortunately, it was written in Perl, which I have no experience in, but my general programming experience allowed me to edit it quite easily (without errors, too. It was quite the phenomenon.) I setup the MySQL database and got the script running. All that I needed was a web page to display it all.
I love Python (AND YOU WILL USE IT), so I picked up mod_python (which I hear is inferior to mod_wsgi) for the Apache2 webserver. A few tests and bizarre errors later, I had it all working. With my handy KDevelop, I started working on the page to display it all. An hour or so later, the page displayed the time a song was played, its title, artist (if one was set), album (if one was set), and cover art. The cover art was a bitch to write, but it worked well enough to display everything correctly. Plus, I stole the default cover art from Amarok
Admiring my work, I noticed that I’d been on Ubuntu for days now, and I hadn’t played one single game. I never thought that was possible. There was so much to do on Linux that I hadn’t even cared to play a game.
I have a small blog post for ya, but it’s mostly for my sake. I made some very stupid mistakes over the past week with Viper, and I wish to share them with you (and archive the solutions for when I inevitably make them again).
First off, I had this code to create ConCommands:
pCmd = new ConCommand(new_name, CommandCallback, new_help, flags);
It took me around three or four days to realize I wasn’t registering pCmd. I slipped in META_REGCVAR(pCmd), and it works beautifully
Secondly, and lastly, I had consistency issues with paths. Windows is very annoying because it uses backslashes instead of forward slashes. This means that I have to escape every directory in a path. Thankfully, Python accepts both forward and back slashes in paths. However, a trie a does not. I had a lot of trouble determining why Viper couldn’t recognize which plug-in called Register (that function finds the path of the script which called it, looks it up in the trie, then updates the plug-in’s info). After a lot of searching, it finally dawned on me that the path entered into the trie and the path from Register were different. You can thank my shotty eyesight; I had printed out the two paths into the console and still couldn’t see any differences for the longest time ![]()
Powered by WordPress. Driven by caffeine.