Freesex Network: Sex and Second Life, Version 1.0

Thanks to Hunting Hare for being the enabler that got me playing SL in the first place. Bastard. :)

With help from Velox Severine, as well as most of #secondlife on EFNet, mostly unwittingly

Model for Pictures: Kae Languish (In-Game Name. Help the girl out, she's nice!)

Dedicated to Billy Trudeau, a man into "Pleasure". Don't you wish you would've let Emma take those pictures now? ;)

NOTE: I'm available for hire as a scripter in world. =D (Update 2013-05-25: Dear 2005 me: if only you knew the kind of trouble this would get you into later.)

Update 2013-05-25: Most of the code links in this article are dead. However, the original code is now archived on my github at https://github.com/qdot/np_boneyard

Disclaimer: You use this and fuck up and lose your SL account, it's your fault. I'm pretty sure there's chances for all sorts of nasty, unsecure stuff to happen with this code. It's proof of concept. So treat it as such.

Second Life Becomes First

I found out about Second Life while writing our last article on How to have sex with any video game ever made. Sure, I'd heard about it through every magazine and blog in existence, but for some reason I'd never really paid attention to it. After reading up on the game and the massive, massive, MASSIVE user-built sex system, I felt it was time to spend the $9 to actually buy the game. 2 weeks later, and I now have 3 accounts, and am already paying land tier fees.

Yup, I'm an addict.

Development in progress. Very dark progress.

So for all of you wondering what the hell Second Life actually is, imagine a gigantic set of computerized legos. Really, that's it. You can build ANYTHING out of a set of basic geometric shapes they give you, texture those shapes, and script them using a language called Linden Scripting Language. If you can think of it, it's most likely possible in Second Life (though some moderate to severe amount of pain may be involved in making that dream come true).

Oh yeah, and Optimus Prime goes to Strip Clubs in this world.

Unlike legos, Second Life can pay. Pay real dollars. There's a full currency market available for US dollars at Gaming Open Market, where, as of 7/28/05, 1000$L (Linden Dollars) will get you about $3.84US. There's also the IGE, which will let you move credits between around 10 online games.

Some people make their living playing this game.

Me? Shit, as usual, I'm releasing everything for free. 'cause I's a dumbass.

However, if you'd like to donate to the "qDot makes the awesomest shit ever" fund, I'm "qDot Bunnyhug" in the game.

Note: I'm totally putting the cart before the horse with this project. I have tutorials planned for how DI Force Feedback works, how to mod sex toys to work with the SeXBox, and how to make a cable to hook your SeXBox to your computer. However, I'm incredibly excited about this project, so it's going first. Enjoy the non-linearity.

2. Overview of the project

Basically, this project will allow you to control a Constant Force effect on any DirectInput capable Force Feedback controller. You can use a computer joystick, or you can easily mod an xbox controller to work with your machine. We did the latter of the two, since we've already established why XBox controllers fucking r00lz0rz.

Now please note, with the method of control we use, you can control most anything in the outside world through Second Life. For example, one of our cleaner "Demo" projects involved turning a lamp on and off in the game that relayed to an X10 controller to turn a lamp on and off in our house in real life. There's a million different things that can be done with this approach. So why are we "lowballing" it with sex? Simple. Most people don't have X10 controllers. LOTS of people have joysticks. Since we're still working on input overrides to the game (NOTE TO LINDENS: THIS IS NOT A HACK. Since the game is controllable thru Synergy, we can use this method to hook up new control mechanisms to the world. Please do not delete our accounts. Thank you. :) ), you're rather stuck with what you can do in terms of actuation at the moment. We chose vibration for this project. The X10 project will be up soon on Nonpolynomial Labs.

This project is realized through a combination of a LSL Script in an in-world object, and a C# client application. Yes, I said C#. Do you have a fucking problem with that?

3. Not Crossplatform?!?!?! HEATHEN!

Ok, so yeah, you have probably have a problem with that. Second Life will currently run on the Windows and OS X platforms, and there's a Linux version lined up. So why are we stuck with Windows for this project (which currently doesn't have a clever name right now)?

Well, there's a few reasons. First off, the only xbox controller driver that's fully open source at the moment is redCl0ud's, and that's windows. The Mac driver costs $15, and doesn't have rumble support yet (even though forcefeedback.ext should make that pretty easy). I have no problems writing drivers myself, but my mac is at work, and this isn't the most work friendly of projects.

Secondly, I've been looking for a reason to learn C# for a while, and this seemed to be like a good occasion to do it. This project took me 3 days from never seeing C# or LSL in my life to getting the basic implementation done, so needless to say, I'm happy with the language.

This does not mean I will be staying with this setup forever. I'll be going over the plans for version 2 in the end of this article, but if you're still frothing and want confirmation that I'm not staying with the current implementation, just scroll down and read it now. Bitch.

4. An Idea of How You Have Sex in Second Life

Thanks to Velox Severine and Kae Languish for most of this info.

First, some terminology. In Second Life, your character can be put into "poses". Basically, this is an animation created in Poser or some other movement/animation program. You create the animation, loop it, and upload it to Second Life. These poses can be attached to what are known as Pose Balls. By having your character touch a pose ball (basically, clicking on it), you character will being using the animation that was contained in the pose ball. This is how sex is played out visually in Second Life. You touch one pose ball, your partner touches the other, and all of the sudden one is banging the other. Don't you wish it was that easy in real life?

Specialized sex furniture in Second Life. Picture taken at Strokerz Toyz Eros, Eros (189, 185)

Now, you've got to remember, when I said you could do anything in Second Life, I meant ANYTHING. This game has some of the weirdest BDSM equipment I've ever seen, much of which really wouldn't work in real life. Putting a stompy industrial boy in all of it is just hours of stupid, giggly fun.

My fantasy of being stabbed in the crotch while strapped to the Wheel of Fortune, fulfilled. Picture taken at Strokerz Toyz Eros, Eros (189, 185)

Animations will run you somewhere between 200L$ and 500L$ ($.50-2US), sometimes upwards of 1000L$ (~$4US) depending on how drawn out they are. As with all aspects of the world, your body is scriptable. That's right, you can program your nuts. They can do a happy little nut dance. There's also erections and pumping and all that, but I'm totally fixated on the happy little nut dance idea now. There goes another 2 weeks of my life.

Animations can be speed controlled by writing a script that binds animations to buttons, and hitting those buttons to change what animation is displaying. This is how sex progresses.

Can't find anyone to get intimate with in world? Then buy an escort! The SL world is chock motherfucking full of whores! Whores everywhere! A vertiable smorgasbord of WHORES! A half-hour will run you 500-750L$ (~$2-3US), but hey, no diseases!

So really, that's it. You click, they click, then it's pretty much text cyber sex from then on. You've got a million toys to play with, pieces of furniture to do it on, etc etc etc, but it's still text.

At least, until now.

Using the Second Life Sexbox Relay

Unlike all of my other tutorials, I'm going to be nice and describe how to use this first, and THEN I'll go into the technical implemenation details.

God, I could REALLY use some candy right about now. If only I could reach... the... machine...

Here's what you'll need:

  • Our Second Life XML-RPC Client
  • Source Code - You'll need the .lsl file out of here at minimu, but the C# stuff is in there too.
  • Any DirectX Compatible Controller with Force Feedback
  • If you want to use an XBox/Sexbox, pick up the redcl0ud drivers. Nice and open sourcey!* A Windows System with DX9 and the .NET Framework (Not a word, fuckers, not a WORD)
  • A Second Life Account. A basic account will run you $9 (once. Period.) for a lifetime account. Owning land costs more, but that's not required to play the game

That's should do it.

Now first, you'll need to load up the client. Just double click on it. Easy, eh?

The GUI. Forbidding. Aloof. Terrifying. The GUI with the biggest tits in the world. GONG

The "Force Feedback Only" Box will be stuck on. I'm just using that for debugging purposes, so ignore it. :)

Select the joystick you would like to use by selecting it in the list. This should make the UUID box and Timer Start Button appear.

Log into SL. You'll need to be able to tab back and forth between the game and your client, so if you've got a crappy machine, prepare for hell.

I currently don't have a cool object built for this, so it's up to you to take the LSL script and bind it to an object. If you are not aware of how to do this, talk to your greeter, a mentor, or live help. This product will become more user friendly as time goes on, but right now, I'm more worried about the damn thing being finished.

Now then, once you've bound the script to an object, rez it. It should give you back a UUID. This ID is unique to the object, and will change any time you Rez the object. You will need to cut this, and paste it into the UUID box in the client. Once you've done that, hit the "Start XML Query Timer" button, and the client will start communicating with your in-game object.

To control the object in world, you'll need to chat on channel specified when you opened it. This means if it says "Chat in channel 98", you'll need to start all chat lines with "/98".

To command the box, simply type "/ ff ". Speed is a number between 0-100, which represents the percentage of vibration the controller will relay. If you use -1, the client timer will stop.

Please note that you WILL see lag between you commands and the speed updates. Due to spam avoidance, LSL only allows you to make XML-RPC calls once every 3 seconds. Yes, it sucks, but it's the best I can do for right now.

So, really, that's it. You can now have sex through Second Life. Spiffy, no?

To the best part of the tutorial... THE GORY DETAILS!

6. Implementation: First Life Interface

How I spend my Thursday nights, with Friday off

The reason this program was so damn easy is that we used XML-RPC.NET to program it. It pretty much threw together everything we needed to talk to SL in a format that took all of 8 seconds to learn.

To talk to Second Life, you need a Channel ID, which is a GUID/UUID/Whatever you like to call 128bit numbers these days. This uniquely refers to the object in world that you want to talk to. This is thrown out by the object in world when it is created, so the users passes it to the application, and there you have it.

After the GUID is put in, the user starts the timer, which triggers off a thread a 3.1 seconds. The XML-RPC command blocks until it gets a responce, and we want our GUI nice and snappy, therefore we thread. Sloppily. You can only query once every 3 seconds, due to the fact that once you get a packet in the game, the reply sends the reply and blocks for 3 seconds, again, to avoid spamming. This is why our timer is set to 3.1 seconds.

Next, we need to pass the packet to Second Life. An obviously easier method would be to have Second Life throw out a value to you every time the user changes the settings, but that's not possible. The game developers have XML-RPC outbound communications currently turned off to avoid malicious users spamming through the game. So, we're forced to query inward.

The packet structure looks like this:

<?xml version="1.0"?>
<methodCall>
    <methodName>llRemoteData</methodName>
    <params>
        <param>
            <value>
                <struct>
                    <member>
                        <name>Channel</name>
                        <value><string>4a250e12-c02e-94fb-6d2f-13529cbaad63</string></value>
                    </member>
                    <member>
                        <name>IntValue</name>
                        <value><int>0</int></value>
                    </member>
                    <member>
                        <name>StringValue</name>
                        <value><string>test</string></value>
                    </member>
                </struct>
            </value>
        </param>
    </params>
</methodCall>

However, this packet is magically constructed by XML-RPC.NET, so we really don't give a shit as long as it works.

The method name we call is llRemoteData, and we pass the ChannelID, and a string and integer if we want. As of version 1, there's really nothing we need to send to the game, so we just load "" and 0 into those values. All we're interested in is getting the reply back with the value the object is currently holding.

Once we get a query back, we unpack it, and check out what it's given us. If the channel GUID is wrong, the program gives back an "Invalid Channel", and everything halts. Otherwise, the string returns "Request Received" and the integer returns the integer that the player has set power to through talking to the object. We take this integer, and edit our force feedback effect. Force feedback effects can have many horribly complicated features such as envelopes, fades, so on and so forth, but right now we're just interested in a full on constant force. Constant force magnitude range is between -10000 <= x <= 10000, so we just take the percentage given by the user * 10000 (which means no backward motor rotation), shove that through the effect, download it to the controller, and voila! shakey happy fun time!

Implementation: Second Life Interface

The LSL code is a hell of a lot simpler than the C# code, which means it's just mind bogglingly easy. However, I'll present a little setup for those not familiar with LSL.

LSL is a state based language (i.e. you change states, and events are driven to handlers in the state your in) that looks a lot like C, but sucks more. Really, I can't bitch too much though, with as much as you can do with it in the world, it's pretty god damn impressive.

Anyways, we start with default->state_entry. Imagine that as your constructor. This opens up our RPC channel, and gives us back the GUID, which we then relay to the user through the chat window. We move to the "go" state then.

In "go", there's three events we can handle: creation, listening, and packet receive.

Creation is kinda fucked. There's no destructors for objects, so when you remove them from the world, they stay in the state they left the world in. Therefore, if you need to do something like re-establish an RPC channel (RPC channels are garbage collected on object removal), you have to tell the program to specifically skip back to the initial object state.

Listening is how we change settings in the object. Users interact with the object through chat, and we then pick up the chat and do some basic string parsing on it to make sure it's a valid command. IF it's a valid command (first or second token being "ff"), we change our global that handles power levels to whatever the user wanted.

Packet Creation happens after we receive a request from the client. Assuming the packet has the information we want in it (which it most likely will, hard to screw that up since we aren't taking any input), we case up the power value and ship it off, then sit there for 3 fucking seconds in a god damn spin wait. God, that hurts.

Anyways, that's really it for the LSL script.

8. Upcoming Improvements

  • Actually making a shape for this thing
  • Multi-user reflection and communication (for group chats with multiple bricks)
  • Multi-brick timer staggering to decrease wait (basically switching between 3 bricks at 1 second intervals, to stride the spin waits).
  • Animation binding, so you can bind animation timing scripts to the object
  • Effects file playing, so you can preprogram effects and call them by name
  • Overhauling the system to C++ and Qt, since that's what I know in terms of Cross Platformness
  • Turn the client into a plugin system, so that it can dynamically talk to any library anyone writes (so that the same client will work for this, for X10, and for any other project anyone might have)

Timeframe on this is sometime between who knows when and I have no clue. If anyone else improves on the scripts, please update me, I'm passing around this code for a reason, and I'll be happy to post about anyone's experiences or improvements. That's what Second Life is all about, right? :)