You are not logged in (login or register) Sitemap | Help!

A First glance at Mini Region Modules (MRMs)

...through the eyes of a C# noob

Edited by: Simon Probert

Link

MRM stands for MiniRegionModule and is designed to bridge the Gap between LSL/OSSL and Region Modules. Are MRMs the next big thing for scripters?

Before we start, be aware that MRM's are still in early Development as far as i can see. Playing around with them can might crash your sim, give you a headache or set your cat on fire. Even if we are right now just looking at the fundament of MRM, it's nevertheless interesting, because in my Opinion, we're looking at the fundament of something big.

What is MRM? MRM stands for MiniRegionModule and is supposed to fill the Gap between LSL/OSSL and Region Modules. Adam Frisby explained this pretty nicely in his MRM Scripting - Coming Soon article.

So, for me, being the type who likes to try everything that's new, the first and most important Question was not "Why should I use it?", but "How can I use it?". So I searched the documents, blogs and other sources and donned my waterproof thermal underpants ready to jump into the icy cold water.

To get something running quickly, I skipped the ubiquitous "Hello World" and muddled together some code I found at Adam's blog and in a Mantis Patch.

//MRM:C#


using OpenSim.Region.OptionalModules.Scripting.Minimodule;

namespace OpenSim{
   
   class MiniModule : MRMBase
   {
      public override void Start()
        {
           
            Host.Object.Say("Starting up a useless script.(MRM)");        
            World.OnChat += World_OnChat;
            Host.Object.OnTouch += OnTouched;
        }

        void World_OnChat(IWorld sender, ChatEventArgs e)
        {
            if (e.Sender is IAvatar)
            {
                    Host.Object.Say("Sshh...");
            }

            if(e.Sender is IObject)
            {
                // Ignore
            }
        }
        
        void OnTouched(IObject sender, TouchEventArgs e)
        {
           Host.Object.Say("Ouch!");
        }
        
        public override void Stop()
        {

        }

   }  
}

So, at the first Glance, I have to say, yeah, MRM looks like a real programming language. Then re-wrote this small script in LSL to examine the differences.

integer lt;

default {
    
    state_entry() {
        llSay(0,"Starting up a useless Script (LSL)");
        lt = llListen(0,"","","");
    }
    
    
    listen( integer channel, string name, key id, string message )
    {
        
        list caller = llGetObjectDetails(id,[OBJECT_OWNER]);
        if(llList2Key(caller,0) == id)
        {
            if(channel == 0)
            {
                llWhisper(0,"Sshh..");                
            }
        }
    }
        
    touch_start(integer num)
    {
       llSay(0,"Ouch..");

    }
    
}

Wow, isn't there really a better way to distinguish an object from an avatar? Anyway, i love the 'is' keyword in MRMs already. So, what to do with the code? Just paste it into the LSL Editor InWorld and save it to an Object? Can that work? Nope, it can't. I need to update my OpenSim.ini :

[MRM]
    ; Enables the Mini Region Modules Script Engine. WARNING: SECURITY RISK.
    ; default is false
    Enabled = true

We'll be right back after this reboot. So, created a Box, put the script into it .... And BOOM... after some nice Exceptions and some poking around, i decide to update to the latest SVN Revision of OpenSim. Unfortunately, you only can see MRM Errors in the OpenSim.log. So, my advice, keep the logwindow open while playing around with MRM's. I finally figured out that i have to call the Class "MiniModule"...

    class MiniModule : MRMBase

