<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>Naked Imagination &#187; scripting</title>
	<atom:link href="http://robsmart.co.uk/tag/scripting/feed/" rel="self" type="application/rss+xml" />
	<link>http://robsmart.co.uk</link>
	<description>Emerging technology, Virtual Worlds and Cultural Observations</description>
	<pubDate>Thu, 17 Dec 2009 15:27:58 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>XML Parsing in OpenSim: Example - reading RSS feeds</title>
		<link>http://robsmart.co.uk/2008/10/27/xml-parsing-in-opensim-example-reading-rss-feeds/</link>
		<comments>http://robsmart.co.uk/2008/10/27/xml-parsing-in-opensim-example-reading-rss-feeds/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 13:21:22 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
		
		<category><![CDATA[]]></category>

		<category><![CDATA[c#]]></category>

		<category><![CDATA[opensim]]></category>

		<category><![CDATA[scripting]]></category>

		<category><![CDATA[secondlife]]></category>

		<category><![CDATA[virtualworlds]]></category>

		<guid isPermaLink="false">http://robsmart.co.uk/?p=126</guid>
		<description><![CDATA[In OpenSim you&#8217;re not just restricted to using LSL for scripting, it&#8217;s also possible to use c#. This opens up the possiblilities for far more powerful scripts that can access c# in built libraries.
For example I&#8217;ve previously mentioned that the string processing methods in Second Life are not very flexible when it comes to reading [...]]]></description>
			<content:encoded><![CDATA[<p>In OpenSim you&#8217;re not just restricted to using LSL for scripting, it&#8217;s also possible to use c#. This opens up the possiblilities for far more powerful scripts that can access c# in built libraries.</p>
<p>For example I&#8217;ve previously mentioned that the string processing methods in Second Life are not very flexible when it comes to reading formatted data. Thus the reason I implemented the osParseJSON method to make Web APIs easier to use.</p>
<p>Obviously another common data format is XML, in this case I don&#8217;t have to implement any new OpenSim script functions because the XML capabilities are available natively in c#.</p>
<p>Here is a simple example of reading the <a href="http://robsmart.co.uk/feed">RSS feed</a> for my blog, and reading out the entries in chat.</p>
<p><code><br />
//c#<br />
// displays the contents of an RSS 2.0 feed</code></p>
<p>string URL = &#8220;http://robsmart.co.uk/feed&#8221;;<br />
System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();<br />
LSL_Types.LSLString requestID;</p>
<p>public void default_event_state_entry()<br />
{<br />
llSay(0,&#8221;RSS reader current Feed is &#8221; + URL);<br />
getFeedContent();</p>
<p>}</p>
<p>public void getFeedContent()<br />
{<br />
requestID = llHTTPRequest(URL, new LSL_Types.list(), &#8220;&#8221; );<br />
}</p>
<p>public void default_event_touch_start(LSL_Types.LSLInteger total_number)<br />
{<br />
// read out the RSS feed.<br />
displayFeed();</p>
<p>}</p>
<p>public void displayFeed()<br />
{<br />
System.Xml.XmlNodeList items = xDoc.GetElementsByTagName(&#8221;item&#8221;);</p>
<p>for(int i=0;i &lt; items.Count ; i++)<br />
{<br />
string title = items[i].SelectSingleNode(&#8221;title&#8221;).InnerXml;<br />
string link = items[i].SelectSingleNode(&#8221;link&#8221;).InnerXml;</p>
<p>string description=&#8221;no description available&#8221;;</p>
<p>if(items[i].SelectSingleNode(&#8221;description&#8221;)!=null)<br />
description = items[i].SelectSingleNode(&#8221;description&#8221;).InnerXml;</p>
<p>llSay(0,title + &#8220;\n&#8221; + description + &#8220;\n&#8221;);<br />
}<br />
}</p>
<p>public void default_event_http_response(LSL_Types.LSLString request_id, LSL_Types.LSLInteger status, LSL_Types.list metadata, LSL_Types.LSLString body)<br />
{<br />
if (requestID == request_id)<br />
{<br />
// store the xml<br />
xDoc.LoadXml(body);</p>
<p>// process the xml<br />
llOwnerSay(&#8221;loaded feed&#8221;);<br />
}<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://robsmart.co.uk/2008/10/27/xml-parsing-in-opensim-example-reading-rss-feeds/feed/</wfw:commentRss>
		</item>
		<item>
		<title>OpenSim Web 2.0 contribution</title>
		<link>http://robsmart.co.uk/2008/09/14/opensim-web-20-contribution/</link>
		<comments>http://robsmart.co.uk/2008/09/14/opensim-web-20-contribution/#comments</comments>
		<pubDate>Sun, 14 Sep 2008 21:37:51 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
		
		<category><![CDATA[]]></category>

		<category><![CDATA[c#]]></category>

		<category><![CDATA[opensim]]></category>

		<category><![CDATA[opensource]]></category>

		<category><![CDATA[scripting]]></category>

		<category><![CDATA[secondlife]]></category>

		<category><![CDATA[translation]]></category>

		<guid isPermaLink="false">http://robsmart.co.uk/?p=117</guid>
		<description><![CDATA[As described over on Eightbar I have made my first contribution to the OpenSim opensource project. The contribution is in the form of a new scripting function called osParseJSON. This function allows a c# script in OpenSim to consume the JSON notation provided by many of the major Web 2.0 APIs provided by services such [...]]]></description>
			<content:encoded><![CDATA[<p>As described over on <a href="http://eightbar.co.uk">Eightbar</a> I have made my first contribution to the OpenSim opensource project. The contribution is in the form of a new scripting function called <a href="http://opensimulator.org/wiki/OSSL_Implemented">osParseJSON</a>. This function allows a c# script in OpenSim to consume the JSON notation provided by many of the major Web 2.0 APIs provided by services such as Flickr and Google translation.</p>
<p>The following example is a script that uses the Google Translate API to let an OpenSim avatar translate ther conversations between 23 different languages.</p>
<p>(disclaimer - please read the terms of conditions of the Google translate API and abide by them)</p>
<div style="text-align: left;" dir="ltr">
<pre class="source-csharp" style="padding-left: 30px;"><span class="co1">//c#</span>
<span class="co1">// This script is written as an example use of the osParseJSON method</span>
<span class="co1">// it uses the Google translate API</span>
<span class="co1">// ensure you have read the terms and conditions of the Google translate API</span>
<span class="co1">// http://code.google.com/apis/ajaxlanguage/documentation/</span>

LSL_Types.<span class="me1">key</span> requestID;
<span class="kw4">string</span> sourceLang = <span class="st0">"en"</span>;
<span class="kw4">string</span> targetLang = <span class="st0">"fr"</span>;

<span class="kw1">public</span> <span class="kw1">void</span> default_event_state_entry<span class="br0">(</span><span class="br0">)</span>
<span class="br0">{</span>
     llSay<span class="br0">(</span><span class="nu0">0</span>,<span class="st0">"translator running say '/1 sentence' to translate something"</span><span class="br0">)</span>;
     llSay<span class="br0">(</span><span class="nu0">0</span>,<span class="st0">"translator running say '/2 source langage' to change target language e.g. '/2 fr'"</span><span class="br0">)</span>;
     llSay<span class="br0">(</span><span class="nu0">0</span>,<span class="st0">"translator running say '/3 target langage' to change source language e.g. '/3 en'"</span><span class="br0">)</span>;
     llSay<span class="br0">(</span><span class="nu0">0</span>,<span class="st0">"translator running say '/4 help', to list languages"</span><span class="br0">)</span>;
     llListen<span class="br0">(</span><span class="nu0">1</span>, <span class="st0">""</span>, NULL_KEY, <span class="st0">""</span><span class="br0">)</span>;
     llListen<span class="br0">(</span><span class="nu0">2</span>, <span class="st0">""</span>, NULL_KEY, <span class="st0">""</span><span class="br0">)</span>;
     llListen<span class="br0">(</span><span class="nu0">3</span>, <span class="st0">""</span>, NULL_KEY, <span class="st0">""</span><span class="br0">)</span>;
     llListen<span class="br0">(</span><span class="nu0">4</span>, <span class="st0">""</span>, NULL_KEY, <span class="st0">""</span><span class="br0">)</span>;
<span class="br0">}</span>

<span class="kw1">public</span> <span class="kw1">void</span> default_event_touch_start<span class="br0">(</span>LSL_Types.<span class="me1">LSLInteger</span> total_number<span class="br0">)</span>
<span class="br0">{</span>
     llSay<span class="br0">(</span><span class="nu0">0</span>,<span class="st0">"translator running say '/1 sentence' to translate something"</span><span class="br0">)</span>;
     llSay<span class="br0">(</span><span class="nu0">0</span>,<span class="st0">"translator running say '/2 source langage' to change target language e.g. '/2 fr'"</span><span class="br0">)</span>;
     llSay<span class="br0">(</span><span class="nu0">0</span>,<span class="st0">"translator running say '/3 target langage' to change source language e.g. '/3 en'"</span><span class="br0">)</span>;
     llSay<span class="br0">(</span><span class="nu0">0</span>,<span class="st0">"translator running say '/4 help', to list languages"</span><span class="br0">)</span>;
<span class="br0">}</span>

<span class="kw1">public</span> <span class="kw1">void</span> default_event_http_response<span class="br0">(</span>LSL_Types.<span class="me1">LSLString</span> request_id, LSL_Types.<span class="me1">LSLInteger</span> status, LSL_Types.<span class="me1">list</span> metadata, LSL_Types.<span class="me1">LSLString</span> body<span class="br0">)</span>
<span class="br0">{</span>
        <span class="kw1">if</span> <span class="br0">(</span>requestID == request_id<span class="br0">)</span>
        <span class="br0">{</span>
            <span class="co1">// the Google JSON string returned wil be of the format</span>
            <span class="co1">//  {"responseData": {"translatedText":"Bonjour"}, "responseDetails": null, "responseStatus": 200}</span>
            <span class="co1">// call the osParseJSON method so we can read the contents </span>
            <span class="kw5">System</span>.<span class="me1">Collections</span>.<span class="me1">Hashtable</span> response = <span class="br0">(</span><span class="kw5">System</span>.<span class="me1">Collections</span>.<span class="me1">Hashtable</span><span class="br0">)</span> osParseJSON<span class="br0">(</span>body<span class="br0">)</span>;
            <span class="kw5">System</span>.<span class="me1">Collections</span>.<span class="me1">Hashtable</span> responsedata = <span class="br0">(</span><span class="kw5">System</span>.<span class="me1">Collections</span>.<span class="me1">Hashtable</span><span class="br0">)</span> response<span class="br0">[</span><span class="st0">"responseData"</span><span class="br0">]</span>;

            llSay<span class="br0">(</span><span class="nu0">0</span>,<span class="br0">(</span><span class="kw4">string</span><span class="br0">)</span>responsedata<span class="br0">[</span><span class="st0">"translatedText"</span><span class="br0">]</span><span class="br0">)</span>;
        <span class="br0">}</span>
<span class="br0">}</span>

<span class="kw1">public</span> <span class="kw1">void</span> default_event_listen<span class="br0">(</span>LSL_Types.<span class="me1">LSLInteger</span> channelIn, LSL_Types.<span class="me1">LSLString</span> name, LSL_Types.<span class="me1">LSLString</span> id, LSL_Types.<span class="me1">LSLString</span> message<span class="br0">)</span>
<span class="br0">{</span>
    <span class="kw1">if</span><span class="br0">(</span>channelIn==<span class="nu0">1</span><span class="br0">)</span>
    <span class="br0">{</span>
        <span class="kw4">string</span> toTranslate = <span class="br0">(</span><span class="kw4">string</span><span class="br0">)</span> message;
        requestID = llHTTPRequest<span class="br0">(</span> <span class="st0">"http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&amp;q="</span>+toTranslate+<span class="st0">"&amp;langpair="</span>+sourceLang+<span class="st0">"%7C"</span>+targetLang, <span class="kw3">new</span> LSL_Types.<span class="me1">list</span><span class="br0">(</span><span class="br0">)</span>, <span class="st0">""</span> <span class="br0">)</span>;  

    <span class="br0">}</span>
    <span class="kw1">else</span> <span class="kw1">if</span><span class="br0">(</span>channelIn==<span class="nu0">2</span><span class="br0">)</span>
    <span class="br0">{</span>
        sourceLang = <span class="br0">(</span><span class="kw4">string</span><span class="br0">)</span> message;
    <span class="br0">}</span>
    <span class="kw1">else</span> <span class="kw1">if</span><span class="br0">(</span>channelIn==<span class="nu0">3</span><span class="br0">)</span>
    <span class="br0">{</span>
        targetLang = <span class="br0">(</span><span class="kw4">string</span><span class="br0">)</span>message;
    <span class="br0">}</span>
    <span class="kw1">else</span> <span class="kw1">if</span><span class="br0">(</span>channelIn==<span class="nu0">4</span><span class="br0">)</span>
    <span class="br0">{</span>
        llOwnerSay<span class="br0">(</span><span class="st0">"LANGUAGE (CODE)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"*  Arabic (ar)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Bulgarian (bg)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Chinese (zh)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Croatian (hr)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Czech (cs)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Danish (da)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Dutch (nl)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* English (en)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Finnish (fi)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* French (fr)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* German (de)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Greek (el)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Hindi (hi)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Italian (it)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Japanese (ja)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Korean (ko)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Norwegian(no) "</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Polish (pl)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Portuguese (pt-PT)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Romanian (ro)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Russian (ru)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Spanish (es)"</span><span class="br0">)</span>;
        llOwnerSay<span class="br0">(</span><span class="st0">"* Swedish (sv)"</span><span class="br0">)</span>; 

    <span class="br0">}</span>
<span class="br0">}</span></pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://robsmart.co.uk/2008/09/14/opensim-web-20-contribution/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Second Life hidden video secrets</title>
		<link>http://robsmart.co.uk/2007/10/27/second-life-hidden-video-secrets/</link>
		<comments>http://robsmart.co.uk/2007/10/27/second-life-hidden-video-secrets/#comments</comments>
		<pubDate>Sat, 27 Oct 2007 10:07:31 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
		
		<category><![CDATA[]]></category>

		<category><![CDATA[lsl]]></category>

		<category><![CDATA[scripting]]></category>

		<category><![CDATA[secondlife]]></category>

		<category><![CDATA[streaming]]></category>

		<category><![CDATA[video]]></category>

		<category><![CDATA[virtualworlds]]></category>

		<guid isPermaLink="false">http://robsmart.co.uk/2007/10/27/second-life-hidden-video-secrets/</guid>
		<description><![CDATA[There is a very little known feature of Second Life to do with showing video in world, this is the ability to show different videos to individual avatars on the same land parcel. I&#8217;ve mentioned this to a quite a few people now and all have been in disbelief, even some of the Lindens seem [...]]]></description>
			<content:encoded><![CDATA[<p>There is a very little known feature of Second Life to do with showing video in world, this is <strong>the ability to show different videos to individual avatars on the same land parcel</strong>. I&#8217;ve mentioned this to a quite a few people now and all have been in disbelief, even some of the Lindens seem to be unaware of this feature.</p>
<p>The method to do this however is not a hack and has in fact been documented in the LSL API for as long as I know.</p>
<p>The method in question can be discovered by looking at the documentation for <a href="http://wiki.secondlife.com/wiki/LlParcelMediaCommandList" target="_blank">llParcelMediaCommandList </a> if you have a close look at the parameters there is one called</p>
<p><strong>PARCEL_MEDIA_COMMAND_AGENT</strong></p>
<p>the description for which is <strong>&#8220;Applies the media command to the specified agent only.&#8221;</strong></p>
<p>So lets look at a quick simple example.</p>
<p>We need a screen that can listen for urls over chat and then set the url for the person speaking.  ( The screen must be owned by someone who has media permission on the land )</p>
<p>The script for the screen is &#8230;</p>
<blockquote><p>integer listen_handle;</p>
<p>default<br />
{<br />
state_entry()<br />
{<br />
listen_handle = llListen(10, &#8220;&#8221;, &#8220;&#8221;, &#8220;&#8221;);<br />
}</p>
<p>touch_start(integer total_number)<br />
{<br />
llSay(0, &#8220;talk on channel 10 to set your personal video for this land&#8221;);<br />
}</p>
<p>listen( integer channel, string name, key id, string message )<br />
{<br />
llSay(0, &#8220;Setting Video play back to &#8221; + message);<br />
llParcelMediaCommandList( [<br />
PARCEL_MEDIA_COMMAND_URL, message,<br />
PARCEL_MEDIA_COMMAND_AGENT, id,<br />
PARCEL_MEDIA_COMMAND_TEXTURE, (key) llGetTexture(0) ] );<br />
}</p>
<p>}</p></blockquote>
<p>Here&#8217;s a quick side by side screenshot of two AVs watching a different movie at the same time on the same parcel of land.</p>
<p><a href="http://robsmart.co.uk/wp-content/uploads/2007/10/ironmanvideo.jpg" title="secondlife yoss video"><img src="http://robsmart.co.uk/wp-content/uploads/2007/10/ironmanvideo.jpg" alt="secondlife yoss video" /></a><a href="http://robsmart.co.uk/wp-content/uploads/2007/10/yossvideo.jpg" title="zeki video"><img src="http://robsmart.co.uk/wp-content/uploads/2007/10/yossvideo.jpg" alt="zeki video" height="254" width="332" /></a></p>
<p>Extra points for guessing what movie trailers they are watching <img src='http://robsmart.co.uk/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://robsmart.co.uk/2007/10/27/second-life-hidden-video-secrets/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
