Mono information for scripters
What is Mono?
Mono is an open-sourced programming environment in which to develop and run .NET applications. You can find out more at the Mono website. "Mono for Second Life®," which we'll just refer to as "Mono" from now on, is the integration of a new Mono-based compiler and runtime into our Second Life servers. The Mono compiler turns ordinary Linden Scripting Language (LSL) code into Mono bytecode, which the simulator runtime can then execute. In this way, Mono represents an alternate way to run LSL scripts in the Second Life world. Previously, all LSL code was compiled into LSL2 bytecode and run on the simulator's LSL2 runtime. Now, you can choose which bytecode format you want as your compile target for each LSL script you write. The appropriate runtime will execute your script.
What are the benefits of using Mono for Second Life?
|Note: We are aware that there are some LSL gurus out there who have uploaded bytecode for legitimate purposes -- in fact, most of them were active participants in the Mono beta. We hope that the capabilities and promise of Mono offset any inconvenience this may cause to their future development efforts.|
How to compile a script to Mono
To compile a script to Mono:
- Rez the object that contains the script.
- Right-click the object and select Edit. The Tools window opens.
- In the Contents tab, double-click on the script. The Script window opens. At the bottom of the Script window is a checkbox labeled Mono.
- Select the Mono checkbox and click Save.
The script will then generate Mono bytecode, and whenever it runs, it will run automatically in the Mono runtime.
- If you want to convert the script back to plain old LSL, simply uncheck the box and save.
- If you have a bunch of scripts in one or more prims that you want to recompile all at once, simply select all the prims or linksets containing the scripts. Then, from the Tools menu, select Recompile selection > Mono.
Reporting issues with Mono
You can report issues with Mono using the Public Issue Tracker (PJIRA).
|Note: You should check SVC-1276 before you create a new issue -- someone may have already reported the problem you see.|
The following fields should be set for Mono-related issues:
- In the Project dropdown, select 2. Second Life Service - SVC (unless it's clearly a viewer issue, in which case select 1. Second Life Viewer - VWR).
- In the Issue Type dropdown, select Bug.
- Place the word "Mono" in the Summary.
- In the Component list, select Scripts.
- Link the issue you create to SVC-1276. This will allow others to quickly see all open Mono issues.
The following are some frequently asked questions about Mono.
So, can I just recompile all my scripts to Mono and start selling the Mono versions?
Mono is compatible with LSL2, and many scripts convert to Mono with no noticeable differences. However, the timing differences (Mono being typically faster than LSL2) can introduce behavioral changes in scripts. Therefore, when you convert a script to Mono, you should do a full QA pass on the script to insure that it still operates exactly as intended. You may also find that you can take advantage of Mono's 64K limit: if you have a project with two or more 16K scripts that have to pass data to each other, see if you can now have a single script using Mono, eliminating the inter-script communication.
Are you going to eliminate LSL2?
We have no plans to eliminate LSL2. We may eliminate the LSL2 compiler, which will mean that all new and edited scripts will become Mono, but we are unlikely to ever turn off the LSL2 runtime. Legacy scripts, therefore, will continue to run.
Why not simply convert all scripts to Mono bytecode and then be done with LSL2?
There are several reasons why we do not want to mandate the conversion to Mono:
- Scripts would be reset when we recompile. This would have undesirable effects for many running scripts.
- There are slight differences between LSL2 and Mono. Some content would break.
- Timing differences will cause some scripts to behave differently under Mono. We need to allow scripters the opportunity to QA the Mono versions of their scripts, and make necessary changes.
- There are some scripts running in the Second Life world today for which we no longer have the corresponding actual code (the text asset was somehow lost or deleted), but whose LSL bytecode still exists. These scripts can still run, but we cannot modify or recompile them.
When do I get to start scripting Second Life in $favorite_language?
We've already done a proof of concept for programming SL with C#, and it's likely that C# will be the first "alternative" language that we'll support. However, scheduling for this or any project is a question of balancing priorities; there are several other projects that demand the attention of our development organization, and our primary concern is determining which efforts give the most benefit to Second Life and its Residents as a whole. We encourage all interested Residents to attend some of the Mono office hours and give us feedback on your priorities. Alternatively, you can submit new feature requests using the Public Issue Tracker, which can garner other resident votes.