July 24, 2008

Playlog Displayer

Written by theY4Kman at 5:23 am under Python and Programming

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 :D
(more…)

July 23, 2008

Ubuntu and more!

Written by theY4Kman at 6:30 am under Ubuntu, Linux, Python and Programming

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 :P

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.

July 11, 2008

Vegas Videos

Written by theY4Kman at 3:10 am under Vegas and Video

I picked up Sony Vegas a while back. Vegas is a video editing software, and it’s damn good. Video editing is a skill I’d like to have, as it can be very useful for tech demos, frag videos, and just some screwing around, like so:


Saving Private Ryan: Where Is My Mind?


Saving Private Ryan: Where Is My Mind? (Take 2)

These videos are a product of my boredom and struggle quest for knowledge. I learned some valuable stuff in making them; one of those things being that the Pixies kick ass :)

June 14, 2008

Viper Woes

Written by theY4Kman at 9:51 pm under Viper and Python

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 :D

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 :P

April 20, 2008

ConVar Manager Update and more!

Written by theY4Kman at 10:06 pm under Viper, SourceMod and Programming

Last night and today I worked on finishing the ConVar manager, which I did actually complete! All convars created inside of a plug-in are added to the ConVar manager’s internal database (A Trie) and the plug-in’s convar list. Tomorrow I’ll work on adding a “cvars” option to the Viper menu, which will be accessed with “sm py cvars”. I’ve created a test plug-in to create many ConVars, which successfully created every single one, and was able to retrieve the value from each; each convar was declared as a different type of data (Float, int, string, etc.), and retrieved by each type, so as to test my error checking, also.

There is one problem, though: If you create a convar from the console by using the Python interpreter command I’ve created, “py”, it does not work. The Python convar object is created, so you can call functions on it and the such, but the Source ConVar class instantiated through “new ConVar(name, defaultVal, …)” equates to NULL when accessed. The chain of command is this:

  1. On the Python side, the user creates a convar object
    convar = console.CreateConVar("a_name", "a_value")
  2. CreateConVar does some simple error checking (Making sure the name isn’t blank, etc) and calls New_ConVarObject, then Init_ConVarObject. I’m going to showoff here and present the code of this:
    static PyObject * Console_CreateConVar(PyObject* self, PyObject* args, PyObject *keywds)
    {
    	char const *pName, *pDefaultValue, *pHelpString = NULL;
    	int flags = FCVAR_PLUGIN;
    	float fMin = NULL, fMax = NULL;
     
    	static char* kwds[] = {"name", "value", "desc", "flags", "max", "min", NULL};
     
    	if(!PyArg_ParseTupleAndKeywords(args, keywds, "ss|siff", kwds, &pName, &pDefaultValue, &pHelpString, &flags, &fMin, &fMax))
    		return NULL;
     
    	if(pName[0] == '\0')
    		Py_RETURN_NONE;
     
    	Py_XINCREF((PyObject*) &console_ConVarType);
    	PyObject* ConVarObj = (PyObject*) console_ConVarType->tp_new((_typeobject*)console_ConVarType, args, (PyObject*)NULL);
    	ConVarObj->ob_type->tp_init(ConVarObj, args, (PyObject*)NULL);
    	return ConVarObj;
    }
  3. New_ConVarObject just sets the values of the object. Nothing to see here.
  4. Init_ConVarObject does all the real work for the Python side: error rechecks (Just in case :D), creates the ConVar (Through the ConVar manager), and does some work after the ConVar object is created.
  5. The ConVar manager does all the real work on the C++ side:
    static int console_ConVar_Get(console_ConVarObject *self, PyObject *args, PyObject *keywds)
    {
    	char const *pName, *pDefaultValue, *pHelpString = NULL;
    	int iFlags = 0;
    	float fMin = NULL, fMax = NULL;
     
    	static char* kwds[] = {"name", "value", "desc", "flags", "max", "min", NULL};
     
    	if(!PyArg_ParseTupleAndKeywords(args, keywds, "ss|siff", kwds, &pName, &pDefaultValue, &pHelpString, &iFlags, &fMin, &fMax))
    		return -1;
     
    	// Make sure the ConVar has a name. teame06 would be dumb enough to make a ConVar with no name, which is why I add this check in!
    	if(pName[0] == '\0')
    	{
    		PyErr_SetString(PyExc_ValueError, "cannot have a blank ConVar name.");
    		return -1;
    	}
     
    	CPlugin* pPlugin = g_VPlugins.GetPluginByPath(GetCurrentPath());
     
    	if(pPlugin == NULL)
    	{
    		PyErr_SetString(PyExc_StandardError, "error in accessing the plugin.");
    		return -1;
    	}
     
    	self->info = g_VVars.CreateConVar(pPlugin, pName, pDefaultValue, pHelpString,
    				 iFlags, (fMin != NULL), fMin, (fMax != NULL), fMax);
     
    	if(!self->info || !self->info->pCvar)
    	{
    		PyErr_SetString(PyExc_StandardError, "error in creating ConVar.");
    		return -1;
    	}
     
    	self->info->handle = self;
    	self->convar = self->info->pCvar;
     
    	printf("Convar '%s': '%s'\n", self->convar->GetName(), self->convar->GetString());
     
    	return 0;
    }