I still have to figure out why ( maybe by reading some more about c# ). Please note that it can take a while for the MRM to compile. But soon you may see in the log something like this :

23:06:08 - [MRM]: Found C# MRM
23:06:08 - MRM 1
23:06:08 - MRM 2
23:06:08 - MRM 3
23:06:08 - MRM 4
23:06:08 - MRM 5
23:06:08 - MRM 6
23:06:08 - MRM 7
23:06:08 - MRM 8
23:06:08 - MRM 9
23:06:08 - MRM 10
23:06:08 - [MRM]: Created MRM Instance
23:06:08 - [MRM]: Starting MRM

Ok, so that went nicely. Fine. So we can make an object listen to chat and react on touch. But there has to be more about MRM. So let's have a closer look a at some of the Commands i've used in that script. Like :

   Host.Object.Say("Hello MRM-World..");

So, what means "Host"?

Adam answered this in MRM Scripting - Coming Soon under Hosted Scripts. Aha!, so Host.Object means, that we're dealing with the Object the script resides in. Wait a sec....if there is also an Object Property in 'World', does that mean we can do things with every Object in the Sim? I'll have to check that later..... Where are we? Ah yes....so we address the Object the Script is in with Host.Object.

What can we do with the Object? Well I guess we can make it talk by using

Host.Object.Say("..").

What else can we do?

The answer seems to be here on the Opensim Wiki. Remember, we're in C#, so that means object-oriented, this means we can access every Property and Function of an Object just by addind the Name with a '.' to our Object. That means, we can directly access all those Properties. Let's try this.

Host.Object.Description = "I'm an Object, yeah!";

and let's add that to the script. Yep, that works. How would this look in LSL?

 

llSetObjectDesc("I'm and Object, so what?");

Now I want to have a floating text above my Object, so let's add the following :

Host.Object.Text = "I'm an Object, with an MRM Script, yeah!";

Click "Save" and....

- [MRM] Error: System.NotImplementedException: The requested feature is not implemented.

Oops, never mind, i will be patient....let's try something else :

Host.Object.Physics.FloatOnWater = TRUE;

Make it  "Physical" and drop it into the water...and yes......it floats!!! ....kinda.

Ok, enough for now. So we can do with MRM a lot of things we can do with LSL/OSSL. And most of it much nicer. But wait, there was something I wanted to check....ah yes...what was with this "World" Object....? But I guess that's the next thing for me to write about. For now, happy scripting ( if it's LSL, OSSL, MRM or whatever..... ) byee..

So are MRMs the next big thing for scripters?

We don't know yet, but it's looking good so far - we will continue to experiment and maybe we can answer that question soon :)

 

References:

Links :

http://www.adamfrisby.com/blog/2009/04/mrm-the-api-continued/
http://www.adamfrisby.com/blog/2009/04/mrm-making-scripting-simpler-and-faster/ 

Article tagged:


4 comment(s) for “Experimenting with MRM”


Gravatar of Adam Frisby Adam Frisby said on Wednesday, April 29, 2009 (2:16:20 AM)
Heh thanks - I've been realing looking forward to the first public reactions from MRM, in answer to a few questions:

Yes you can modify every object in the region. Host.Object is identical to World.Objects[] - anything you can do on the host object you can do on any remote object, including bind to remote events.

Re: NotImplementedException - you will find this a bit, probably 50% of the API has that flag set right now; but I'm welcoming any patches which implement the NotImplemented bits.

I'm hoping with MRM to take this in a direction where it's a real powerful, usable API for scripting. LSL I find is crippling because it requires dirty hacks to achieve simplistic functionality (eg, your example detecting if an avatar or object is speaking).
Gravatar of Adam Frisby Adam Frisby said on Wednesday, April 29, 2009 (2:17:51 AM)
Oh, The 'MiniModule' naming thing - that's been fixed locally. I have a patch waiting to go in which will just use the first class to inherit from MRMBase rather than an enforced name.

The enforced name comes from a little AppDomain UnPack laziness, but I have the fix ready to commit.
Gravatar of Tony B Tony B said on Wednesday, April 29, 2009 (11:12:52 AM)
I say it is absolutely the next big thing!
I have been following Adam's blogs about it, and think it is a much better approach and will hopefully result in something much better then LSL ever was.
I consider LSL too limited to write real complex interactions (if you do the code complexity goes through the roof).
And this will be much better then having to write a plugin for the region which would likely require a region restart anyways to load.
Gravatar of SP SP said on Wednesday, April 29, 2009 (8:51:17 PM)
Adam has some great stuff on his blog which will be making an appearance on MP very soon :)