Learning BYOND, Day 4: Early Vestiges Of Awesome

Am I really only on day 4? The human brain is a remarkable device – that which seems hopelessly impossible to understand yesterday is implicitly understood and being done today. Where is the tangible difference? In the individual’s perspective, it is as though a part of reality was completely redefined, and yet there’s no artifacts to be found to mark the change.

I didn’t keep a running tab of everything I figured out today, so there will be no categorized list of minor newbie tips. Sorry, I was just having too much fun. However, I can remember a few interesting things that happened in my coding exploits today that might prove enlightening.

Bloat

As I wrote yesterday, I’m just comfortable enough writing code now to be dangerous. Consequently, I’ve been coding pretty comfortably. When you type 100 WPM, that stuff adds up pretty quick. Looking at the directory now, my code is up to about 41 kilobytes (over 40000 keystrokes) of raw text now. My code probably more than doubled in size this day alone.

I’ve broken off parts of my source code into other source files named after the particularly meaty object or global procedure definitions I moved there. That’s a good practice to adapt in order to quickly leap to the code you want to access. BYOND handles all the code file inclusions automatically: if it’s checked on the left of the dream maker’s file list, it’ll be compiled and accessible. (Of course, it’d be a bad idea to split an object or procedure in mid-definition since you can’t be sure in which order those files will be assembled.)

All this bloat is just that: Little (if any) of the code I wrote today is permanent. In fact, I’ll probably regret my amateur code later and want to completely re-write it when practice brings with it new standards of coding elegance. Oh well, such is the business of programming. At least, that’s the kind attitude a fledging programmer needs to not regret another day of his life down the bit bucket. (Oh well, how else would I have spent that time? Spamming a forum mostly filled with people half my age, probably.)

Hints of reward

With size, my code is also growing more capable. All those happy little digital souls living in my program now have brand new arms and legs with which they run amok all about my virtual world, gnashing and tearing, raping and pillaging. I do hope to teach them subtlety some day, but I can only code an ideal virtual world one line at a time.

As of today, my little robot mobs can now have special items I created – “robot interfaces” – installed into them by player characters who are carrying these interfaces. Each robot interface carries verbs that allow the players who can see them to control the robot they are installed in. So far, only two interfaces work: “follow me” and “wait,” but the basic framework is in place to allow players to install and use as many as I feel like creating. In a way, my coding more robotic interfaces would be not unlike a fantasy RPG developer coding more magic spells for wizards to cast.

The interfaces work via a rather crude hack where anyone in the world can use the verbs attached to them. That would simply not do – anyone could hack your robots and use them against you – however I’ve yet to figure out BYOND sufficiently to configure a better ‘set src’ setting to allow an item in another mob’s inventory to be accessible by the player.

For the time being, access can be controlled by who is capable of viewing the items in that robot’s inventory. The only way you can see the robot’s inventory is to see the robot’s inventory panel. Though it feels sloppy to not rely on the standard “set src” verb restriction, it works. It’s almost a very clever workaround, as the verb-enabled objects merge together on the robot’s inventory list to form a dynamic right-click menu.

Another bit of progress today is making some rudimentary use of clicking the mouse in the game via the Click() procedure that can be redefined on any visible object that’s placable in the game world. One elegant-feeling trick is to hook up the mouse click procedure to swap of the client.statobj variable. This enables players to see the stat panels of something else – just be sure to have coded the neccessary access restrictions in place to prevent the statobj from being assigned to anything you don’t want the players to view. A Click() procedure is also good to put on usable items to call a default verb that activates when the item is clicked on.

Trouble Ahead: Finding The Way

Considering the difficulty I’m having with figuring out a way players can input waypoints, I might just settle for the “follow me” and “wait” robot interfaces along with a third that orders the robot to go to somewhere easily in view. Players could tow around their robots and deploy them that way, and the game will be completely playable.

That’s a cop out, however. Next on the agenda will be creating a much better way to handle waypoint travel. Part of the reason why is because I wasted about 3-4 hours trying to paint my player character’s assigned waypoints with the image() procedure. Because my current waypoint system is so kludgey, that turned out to be several times harder than it should have been.

(It might have helped if I had some previous experience with BYOND’s Image object handling – I’ve got the theory down, but there’s a remarkable difference between understanding the theory and having the experience of actually doing.)

The much-maligned short path to knowledge: RTFM

If I wasn’t having so much fun playing with my code today, I might have taken a better look at the DM Guide PDF. I’m only up to about chapter 7 now, having skimmed ahead for occasional things as I need it. Reading through my printed out PDF file and defacing it with a pencil seems to produce excellent rules in fostering better understanding. If I actually read it from cover to cover this way, it would probably be the shortest path to neigh complete understanding of the BYOND coding environment.

Alternately, I should probably consider getting my hands on some more example code. Seeing the way things are written by experienced BYOND programmers may prove enlightening, at least once I know enough about the why of it to understand why the code turned out elegant the way it was done.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: