<?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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Phyrax &#187; LSL</title>
	<atom:link href="http://www.phyrax.com/tag/lsl/feed" rel="self" type="application/rss+xml" />
	<link>http://www.phyrax.com</link>
	<description>Under the webs hood!</description>
	<lastBuildDate>Wed, 21 Jul 2010 00:33:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Turning a script off or on</title>
		<link>http://www.phyrax.com/second-life/turning-a-script-off-or-on</link>
		<comments>http://www.phyrax.com/second-life/turning-a-script-off-or-on#comments</comments>
		<pubDate>Tue, 20 Jul 2010 04:22:23 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[Second Life]]></category>
		<category><![CDATA[LSL]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.phyrax.com/?p=269</guid>
		<description><![CDATA[While turning on or off a script is as simple as opening it and un-checking the &#8220;running&#8221; box.  Sometimes you may want to automate this process.  While I do not think this small tutorial belongs on its own page as of yet, I do still think that these two methods are worth it.  For these]]></description>
			<content:encoded><![CDATA[<p>While turning on or off a script is as simple as opening it and un-checking the &#8220;running&#8221; box.  Sometimes you may want to automate this process.  While I do not think this small tutorial belongs on its own page as of yet, I do still think that these two methods are worth it.  For these methods I will be using the <a href="http://lslwiki.net/lslwiki/wakka.php?wakka=touch_start" target="_blank">touch_start()</a> event.  While you can do other events such as a <a href="http://lslwiki.net/lslwiki/wakka.php?wakka=listen" target="_blank">listen</a> or <a href="http://lslwiki.net/lslwiki/wakka.php?wakka=link_message" target="_blank">link_message</a>, this is the fastest for me.<br />
<span id="more-269"></span></p>
<pre>Method two will be added tomorrow.  Check Back!</pre>
<h3>Method I</h3>
<p>The first method, and possibly the most simple, is followed by creating an off/on script and adding the script to the object inventory.  As always I begin by showing you the whole script.</p>
<pre class="brush: lsl; collapse: true; light: false; toolbar: true;">
string script2kill = &quot;ScriptName&quot;;

default
{
	state_entry()
	{
		llOwnerSay(&quot;Off/On Script Initialized&quot;);
	}
	touch_start(integer total_number)
	{
		integer curState = llGetScriptState(script2kill);
		if(curState==TRUE){
			llSetScriptState(script2kill, FALSE);
		}else if(curState == FALSE){
			llSetScriptState(script2kill,TRUE);
		}
	}
}
</pre>
<p>Now as you know I like to use global variables, this allows me to change data without having to sort through the script in hopes of finding my variable.  While this isn&#8217;t such a bad thing in a small script such as this, it helps out an amazing amount later down the road.  Line 01 is the global variable <span style="color: #000000;">script2kill</span>, now you can change <span style="color: #99cc00;">ScriptName</span> to whatever you want, but it must be the name of the script you want to kill when you touch the object.</p>
<pre class="brush: lsl;">
string script2kill = &quot;ScriptName&quot;;
</pre>
<p>Being that we&#8217;re using <a href="http://lslwiki.net/lslwiki/wakka.php?wakka=llSetScriptState" target="_blank">llSetScriptState</a>, the variable type of <span style="color: #000000;">script2kill </span>must be a string, and therefore must be encompassed in double quotes.  HOWEVER, and this is a big one, well not really, but anyhow, according to the LSL wiki, &#8220;While this function can be used to stop any script, it can only be used to <em>start</em> scripts which were stopped by an <tt>llSetScriptState</tt> function call.&#8221;  Therefore assuming you&#8217;re script has already been started, you can kill and restart it at any time.</p>
<p>The <a href="http://lslwiki.net/lslwiki/wakka.php?wakka=state_entry" target="_blank">state_entry </a>event isn&#8217;t anything special, by now you should know that <a href="http://lslwiki.net/lslwiki/wakka.php?wakka=State_Entry" target="_blank">state_entry </a>is required, therefore I just used <a href="http://lslwiki.net/lslwiki/wakka.php?wakka=llOwnerSay" target="_blank">llOwnerSay </a>to let you know that the script is actually ready.  You can simply remove line 09 altogether and leave it blank.  For me I like to know my scripts are ready.</p>
<p>The magic for this method really starts in the touch_start event.</p>
<pre class="brush: lsl; first-line: 9;">
	touch_start(integer total_number)
	{
		integer curState = llGetScriptState(script2kill);
		if(curState==TRUE){
			llSetScriptState(script2kill, FALSE);
		}else if(curState == FALSE){
			llSetScriptState(script2kill,TRUE);
		}
	}
</pre>
<p>Line 11 sets a local variable that I can refer too.  <a href="http://lslwiki.net/lslwiki/wakka.php?wakka=llGetScriptState" target="_blank">llGetScriptState()</a> receives a string variable and returns an integer.  Therefore we can use the <span style="color: #000000;">script2kill </span>global we set for the functions string, and we can store the functions result as our own variable, for use in <a href="http://lslwiki.net/lslwiki/wakka.php?wakka=llSetScriptState" target="_blank">llSetScriptState()</a>.  Since curState is set every time you touch the object, this script checks your script2kill to see if its off, and if it is, then it does the exact opposite.    You have to use an if&#8230;else statement because if not, then you&#8217;ll keep turning off a script that&#8217;s already off.  If you&#8217;re confused let me clarify this a little for you.</p>
<p>Line 12 uses the <a href="http://lslwiki.net/lslwiki/wakka.php?wakka=binary" target="_blank">logical binary operato</a>r to compare two values.  In more simplistic terms, it simply sees if one variable is the exact same as the other.  Therefore, since llGetScriptState returns an integer (TRUE or FALSE), we compare it to yet another integer.  If it is on, since a user has touched it then <a href="http://lslwiki.net/lslwiki/wakka.php?wakka=llSetScriptState" target="_blank">llSetScriptState </a>will kill it.  If the curState is not true, if the logic says no, then we jump down to line 14 and completely skip turning off the script.</p>
<pre><strong>INFO:</strong><span class="error"> If you haven't figured it out yet, FALSE means off, and TRUE means on!</span></pre>
<p>Line 14 checks if curState (assigned a value by line 11) is false.  If the logical binary operator says everything is okay then the script turns on the other script via <a href="http://lslwiki.net/lslwiki/wakka.php?wakka=llSetScriptState" target="_blank">llSetScriptState</a>.</p>
<pre>Additionally you can setup the on/off script to only respond to your touch or receive commands from an external script via <a href="http://lslwiki.net/lslwiki/wakka.php?wakka=llListen" target="_blank">llListen</a>.  The possibilities are endless, yet its usage is somewhat limited also.  For instance, by turning off a script that has already used <a href="http://lslwiki.net/lslwiki/wakka.php?wakka=llSetText" target="_blank">llSetText</a>, you do not remove the text.  You would need to reset the text back to empty by passing an empty string variable to <a href="http://lslwiki.net/lslwiki/wakka.php?wakka=llSetText" target="_blank">llSetText </a>within your on/off script.</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.phyrax.com/second-life/turning-a-script-off-or-on/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yet another update!</title>
		<link>http://www.phyrax.com/second-life/yet-another-update</link>
		<comments>http://www.phyrax.com/second-life/yet-another-update#comments</comments>
		<pubDate>Thu, 15 Jul 2010 07:23:04 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[Second Life]]></category>
		<category><![CDATA[LSL]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://www.phyrax.com/?p=262</guid>
		<description><![CDATA[Due to the fact that an object does not retain its key when taken into inventory and &#8220;re-rezzed&#8221;.  I now have to update the downloads system (Second Life side anyhow) to now communicate with my database to see if a new key is available.  Since the system uses llEmail, and object to object email requires]]></description>
			<content:encoded><![CDATA[<p>Due to the fact that an object does not retain its key when taken into inventory and &#8220;re-rezzed&#8221;.  I now have to update the downloads system (Second Life side anyhow) to now communicate with my database to see if a new key is available.  Since the system uses llEmail, and object to object email requires keys, when I move my server systems (which will be tomorrow) I&#8217;ll have to update the system yet again.  Again, this is only one step closer to making my off-world system sellable.</p>
<p><span style="color: #ff0000;">If you experience any issues with downloads please be patient and try again in a few hours.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phyrax.com/second-life/yet-another-update/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Script update tonight!</title>
		<link>http://www.phyrax.com/second-life/script-update</link>
		<comments>http://www.phyrax.com/second-life/script-update#comments</comments>
		<pubDate>Tue, 29 Jun 2010 06:33:14 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[Second Life]]></category>
		<category><![CDATA[LSL]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://www.phyrax.com/?p=259</guid>
		<description><![CDATA[I&#8217;ve been going on and off about doing this but it&#8217;s going to make my RL item download system for Second Life, a whole lot better. For those of you who don&#8217;t know what I&#8217;m talking about, or haven&#8217;t bought my skin kits, this system was previously a single script, however, each script would need]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been going on and off about doing this but it&#8217;s going to make my RL item download system for Second Life, a whole lot better.  For those of you who don&#8217;t know what I&#8217;m talking about, or haven&#8217;t bought my skin kits, this system was previously a single script, however, each script would need to be altered should my website change or should the server change, each product would have to have promotional items such as LM&#8217;s and NC&#8217;s added, and sometimes the script would just glitch out.  This is a pain considering I had over 33 skin kits at one time.  </p>
<p>On the end-user side of things, the box required the buyer to touch it, and being that there was large yellow letters telling them to do so, I didn&#8217;t think this would have been an issue.  Obviously I didn&#8217;t consider the language barrier, nor the younger ages that apparently couldn&#8217;t read yet.  This is fixed, and will only require the user to rez the box.  As a safety measure, if the user was to rez the box and something glitched out, then the user can still touch it to contact the server.</p>
<p>The product script now contains a fool-proof self-contained algorithm&#8230; not that big of a deal though.  I&#8217;ve just secluded the HTTP portion of the script to a central server object that I OWN.  The product box only sends data, via llEmail to the server object, that I can translate or use how I see fit.  In doing that, it will allow me to optimize the data insertion process on the actual HTTP server.</p>
<p>I may be optimizing my RL download system for end-users and sell it later on, but as for now, that&#8217;s a lot of work <img src='http://www.phyrax.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.phyrax.com/second-life/script-update/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Second Life and PHP</title>
		<link>http://www.phyrax.com/second-life/second-life-and-php</link>
		<comments>http://www.phyrax.com/second-life/second-life-and-php#comments</comments>
		<pubDate>Wed, 24 Mar 2010 22:13:13 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[Second Life]]></category>
		<category><![CDATA[Internet Communication]]></category>
		<category><![CDATA[LSL]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.phyrax.com/?p=221</guid>
		<description><![CDATA[I&#8217;ve created a beginner&#8217;s tutorial to show how to use Second Life&#8217;s llHTTPRequest function to communicate with PHP scripts on a website.  This offers absolutely limitless possabilities when attempting to communicate with websites, databases and many other web-based application platforms and APIs. View the tutorial here.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve created a beginner&#8217;s tutorial to show how to use Second Life&#8217;s <a href="http://lslwiki.net/lslwiki/wakka.php?wakka=llHTTPRequest" target="_blank">llHTTPRequest </a>function to communicate with PHP scripts on a website.  This offers absolutely limitless possabilities when attempting to communicate with websites, databases and many other web-based application platforms and APIs.</p>
<p><a href="http://www.phyrax.com/tutorials/scripting/lsl-to-php">View the tutorial here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phyrax.com/second-life/second-life-and-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
