From OSGrid to the Main Grid

January 18, 2010

In my adventures on OpenSIM (as Instant Blue on OSgrid), I have found it hard to come accross anything to change parcel radio stations. There are also other problems in what you see may not be legal. (Someone may have imported something that they shouldn’t have, and shared it with the grid). To work around the problem, I made my own little boombox script that lets me change stations according to my mood. I have found it to be very handy.

On the main grid, I started having that desire to switch stations again with the simple interface of my boombox, but I didn’t have anything close at hand in my inventory. I went ahead and pulled my boombox script from the OSgrid and created the boombox on the mainland.

This brings up some interesting thoughts, as people are often complaining about stolen content making it’s way to the OpenSIM grids. Although this is a script that I wrote myself, I am a bit concerned about the protection of content on the OpenSIM grids. Some of them have permissions enforced to prevent you from modifying, copying and looking at objects. However, the administrators of the grid may be able to work their own magic to bypass the permissions that content creators have setup. The same could be said about the Lab’s capabilities as well, but there is a stronger sense of trust with the lab along with legal actions that can be taken.

If I create something on an OpenSIM grid, is my content protected? Do I retain the IP rights? Are there security holes that I should be worrried about?

I’m sure there are more questions about this, but I’m about to turn in for the night.

posted by Dedric Mauriac on Applewood using a blogHUD : [blogHUD permalink]

Classes in PHP and JSON

November 30, 2009

I started looking into classes in PHP and found a great way to encapsulate a lot of logic that I am going to use quite often for my grids. In addition, I found a method in PHP that also converts objects into JavaScript Object Notation (JSON) – json_encode($this). It takes a lot of the manual labor out of the equation. PHP’s implementation appears to be a little bit more heavier on the encoding and casts property names to strings. I found one problem where I had to recast integers retrieved from a database so that the JSON would represent them as numbers instead of strings.
posted by Dedric Mauriac on Woodbridge using a blogHUD : [blogHUD permalink]

Inventory Service

October 4, 2009

I’ve spent the majority of the day working on a robust PHP script that permits an in-world inventory server to connect to a web-based service. It sounds simple enough, but the validation is killer. I only have one part of a few parts that I’m still working on. Connection is done. I need to work on a cron job to verify the URL still works, and I also need to work on the API to permit a list of the inventory to be stored on the web service.

One thing that I found pleasing was the capability of asynchronous HTTP communications. I start to make a request with llHTTPRequest. While that is happening, the URL that it is contacting tries to contact the same script on the http_request event. The http_request event verifies information from the server and returns additional information to verify that it is coming from the same script that originated the request. Finally, the http_response event gets the results from the llHTTPRequest and both client/server are happy.

I’m still uncertain if I should focus on the scavenger hunt idea or not since Peter Stindberg pointed out a scavenger hunt system made by iRika. However, it appears that hers is not web-based. The power of the web permits grid-wide (and even cross-grid) scavenger hunts. In addition, it permits profiles where people can choose to show which scavenger hunts they completed, and the reward associated with it. This is sort of like a trophy system. Imagine a large treasure hunt also that allows multiple people to hide items – like the great grid-wide goldrush and the Great Grid-Wide Easter Egg Hunt, but instead, you have to log onto other grids as well to get the entire collection. Another possibility would be to exchange found treasures for others similar to how the in-world Geocaching works. In this sense, you could leave a “bug” in one cache, and see how far it moves as others find it and put it into other cache’s. Because the back-end is connected to a database, you wouldn’t be limited by memory constraints. I found one treasure hunt that boasts support for 4,000 items. This is nothing with the power of a database.

Another item that I found on XStreetSL provided people with a set of gold bars to be hidden around a region. With the system I was thinking about, I could sell collections individually like this (but with different types of ingots like copper, iron, silver), or provide the ability to drop a script into your own objects. I believe iRika does something similar to this. Another product offers different flags to add some variety.

Although I am working with the web, I was also thinking of how to simplify things. In this case, the web should be completely optional. Even a checklist could be dynamically updated. I could add a button for it to list active treasure hunts in the current region, and then display a list of items for them to find. Perhaps some treasure hunts could be marked as private to group members only, individual people, or peoples avatars who are older or younger than a specific age. Another idea would be to require someone to be standing within a short distance whose rezday is today, in order for other people to claim the treasure. Or perhaps their name has to begin with a specific letter like lucky chairs, or a minimum number of people need to be near by similar to mob vend. With the capabilities of a website on the back-end, I could even set items up so that people would have to post a snapshot to bloghud, snapzilla, or mixoom in order to retrieve their prize. There are tons of ways to expand the idea of how to hunt for things. Oh, and the most awesome one – teams!