Anyways, I’m getting way too technical now. Nobody understands me. I’ll go cry in a corner.

The “and more!” is that I added ClientCommand and FakeClientCommand to the Client object. I’ll work on the Client object tomorrow, too; it needs Kick and Ban. Now, off to workout and bed for me!

April 19, 2008

ConCmd/Var Manager Deadline

Written by theY4Kman at 10:11 pm under Viper and Programming

Today, I set a deadline for the console command and variable managers. I was to finish the pair in around 3 hours, beginning at 3pm EST. It worked very well for around an hour, until I had an urge to play Team Fortress 2, for which I paused development, played for an hour, and pushed the deadline ahead another hour. The time I spent developing Viper was extremely productive, compared to my regular barely-work-lots-of-play schedule, which wreaks havoc on my development and school work :P

The results of it were, well, okay, at best. However, the so-so results were caused by fixing compiler errors, not from lack of work. I had much trouble with the py_console files. For example, recent compiling brought forth new errors to py_console.cpp; first off, there was this:
'console_ConVarType' : redefinition; different types of indirection

Then, this sprung up:
C:\coding\hl2sdk\public\tier1/utlmemory.h(102) : error C2129: static function 'int console_ConVar_Get(PyObject *,PyObject *,PyObject *)' declared but not defined

It made absolutely no sense, for many reasons:

  1. utlmemory.h is not directly included from the file I suspected was causing the error (py_console.cpp)
  2. utlmemory.h is part of the HL2SDK, and should have nothing to do with my Python files
  3. Sawce loves Rukia!

I’ll be working on it tonight, and hopefully it’ll be committed working by the time I hit the showers.

March 22, 2008

Call of Duty 4 Update

Written by theY4Kman at 2:08 pm under PS3 and CoD4

Just recently Infinity Ward released an update to Call of Duty 4: version 1.20. I was ecstatic to find it, and couldn’t wait to get on. When the downloading and installing finally finished, I trembled like a rabbit facing a 12-gauge as the game loaded. Upon entering multiplayer, I found that the game mode Oldcore is gone. AAAAHHHHH!

Oldcore is Hardcore (No HUD, less health, slower regeneration) Old School (No classes, higher jumping, pickups), and it was the absolute best game mode there. And they removed it! They killed Oldcore! YOU BASTARDS!

However, they did add a few things that I like. For example, you can now mute people in-game. So no more mic-spamming! I honestly don’t understand why developers don’t include this from the get-go. Anyways, they also optimized server selection, upped the bandwidth standard for 18-player games (No more lag :D), added chase (third-person) cam for spectators, and added better kill cams (For grenades, RPGs, M203 nades, etc).

February 11, 2008

Celebrate Black History Month with some HAND PICKED cotton balls!

Written by theY4Kman at 2:13 am under Funny and Awesome

cotten-balls2.jpg

I think we have a winner

January 11, 2008

I SAID PINCH HIS TITS!

Written by theY4Kman at 9:18 pm under Funny, Awesome and Video


Awesome.

November 27, 2007

CD Players

Written by theY4Kman at 4:52 pm under Reminisce

It seems only yesterday that CD players were the device to have, and “mp3″ was just a typo of “MP5″. Pause and glance around a bit and you’ll find cell phones, iPods, laptops, tablets that all play music. We’ve come a long way since 8-tracks, but it hasn’t been a picnic. So before we get lost in the new wave of music players (I’m hoping the standard will be Vorbis), I’m gonna stop and remember a bit of the [shitty] past.

It’s Monday morning and I’m testing out my brand new Sony Walkman CD player, complete with “The Wall”, by Pink Floyd. I strut onto the bus, feeling so cool as I deftly handle the hot, new gadget. Sitting down amongst the ever-so-faint “ooohs” and “aaahs”, I switch it on, fix crap headphones on my head, and while away the trip to school to Comfortably Numb.

*BUMP* *SKIP*

Fuck.

Next Page »

Powered by WordPress. Driven by caffeine.