However, if it’s not the way to go, I could look into the UFO game again. I pretty much had a working concept setup for it. There were still a few other ideas to go along with it as well.

What Grid are you on?

October 3, 2009

I’ve been working with a LAMP server with Ubuntu on a virtual PC. I came to the part where I had to identify the grid of the object that was calling my API. Although the llHTTPRequest method passes a few headers that help identify objects, owners, and locations, they do not provide any information as to what grid they are on. They do identify the difference between the preview grid, and the production grid through the shard header, stating “Production” or “Testing”. How do I know if it is a region on the official Second Life™ grid? By default, Open Simulator uses “OpenSim” as the value for shard, but it too does not identify the grid.

After much research and hacking away at a few hours of code, I believe I have found the answer. With PHP, I can capture the simulators IP address. If the simulators are ever put behind a proxy, or start using IPv6 addresses, my solution breaks. So now I also have a list of IP addresses that Linden Lab has ownership of.

I created one table that identifies grids that have access to my API. I created one entry to represent the official grid, Agni. I then created a second table to store all addresses associated with the grid. Rather than storing an individual address for each valid IP address (over 20 thousand of them), I got smart and decided to use the IP and Network Mask to represent a range of IP addresses. MySQL offers a method to convert IPv4 addresses to their numeric equivalent and back again. Rather than going through the trouble of datatype problems between PHP’s signed integers, the nature of IPv4 as unsigned, and MySQL unsigned integers, I decided to let MySQL do all the work for me.

In the end, I have a simple query to ask my database, “What grid does the IP belong to?”. This is how I can rephrase the question that the database can understand.

select         GridId from         GridAddress where         INET_ATON('') between GridAddressNumber         and (GridAddressNumber + pow(2, (32-GridAddressMask))-1)

With only a handful of records to search through, the answer comes back quick. “Hey, this is for the Agni grid”.

With this capability, I can then build upon the features over time. If a grid gets a new IP range, or just one, it would be easy to add it to the database. If I wanted to add the address, then I use a simple query:

insert into GridAddress (GridId, GridAddressNumber, GridAddressMask) values (1, INET_ATON(‘’), 32)

This is great for the official grid. However, other grids will start to pose a problem. Most grids, such as OsGrid, have many servers with seemingly random IP addresses since the simulators are at random places on the internet instead of one companies ip range. To represent an Open Simulator grid with a ton of regions would require thousands of records instead of maybe 10. The other problem is that someone may have a server on one grid, and then switch the sim to use another grid. They may even be running two simulators behind the same IP address, but on two different grids. This instability causes havoc in trying to identify which grid a particular script is running from.

This brings me back to the original problem of llHTTPRequest headers. If it became a standard to also include the grid name, then this would be less of a problem. Sure, OpenSim hosts could choose “Agni” as the name of their grid. I don’t know where I’m going with this, but I would like to see  an additional header for X-SecondLife-Grid (SVC-4883) that would have a value of “Agni” on the main grid. For anyone specifying Agni, I can validate that against the network addresses for Second Life. As for everyone else, I can choose either validation by IP, Grid Name, or to simply let it go through but with minimal trust.

Using evolution to solve complex problems

September 21, 2009

I’ve started to work on creating a game of life in a virtual environment based off on John Conway’s Game of Life. The game itself is based on a simple set of rules and demonstrates some really amazing behavior based on the initial patterns to start it off.

The first phase that I am going through is to work out how to use the least amount of resources. The game of life runs best on large binary grids when watching animations of gliders as well as large oscillators. I could probably get away with using 1 prim to represent 40 cells using some of the techniques that I used for my old tic-tac-toe game. In short, I can use a prism to display 5 different faces. Each of those faces can show a portion of a texture representing 8 cells. Multiply 5 by 8 and you get 40. I can probably start of with a 10×16 grid (4 prims), but make it dynamically expandable in some way.

With the Tic-Tac-Toe game, there are 27 possible of combinations on a 3 celled grid displaying 3 different states (x, o, empty). You could probably call it a trinary numbering system. I used a lot of randomization to keep looking for possible ways to layout a texture. It took a fair amount of time for the computer to come up with something.

For this project, I had 256 possible combinations with an 8 celled grid of on/off. There are more combinations to look for, and using a horizontal texture map seemed a bit out of the question, as it was a bit complex just to do 27 for the tic-tac-toe game. Instead, I started looking at other options. I decided to go with a two dimensional texture map. I could simply layout all possible combinations on a 928(16 groups)x16 grid. With 14, 848 cells, this would be too large to manage. I decided to write a program that could detect patterns within a smaller grid going forward, backward, up, and down. This would give me a better way to layout the image. In addition, the program is able to detect patterns through wrapping. That means, the last column may have the first bit, and then the first 7 columns on the same row contain the rest of the byte. This further gives the advantage of condensing the total number of rows and columns needed on the grid.

Another problem that I was starting to run into was time. I am a problem that was so complex, that I couldn’t create an answer on my own, and making random guesses had the potential of not finding an answer in my life time. I started to look into the ideas behind evolution itself. Evolution has some basic fundamentals such as mating, sensing fitness, and mutations. There is far more behind it, but these were the ideas that I pulled out and applied to programming. I made a simple program that had the following mating ritual.

  1. Loop through each organism and pick two additional organisms.
  2. The least fit organism dies and is replaced by the offspring of the other two.
  3. Repeat.

Fitness was based on the number of unique patterns found within the organisms “DNA”. The DNA was an array of bits that represented if a cell in a grid was on or off. The offspring’s DNA was a combination of both of the parents. If one parent had a specific DNA as “on” and another as “off”, I randomly choose between the two. Once the hereditary portion was determined, I then applied mutations on 10% of the DNA and flipped them.

Just to mess with the gene pool, I decided to just kill off 1% of the organism’s, and replace them with fresh organisms with all new randomized DNA to simulate a change in population.

The end results were always different. Sometimes, the answer came immediately. Other times, the answer took a lot longer. One thing that I found helpful was the number of organisms available. A very large pool of organisms was usually able to solve the answer more quickly.

In the end, I now have a 16×16 grid (256 cells) of binary values that represent 256 possible values. This is 98.8% smaller than literally writing out each cell. I have tried to work with smaller grid’s, but they haven’t worked out to all 256 possible values just yet. I would have considered myself lucky if I could get one with an 8×8 grid. There is a possibility that I could get it smaller if I work with diagonal rows as well.

I’m sure that I got a lot of theory’s wrong, and there is probably a better way of finding an answer to this problem. Who knows? However, this was the way that I found the answer on my own. I just find it interesting that evolution is helping me to create the components to create the game of life.

Life Texture Pattern Calculator

Copy Objects Between Grids

July 30, 2009

I just created a video demonstrating a little project I have been working on to export my content from the Second Life main grid onto my OpenSIM server over on OS Grid.

This is not copy bot. There are not any software programs used. The process is done using a few LSL scripts. You need to own the objects with modify permissions in order for this to work.

Prims are rezzed on OpenSIM and linked up to form a single object. Textures, Scripts, and inventory do not transfer during the process. Some of the default client textures are already available, so they will show up as if they had transferred without a problem.

I’ll be posting more details about it later over on my OSGrid page: Import/Export Between Grids by Instant Blue.

Looking up a Regions UUID

July 25, 2008

Through a capability exposed by the web-map API on, I am able to query the name of a region by specifying it’s global position.

For example, Woodbridge is located at 945, 1089. I can query the capability url for it at: 283b-4585-af4d-a3b7d9a32492?var=x&grid_x=945&grid_y=1089. I will get the following results: var x=’Woodbridge’;.

Ok, this let’s me identify the name of a region through cordinates. I have a little problem though. Regions can change location and their names. I need a constant value to keep track of. In addition, I may way to leave room open to support OpenSIM grids. From this, I deduced that RegionID is probably the constant I’m looking for.

I’ve been hunting for a way to retrieve the current region ID that an object is sitting in. I found that SignpostMarv Martin created a directory of every sim on the Agni grid in second life. I found Woodbridge and saw that he made the RegionId available in the source code. I was able to query the web page and parse out the ID.

So, I now have a way to retrieve retion id. I’d much prefer to get it direct from second life though. LSL doesn’t support that capability. I was hoping I could query the google appliance directly that is used for in- world search, but I can’t determine how to query against the website. There has got to be a way to get at that information.

I’m noticing that I can also query google itself with my regions name, and a sitesearch on The first link goes to the URL over on for woodbridge – including the region id. Tada! a second source to get that information. I would still rather search against directly. I may have to look into some HTTP sniffers to look at the traffic going accross the wire.

posted by Dedric Mauriac on Woodbridge using a blogHUD : [blogHUD permalink]

%d bloggers like this: