<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.osgrid.org/index.php?action=history&amp;feed=atom&amp;title=Scripting_Tutorial-06</id>
	<title>Scripting Tutorial-06 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.osgrid.org/index.php?action=history&amp;feed=atom&amp;title=Scripting_Tutorial-06"/>
	<link rel="alternate" type="text/html" href="http://wiki.osgrid.org/index.php?title=Scripting_Tutorial-06&amp;action=history"/>
	<updated>2026-10-25T11:06:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>http://wiki.osgrid.org/index.php?title=Scripting_Tutorial-06&amp;diff=335&amp;oldid=prev</id>
		<title>Osgridadmin at 17:59, 24 August 2018</title>
		<link rel="alternate" type="text/html" href="http://wiki.osgrid.org/index.php?title=Scripting_Tutorial-06&amp;diff=335&amp;oldid=prev"/>
		<updated>2018-08-24T17:59:44Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:59, 24 August 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Scripting &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Tutorial &lt;/del&gt;#6 &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;held &lt;/del&gt;August 19th, 2018 at Sandbox Plaza by Fu Barr ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Scripting &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Lesson &lt;/ins&gt;#6 &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;- Held &lt;/ins&gt;August 19th, 2018 at Sandbox Plaza by Fu Barr ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;lsl&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;lsl&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Osgridadmin</name></author>
	</entry>
	<entry>
		<id>http://wiki.osgrid.org/index.php?title=Scripting_Tutorial-06&amp;diff=333&amp;oldid=prev</id>
		<title>Osgridadmin: Created page with &quot; == Scripting Tutorial #6 held August 19th, 2018 at Sandbox Plaza by Fu Barr ==  &lt;source lang=&quot;lsl&quot;&gt;  /*      Fu&#039;s basic light switch      v0.2      - turn-off-the-lamp timeou...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wiki.osgrid.org/index.php?title=Scripting_Tutorial-06&amp;diff=333&amp;oldid=prev"/>
		<updated>2018-08-24T17:56:50Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot; == Scripting Tutorial #6 held August 19th, 2018 at Sandbox Plaza by Fu Barr ==  &amp;lt;source lang=&amp;quot;lsl&amp;quot;&amp;gt;  /*      Fu&amp;#039;s basic light switch      v0.2      - turn-off-the-lamp timeou...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
== Scripting Tutorial #6 held August 19th, 2018 at Sandbox Plaza by Fu Barr ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lsl&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
&lt;br /&gt;
    Fu&amp;#039;s basic light switch&lt;br /&gt;
&lt;br /&gt;
    v0.2 &lt;br /&gt;
    - turn-off-the-lamp timeout&lt;br /&gt;
    - expanded setup&lt;br /&gt;
&lt;br /&gt;
    v0.1&lt;br /&gt;
    - basic on/off toggle&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
integer DEBUG = TRUE;&lt;br /&gt;
&lt;br /&gt;
integer LAMP_LINK_ID;&lt;br /&gt;
float   LAMP_TIMEOUT = 5.0;&lt;br /&gt;
&lt;br /&gt;
default {&lt;br /&gt;
&lt;br /&gt;
    state_entry() {&lt;br /&gt;
&lt;br /&gt;
        llOwnerSay(&amp;quot;running: &amp;quot; + llGetScriptName());&lt;br /&gt;
&lt;br /&gt;
        if(DEBUG){llOwnerSay(&amp;quot;state: default&amp;quot;);}&lt;br /&gt;
&lt;br /&gt;
        // 0. setup lamp&lt;br /&gt;
        integer i   = 1;    // linked prims are numbered from 1&lt;br /&gt;
        integer end = llGetNumberOfPrims();&lt;br /&gt;
&lt;br /&gt;
        if(DEBUG){llOwnerSay(&amp;quot;Number of prims: &amp;quot; + (string) end);}&lt;br /&gt;
&lt;br /&gt;
        while(i &amp;lt;= end) {&lt;br /&gt;
&lt;br /&gt;
            if(DEBUG){llOwnerSay(&amp;quot;Link ID: &amp;quot; + (string) i + &amp;quot;, prim name: &amp;quot; + llGetLinkName(i));}&lt;br /&gt;
&lt;br /&gt;
            if(llGetLinkName(i) == &amp;quot;bulb&amp;quot;) {&lt;br /&gt;
&lt;br /&gt;
                LAMP_LINK_ID = i;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            i++;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        // 1. showtime!&lt;br /&gt;
        state unlit;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
state unlit {&lt;br /&gt;
&lt;br /&gt;
    state_entry() {&lt;br /&gt;
&lt;br /&gt;
        if(DEBUG) {&lt;br /&gt;
&lt;br /&gt;
            llOwnerSay(&amp;quot;state: unlit&amp;quot;);&lt;br /&gt;
            llOwnerSay(&amp;quot;LAMP_LINK_ID: &amp;quot; + (string) LAMP_LINK_ID);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        llSetLinkPrimitiveParamsFast(LAMP_LINK_ID, &lt;br /&gt;
&lt;br /&gt;
            // the UUID here is the OSgrid specific one for &amp;#039;Blank Texture&amp;#039;&lt;br /&gt;
&lt;br /&gt;
            [ PRIM_FULLBRIGHT,  ALL_SIDES, FALSE,&lt;br /&gt;
              PRIM_TEXTURE,     ALL_SIDES, &amp;quot;5748decc-f629-461c-9a36-a35a221fe21f&amp;quot;, &amp;lt;1,1,0&amp;gt;, &amp;lt;0,0,0&amp;gt;, 0 ]&lt;br /&gt;
        );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    touch_end(integer num_touches) {&lt;br /&gt;
&lt;br /&gt;
        if(llDetectedLinkNumber(0) == LINK_ROOT) {&lt;br /&gt;
&lt;br /&gt;
            state lit;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
state lit {&lt;br /&gt;
&lt;br /&gt;
    state_entry() {&lt;br /&gt;
&lt;br /&gt;
        if(DEBUG) {&lt;br /&gt;
&lt;br /&gt;
            llOwnerSay(&amp;quot;state: lit&amp;quot;);&lt;br /&gt;
            llOwnerSay(&amp;quot;LAMP_TIMEOUT: &amp;quot; + (string) LAMP_TIMEOUT);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        // 0. switch on lamp&lt;br /&gt;
        llSetLinkPrimitiveParamsFast(LAMP_LINK_ID, &lt;br /&gt;
&lt;br /&gt;
            // like in the &amp;#039;unlit&amp;#039; state, the UUID here is the OSgrid specific one for &amp;#039;Blank Texture&amp;#039;&lt;br /&gt;
&lt;br /&gt;
            [ PRIM_FULLBRIGHT,  ALL_SIDES, TRUE,&lt;br /&gt;
              PRIM_TEXTURE,     ALL_SIDES, &amp;quot;5748decc-f629-461c-9a36-a35a221fe21f&amp;quot;, &amp;lt;1,1,0&amp;gt;, &amp;lt;0,0,0&amp;gt;, 0 ]&lt;br /&gt;
        );&lt;br /&gt;
        &lt;br /&gt;
        // 1. setup timer event&lt;br /&gt;
        llSetTimerEvent(LAMP_TIMEOUT);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    timer() {&lt;br /&gt;
&lt;br /&gt;
        state unlit;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 [11:32]  Arielle Popstar: wouldnt  have  thought    it  could  be  made  to  look that  good  in  prim&lt;br /&gt;
 [11:32]  Fu Barr: hey albertlr&lt;br /&gt;
 [11:32]  Arielle Popstar: Hi  Albertr&lt;br /&gt;
 [11:32]  albertlr Landar: Hum. Audrey 2?&lt;br /&gt;
 [11:32]  Fu Barr: nope Alien Plant :)&lt;br /&gt;
 [11:33]  Caro Fayray is Offline&lt;br /&gt;
 [11:33]  albertlr Landar: Little Shop of Horrors.&lt;br /&gt;
 [11:33]  Fu Barr: hehe - never saw that film&lt;br /&gt;
 [11:33]  albertlr Landar: I did that show several times at my Theatre&lt;br /&gt;
 [11:33]  albertlr Landar: No the musical.&lt;br /&gt;
 [11:33]  Arielle Popstar: Hi  cilla&lt;br /&gt;
 [11:33]  cilla teebrook: howdy&lt;br /&gt;
 [11:33]  Fu Barr: hi cilla - welcome :)&lt;br /&gt;
 [11:34]  Arielle Popstar: grabbing  coffee,  brb&lt;br /&gt;
 [11:34]  Fu Barr: well i&amp;#039;m going to wait a few more minutes and then i&amp;#039;ll start. today will (hopefully) be a shorter lesson than last wekk.&lt;br /&gt;
 [11:35]  Fu Barr: hey wiz - welcome :)&lt;br /&gt;
 [11:35]  Wizard Atazoth: Greetings,&lt;br /&gt;
 [11:35]  Fu Barr: pull up some square cm&amp;#039;s of sand :)&lt;br /&gt;
 [11:35]  Fu Barr: we&amp;#039;ll wait for ari to return with coffee and start&lt;br /&gt;
 [11:35]  albertlr Landar: and donuts?&lt;br /&gt;
 [11:36]  Fu Barr: who knows - ive got tea and madeleines&lt;br /&gt;
 [11:36]  Fu Barr: albertlr - will you be recording the log?&lt;br /&gt;
 [11:36]  albertlr Landar: yes&lt;br /&gt;
 [11:37]  paela argus: hi&lt;br /&gt;
 [11:37]  Fu Barr: cool - thnx&lt;br /&gt;
 [11:37]  paela argus: sorry i just wake up&lt;br /&gt;
 [11:37]  Fu Barr: hey paela :)&lt;br /&gt;
 [11:37]  albertlr Landar: Hi paela&lt;br /&gt;
 [11:37]  Fu Barr: arielle - you back yet?&lt;br /&gt;
 [11:37]  Arielle Popstar: bk&lt;br /&gt;
 [11:38]  Fu Barr: okay let&amp;#039;s start )&lt;br /&gt;
 [11:38]  Fu Barr: so first a short recap of last week and then we&amp;#039;ll segway into this week&amp;#039;s subject: Events&lt;br /&gt;
 [11:38]  Fu Barr: last week we spoke about a few things the most important were:&lt;br /&gt;
 [11:38]  Fu Barr: 1. every object/link set has a life cycle&lt;br /&gt;
 [11:39]  Fu Barr: rez, exist, de-rez&lt;br /&gt;
 [11:39]  Fu Barr: during this life-cycle a script that in placed inside an object/link set can react to the world around it. things that happen in the world during the life cycles of the object/linkset are called events&lt;br /&gt;
 [11:40]  Fu Barr: 3. inside of an object/link set this life-cycle can be extended by stepping through &amp;#039;states&amp;#039;&lt;br /&gt;
 [11:41]  Fu Barr: 4. there&amp;#039;s always one default state... called &amp;#039;default&amp;#039;&lt;br /&gt;
 [11:41]  Fu Barr: 5. a scripter can decide to use more than one state to structure his/her code.&lt;br /&gt;
 [11:41]  Fu Barr: 6. brackets {} indicate blocks of code.&lt;br /&gt;
 [11:41]  Fu Barr: 7. blocks of code always have open and close brackets - they ALWAYS need to be balanced.&lt;br /&gt;
 [11:42]  Fu Barr: i think that&amp;#039;s just about the core of what we spoke about last week.&lt;br /&gt;
 [11:42]  Fu Barr: the chat log is on the wiki and the forum if you want to relive my typonese :)&lt;br /&gt;
 [11:42]  Arielle Popstar: i  corrected  that :)&lt;br /&gt;
 [11:42]  Fu Barr: so - today we&amp;#039;re going to spend a little more time with the notion of events&lt;br /&gt;
 [11:42]  Arielle Popstar: it  was an event&lt;br /&gt;
 [11:43]  Fu Barr: I&amp;#039;ve tried to keep it short.&lt;br /&gt;
 [11:43]  Fu Barr: lol&lt;br /&gt;
 [11:43]  Fu Barr: so without further ado - please try and &amp;#039;take copy&amp;#039; this Alien Plant&lt;br /&gt;
 [11:43]  Fu Barr: then rez it from inv.&lt;br /&gt;
 [11:43]  paela argus: i love this plant&lt;br /&gt;
 [11:43]  Fu Barr: welcome koni&lt;br /&gt;
 [11:44]  Arielle Popstar: yes  its  really  nice&lt;br /&gt;
 [11:44]  Fu Barr: please take a copy this plant and rez it&lt;br /&gt;
 [11:44]  Koni Lanzius: ty sweetie&lt;br /&gt;
 [11:44]  Arielle Popstar: Hi  Koni&lt;br /&gt;
 [11:44]  Fu Barr: now once you&amp;#039;ve rezzed it...&lt;br /&gt;
 [11:44]  Koni Lanzius: hi there :)&lt;br /&gt;
 [11:44]  Fu Barr: click on the sphere base once. and wait&lt;br /&gt;
 [11:45]  Fu Barr: you&amp;#039;ll see the &amp;#039;light bulb&amp;#039; in the flower go on and then off&lt;br /&gt;
 [11:45]  Fu Barr: try it again if you missed it&lt;br /&gt;
 [11:45]  Fu Barr: click once and then wait&lt;br /&gt;
 [11:45]  Fu Barr: wait&lt;br /&gt;
 [11:45]  Fu Barr: the lamp will go off on its own&lt;br /&gt;
 [11:45]  Alien plant: state: unlit&lt;br /&gt;
 [11:45]  Alien plant: LAMP_LINK_ID: 13&lt;br /&gt;
 [11:45]  Alien plant: state: lit&lt;br /&gt;
 [11:45]  Alien plant: LAMP_TIMEOUT: 5.000000&lt;br /&gt;
 [11:45]  Alien plant: state: unlit&lt;br /&gt;
 [11:45]  Fu Barr: and in the meantime there&amp;#039;s a bunch of debug data being show on your screen.&lt;br /&gt;
 [11:46]  Fu Barr: so let&amp;#039;s open the script and see what&amp;#039;s going on&lt;br /&gt;
 [11:46]  Fu Barr: everybody got the script open?&lt;br /&gt;
 [11:46]  Fu Barr: I&amp;#039;ll assume you have :)&lt;br /&gt;
 [11:46]  Fu Barr: okay - let&amp;#039;s go&lt;br /&gt;
 [11:47]  Wizard Atazoth: Greetings, Jeff&lt;br /&gt;
 [11:47]  Jeff Hall: hey Wiz and everyone&lt;br /&gt;
 [11:47]  Fu Barr: so first of all, at the top of the script I&amp;#039;ve added a version note. so i know what is different in this script from the previous one&lt;br /&gt;
 [11:47]  Fu Barr: hey jeff :)&lt;br /&gt;
 [11:47]  Wizard Atazoth: Alien plants are multiplying here ^_^&lt;br /&gt;
 [11:47]  Fu Barr: this is not something you have to do. It&amp;#039;s something that I do for myself so in 3 weeks time i know what this thing does&lt;br /&gt;
 [11:48]  Fu Barr: I do recommend you do something similar with your own scripts&lt;br /&gt;
 [11:48]  Fu Barr: your free to decide what/how etc.&lt;br /&gt;
 [11:48]  Fu Barr: now, just like in the previous script there are a few CONSTANT variables at the top&lt;br /&gt;
 [11:49]  Fu Barr: we said Constants were variables that are set once and don&amp;#039;t change. and we use CAPITALS to hint at that.&lt;br /&gt;
 [11:49]  Fu Barr: we see that there&amp;#039;s an extra variable in this version of the script - s= which is the length of time to wait before the lamp goes out automatically&lt;br /&gt;
 [11:49]  Fu Barr: LAMP_TIMEPOUT&lt;br /&gt;
 [11:49]  Fu Barr: it&amp;#039;s made up by me.&lt;br /&gt;
 [11:50]  Fu Barr: not something that is already defined in LSL&lt;br /&gt;
 [11:50]  Fu Barr: then, if you look we have the same 3 states as in the previous version default, unlit and lit&lt;br /&gt;
 [11:50]  Fu Barr: but, in the default one there&amp;#039;s some significant changes&lt;br /&gt;
 [11:51]  Fu Barr: remember how in the first version of this script we set the LINK_LAMP variable to 3&lt;br /&gt;
 [11:51]  Fu Barr: because that was the 3rd and final prim in the link set...&lt;br /&gt;
 [11:51]  Fu Barr: and we needed to know which prim to change so it would &amp;#039;light up&amp;#039;&lt;br /&gt;
 [11:51]  Fu Barr: well. in this version we&amp;#039;re going it in a MUCH smarter way&lt;br /&gt;
 [11:51]  Fu Barr: let&amp;#039;s read the code.&lt;br /&gt;
 [11:52]  Fu Barr: find //0. setup lamp&lt;br /&gt;
 [11:52]  Fu Barr: we&amp;#039;ll start reading from there&lt;br /&gt;
 [11:52]  Fu Barr: I define 2 new variables&lt;br /&gt;
 [11:52]  Arielle Popstar: 27&lt;br /&gt;
 [11:52]  Fu Barr: &amp;quot;i&amp;quot; and &amp;quot;end&amp;quot;&lt;br /&gt;
 [11:52]  Fu Barr: &amp;quot;i&amp;quot; is short for increment&lt;br /&gt;
 [11:52]  Fu Barr: and &amp;quot;end&amp;quot; is short for.... end&lt;br /&gt;
 [11:52]  Fu Barr: :)&lt;br /&gt;
 [11:53]  Fu Barr: then there&amp;#039;s one of the if DEBUG things, ignore that and move to the line: while(i &amp;lt;= end)&lt;br /&gt;
 [11:53]  Fu Barr: what I&amp;#039;m asking the script to do here is do something while &amp;quot;i&amp;quot; is smaller or equal to &amp;quot;end&amp;quot;....&lt;br /&gt;
 [11:53]  Fu Barr: and who can tell me what &amp;quot;end&amp;quot; is?&lt;br /&gt;
 [11:53]  Fu Barr: or rather what value is held in &amp;quot;end&amp;quot;&lt;br /&gt;
 [11:54]  Fu Barr: well the line where we define &amp;quot;end&amp;quot; says:&lt;br /&gt;
 [11:54]  Fu Barr: integer end = llGetNumberOfPrims();&lt;br /&gt;
 [11:54]  Fu Barr: so it stands to reason that llGetNumberOfPrims will return a value that&amp;#039;s the number of prims in the link set&lt;br /&gt;
 [11:55]  Fu Barr: and why do we need that number?&lt;br /&gt;
 [11:55]  Fu Barr: well because the way that I&amp;#039;m doing things now is...&lt;br /&gt;
 [11:55]  Fu Barr: I&amp;#039;m looping through all the prims in the link set...&lt;br /&gt;
 [11:55]  Fu Barr: and when I find the prim that I&amp;#039;ve called &amp;#039;bulb&amp;#039;&lt;br /&gt;
 [11:55]  Fu Barr: then I stick that link id into LAMP_LINK_ID&lt;br /&gt;
 [11:56]  Fu Barr: so that&amp;#039;s my &amp;#039;algorithm&amp;#039; for finding the right prim to &amp;#039;light up&amp;#039;&lt;br /&gt;
 [11:56]  Fu Barr: loop through all the prims&lt;br /&gt;
 [11:56]  Fu Barr: and when you find the one called &amp;#039;bulb&amp;#039; save it&amp;#039;s number&lt;br /&gt;
 [11:56]  Fu Barr: lets see the code...&lt;br /&gt;
 [11:56]  Fu Barr: line 33&lt;br /&gt;
 [11:57]  Fu Barr: while &amp;quot;i&amp;quot; is less than the last link id,&lt;br /&gt;
 [11:57]  Fu Barr: line 37&lt;br /&gt;
 [11:57]  Fu Barr: if the link name of the link at link id number &amp;quot;i&amp;quot; is equal to &amp;#039;bulb&amp;#039;&lt;br /&gt;
 [11:58]  Fu Barr: then set LAMP_LINK_ID to whatever value &amp;quot;i&amp;quot; is&lt;br /&gt;
 [11:58]  Fu Barr: then continue the loop.&lt;br /&gt;
 [11:58]  Fu Barr: by increasing &amp;quot;i&amp;quot; to the next value&lt;br /&gt;
 [11:58]  Fu Barr: we have the script march past every link in the link set and check the name of each link prim&lt;br /&gt;
 [11:59]  Fu Barr: once we find the right link, we store the id.&lt;br /&gt;
 [11:59]  Fu Barr: i hope this is clear to all&lt;br /&gt;
 [11:59]  Fu Barr: questions?&lt;br /&gt;
 [11:59]  Fu Barr: cool.&lt;br /&gt;
 [11:59]  Fu Barr: it doesn&amp;#039;t take a lot of imagination that a loop like this can be used to initialize all sorts of things.&lt;br /&gt;
 [12:00]  Fu Barr: but for our simple plant thing - this is all we need&lt;br /&gt;
 [12:00]  Fu Barr: and then, we leave the default state because we force the script to move to the &amp;#039;unlit&amp;#039; state&lt;br /&gt;
 [12:00]  Fu Barr: thats in line 46&lt;br /&gt;
 [12:00]  Fu Barr: and we never go back into the default state after that&lt;br /&gt;
 [12:01]  Fu Barr: so, when we get into the unlit state...&lt;br /&gt;
 [12:01]  Fu Barr: we have an event.&lt;br /&gt;
 [12:01]  Fu Barr: the &amp;#039;state_entry&amp;#039; event&lt;br /&gt;
 [12:01]  Fu Barr: and there we do what we did last week - we switch off the bulb.&lt;br /&gt;
 [12:02]  Fu Barr: I also removed the switching off of the root prim (if you compare the two scripts) because we don&amp;#039;t have the green cylinder button in this plant.&lt;br /&gt;
 [12:02]  Fu Barr: then the script just waits.&lt;br /&gt;
 [12:02]  Fu Barr: it sits and does nothing&lt;br /&gt;
 [12:02]  Fu Barr: just hanging about in the unlit state&lt;br /&gt;
 [12:03]  Fu Barr: until.... a new event happens&lt;br /&gt;
 [12:03]  albertlr Landar: unless you click it again.&lt;br /&gt;
 [12:03]  Fu Barr: you touch the plant - exactly&lt;br /&gt;
 [12:03]  Fu Barr: and like jeff said last week, we &amp;#039;handle&amp;#039; this event in the event handler &amp;#039;touch_end&amp;#039;&lt;br /&gt;
 [12:03]  Fu Barr: liine 70&lt;br /&gt;
 [12:04]  Fu Barr: in this block, if check...&lt;br /&gt;
 [12:04]  Fu Barr: if the touch happened to be on the root prim, then...&lt;br /&gt;
 [12:04]  Fu Barr: go to the state &amp;#039;lit&amp;#039;&lt;br /&gt;
 [12:04]  Fu Barr: that&amp;#039;s all the event handler does. And all it has to do.&lt;br /&gt;
 [12:04]  Fu Barr: It&amp;#039;s the switch part.&lt;br /&gt;
 [12:05]  Fu Barr: wait till there&amp;#039;s a click event, then do something&lt;br /&gt;
 [12:05]  Fu Barr: all good - welcome - take a copy of the plant! :)&lt;br /&gt;
 [12:05]  Wizard Atazoth: Greetings, inanna.&lt;br /&gt;
 [12:05]  Fu Barr: open it up and dive into the script with us :)&lt;br /&gt;
 [12:05]  Jeff Hall: hey ina&lt;br /&gt;
 [12:05]  inanna beaumont: hi all :-)&lt;br /&gt;
 [12:05]  Fu Barr: so now that we have line 74 sending us to &amp;#039;lit&amp;#039; lets see what&amp;#039;s in the lit state...&lt;br /&gt;
 [12:06]  Alien plant: state: lit&lt;br /&gt;
 [12:06]  Alien plant: LAMP_TIMEOUT: 5.000000&lt;br /&gt;
 [12:06]  Alien plant: state: unlit&lt;br /&gt;
 [12:06]  Alien plant: LAMP_LINK_ID: 13&lt;br /&gt;
 [12:06]  Fu Barr: well again - there&amp;#039;s always the &amp;#039;state_entry&amp;#039; event handler. you always have one of those.&lt;br /&gt;
 [12:06]  Fu Barr: and the first bits are all the DEBUG printing information stuff. that now old news for us.&lt;br /&gt;
 [12:06]  Fu Barr: but look at line 90&lt;br /&gt;
 [12:07]  Fu Barr: I commented there: // 0. switch on lamp&lt;br /&gt;
 [12:07]  Fu Barr: and in line 99: // 1. setup timer event&lt;br /&gt;
 [12:07]  Fu Barr: this is how I build my &amp;#039;steps&amp;#039;&lt;br /&gt;
 [12:07]  Fu Barr: i write in human language in a comment what the script needs to do... and then i write the code that does it.&lt;br /&gt;
 [12:08]  Fu Barr: that way i don&amp;#039;t go nuts trying to figure out what to do.&lt;br /&gt;
 [12:08]  Fu Barr: in this case...&lt;br /&gt;
 [12:08]  Fu Barr: the script needs to turn on the bulb and then set the timer in motion&lt;br /&gt;
 [12:08]  Fu Barr: so lets read in the code...&lt;br /&gt;
 [12:08]  Fu Barr: the switching on is exactly the same as last week&lt;br /&gt;
 [12:08]  Fu Barr: we use llSetLinkPrimitiveParamsFast&lt;br /&gt;
 [12:09]  Fu Barr: function (more about those in two weeks)&lt;br /&gt;
 [12:09]  Fu Barr: and we feed it the LAMP_LINK_ID so it knows which of the prims in the link set to modify and we give it the modification parameters&lt;br /&gt;
 [12:09]  Fu Barr: this is the same as we&amp;#039;ve been doing all along&lt;br /&gt;
 [12:09]  Fu Barr: but in line 100 we do something new&lt;br /&gt;
 [12:09]  Fu Barr: in line 100 we actually FORCE AN EVENT TO HAPPEN&lt;br /&gt;
 [12:10]  Fu Barr: usually an event happens because something happens in the world&lt;br /&gt;
 [12:10]  Fu Barr: you touch a prim&lt;br /&gt;
 [12:10]  Fu Barr: you collide with it you pay it money etc.&lt;br /&gt;
 [12:10]  Fu Barr: but a timer is something we have to set in motion ourselves&lt;br /&gt;
 [12:10]  Fu Barr: it&amp;#039;s like pressing the button on a countdown timer&lt;br /&gt;
 [12:11]  Fu Barr: and how long does it wait before it sets off the timer event?&lt;br /&gt;
 [12:11]  Fu Barr: well...&lt;br /&gt;
 [12:11]  Fu Barr: it waits LAMP_TIMEOUT seconds&lt;br /&gt;
 [12:11]  Fu Barr: which we&amp;#039;ve defined all the way at the top of our script&lt;br /&gt;
 [12:11]  Fu Barr: in our case 5.0 seconds&lt;br /&gt;
 [12:12]  Fu Barr: if you want to have it wait longer/shorter - you just change the value&lt;br /&gt;
 [12:12]  Fu Barr: so what happens after LAMP_TIMEOUT seconds passes?&lt;br /&gt;
 [12:12]  Fu Barr: the script engine will fire the timer event...&lt;br /&gt;
 [12:12]  Fu Barr: and in line 103...&lt;br /&gt;
 [12:12]  Fu Barr: we see the timer event handler&lt;br /&gt;
 [12:13]  Fu Barr: all it does... is send the script back into its &amp;#039;unlit&amp;#039; state.&lt;br /&gt;
 [12:13]  Fu Barr: and we know that the state_entry event handler of the &amp;#039;unlit&amp;#039; state... that turns off the bulb&lt;br /&gt;
 [12:13]  Fu Barr: and that&amp;#039;s all there is to it.&lt;br /&gt;
 [12:13]  Fu Barr: 3 states and a couple of event handlers&lt;br /&gt;
 [12:13]  Fu Barr: default for setting up the correct ID of the bulb&lt;br /&gt;
 [12:14]  Fu Barr: and lit/unlit states to light and turn off the lamp&lt;br /&gt;
 [12:14]  Fu Barr: and a timer event and event handler to turn off the lamp at the right time.&lt;br /&gt;
 [12:14]  Fu Barr: dassit.&lt;br /&gt;
 [12:14]  Fu Barr: end of.&lt;br /&gt;
 [12:15]  Arielle Popstar: why  does  the  script  identify  the  bulb  as:&lt;br /&gt;
 [12:15]  Arielle Popstar: Alien plant: Link ID: 13, prim name: bulb&lt;br /&gt;
 [12:15]  Fu Barr: now of course there&amp;#039;s a bunch more event handlers etc. and we&amp;#039;ll see more of them in the next two sessions.&lt;br /&gt;
 [12:15]  Arielle Popstar: while  in edit  mode  it  shows  as  10&lt;br /&gt;
 [12:15]  Fu Barr: becuae that&amp;#039;s how it&amp;#039;s been linked&lt;br /&gt;
 [12:16]  Fu Barr: i have no idea - lol&lt;br /&gt;
 [12:16]  Fu Barr: it does work though&lt;br /&gt;
 [12:16]  Arielle Popstar: its  a miracle&lt;br /&gt;
 [12:16]  Fu Barr: i&amp;#039;ll have to dig into that.&lt;br /&gt;
 [12:16]  Fu Barr: yes indeed!&lt;br /&gt;
 [12:17]  cilla teebrook: sorry RL needs me&lt;br /&gt;
 [12:17]  Fu Barr: it might be a script reset thing&lt;br /&gt;
 [12:17]  cilla teebrook: ty fu&lt;br /&gt;
 [12:17]  Fu Barr: i dunno - will try and figure it out for next week.&lt;br /&gt;
 [12:17]  Fu Barr: yvw - thanks for joining!&lt;br /&gt;
 [12:17]  Arielle Popstar: tc  Cilla&lt;br /&gt;
 [12:17]  Fu Barr: any questionis abbout this session?&lt;br /&gt;
 [12:17]  Fu Barr: I though i&amp;#039;d try and keep it short this time.&lt;br /&gt;
 [12:18]  Arielle Popstar: does  everyone  see  my  debug  messages?&lt;br /&gt;
 [12:18]  Fu Barr: hopefully repeating some of the stuff from last week and a bit more time on events reading the code made it all a bit clearer so we can do some more complex stuff nexxt week.&lt;br /&gt;
 [12:18]  albertlr Landar: no&lt;br /&gt;
 [12:18]  albertlr Landar: only your debug message will show in your chat.&lt;br /&gt;
 [12:18]  Fu Barr: no - i&amp;#039;m using llOwnerSay() which keeps all the messages private&lt;br /&gt;
 [12:18]  Arielle Popstar: yes  it  did  help  to go back over that  Fu&lt;br /&gt;
 [12:19]  Fu Barr: please run with the script - relink the plant and see if/how it should still work&lt;br /&gt;
 [12:19]  Fu Barr: because the script should still pick up the next link id every time you relink it&lt;br /&gt;
 [12:19]  Fu Barr: try and break the script and learn from the broken pieces :)&lt;br /&gt;
 [12:20]  Fu Barr: next week we&amp;#039;re going to move on to something entirely more powerful&lt;br /&gt;
 [12:20]  Arielle Popstar: cool&lt;br /&gt;
 [12:20]  Fu Barr: we&amp;#039;re going to add scripting to this:&lt;br /&gt;
 [12:20]  albertlr Landar: and everyone take their plants with them please.&lt;br /&gt;
 [12:20]  Arielle Popstar: thx  for  the  lesson Fu, it  was  helpfull&lt;br /&gt;
 [12:21]  albertlr Landar: hum looks like a gate to somewhere?&lt;br /&gt;
 [12:21]  Fu Barr: we&amp;#039;re going to script this &amp;#039;portal&amp;#039;&lt;br /&gt;
 [12:21]  Fu Barr: using the light stuff and a bunch of new stuff&lt;br /&gt;
 [12:21]  albertlr Landar: on a hypergrid gate?&lt;br /&gt;
 [12:21]  Fu Barr: you can do that too - yes :)&lt;br /&gt;
 [12:21]  albertlr Landar: or teleport&lt;br /&gt;
 [12:21]  Arielle Popstar: can  one  be  put  for  people  to  copy  and  look through the  script   if  they  come  later?&lt;br /&gt;
 [12:22]  Fu Barr: like albertlr said - don&amp;#039;t forget to delete your Alien Plant :)&lt;br /&gt;
 [12:22]  albertlr Landar: This script and the lessons will be put in the wiki.&lt;br /&gt;
 [12:22]  albertlr Landar: just have to edit and correct it first.&lt;br /&gt;
 [12:22]  Fu Barr: not sure this is the best place to put out the objects...&lt;br /&gt;
 [12:22]  Fu Barr: lets discuss.&lt;br /&gt;
 [12:22]  Jeff Hall: ty Fu and have a good time everyone:)&lt;br /&gt;
 [12:22]  Fu Barr: any questions?&lt;br /&gt;
 [12:23]  Fu Barr: np jeff - thanks for joining us!&lt;br /&gt;
 [12:23]  inanna beaumont: you too Jeff&lt;br /&gt;
 [12:23]  albertlr Landar: I was thinking about a way to maybe put up an iar of the object in the wiki.&lt;br /&gt;
 [12:23]  Arielle Popstar: or maybe  on  wright  plaza/&lt;br /&gt;
 [12:23]  Fu Barr: yeah - maybe&lt;br /&gt;
 [12:23]  albertlr Landar: yea, that could be done also.&lt;br /&gt;
 [12:24]  Fu Barr: maybe we could box it all up into something at the end and we can keep it as a give away on lbsa?&lt;br /&gt;
 [12:24]  albertlr Landar: yea, good idea also.&lt;br /&gt;
 [12:24]  albertlr Landar: we could include the script and lessons and object.&lt;br /&gt;
 [12:24]  Fu Barr: yep&lt;br /&gt;
 [12:24]  Fu Barr: lol ianna didn;t derez her plant&lt;br /&gt;
 [12:24]  albertlr Landar: And number them as they are in the wiki.&lt;br /&gt;
 [12:24]  Fu Barr shakes his head&lt;br /&gt;
 [12:25]  Fu Barr: wiz - what are your thoughts?&lt;br /&gt;
 [12:25]  Fu Barr: hehe he&amp;#039;s off to the loo :)&lt;br /&gt;
 [12:25]  Fu Barr: okay well that&amp;#039;s all from me.&lt;br /&gt;
 [12:25]  Fu Barr: thanks for coming&lt;br /&gt;
 [12:26]  albertlr Landar: well thanks again Fu, enjoyed your presentation.&lt;br /&gt;
 [12:26]  Arielle Popstar: i  will  post the  lesson  on the  forum  after  i clean  up  the  log  a  bit&lt;br /&gt;
 [12:26]  Fu Barr: like i said - i decided to keep it simple this week. next week we&amp;#039;re going to do much more&lt;br /&gt;
 [12:26]  albertlr Landar: well this will be in the wiki Arielle too.&lt;br /&gt;
 [12:27]  albertlr Landar: Thanks Fu&lt;br /&gt;
 [12:27]  Fu Barr: np :)&lt;br /&gt;
 [12:27]  Arielle Popstar: ok,  but  that  might  be  a  bit  before  it is  up  on  it?&lt;br /&gt;
 [12:27]  Fu Barr: right - me go do something else for abit&lt;br /&gt;
 [12:27]  albertlr Landar: no problem.&lt;br /&gt;
 [12:27]  Fu Barr: been at the machine for 700 hours - or so it feels&lt;br /&gt;
 [12:27]  Arielle Popstar: i  just  doing  this  way  so  people  who  come  next  week  have  had  a  chance  to catch  up&lt;br /&gt;
 [12:28]  albertlr Landar: http://wiki.osgrid.org/index.php/Scripting_Tutorial-05&lt;br /&gt;
 [12:28]  albertlr Landar: Here is last weeks lesson&lt;br /&gt;
 [12:28]  Arielle Popstar: ahh  ok\&lt;br /&gt;
 [12:28]  albertlr Landar: http://wiki.osgrid.org/index.php/Main_Page&lt;br /&gt;
 [12:28]  Fu Barr: i dont see much harm in having both up&lt;br /&gt;
 [12:29]  albertlr Landar: And here are the ones from last year too.&lt;br /&gt;
 [12:29]  Fu Barr: some people will gravitate to the wiki, other to the forum&lt;br /&gt;
 [12:29]  albertlr Landar: Under Scripting class logs&lt;br /&gt;
 [12:29]  albertlr Landar: Oh its fine to put it in the forums too.&lt;br /&gt;
 [12:29]  albertlr Landar: Its just they tend to eventually get lost in the forums.&lt;br /&gt;
 [12:29]  Fu Barr: in the end in a perfect world i&amp;#039;d make a bunch of video&amp;#039;s and stick them on youtube&lt;br /&gt;
 [12:29]  Arielle Popstar: well  no  sense  in  both of  us  editing  the  log  so  i  can  wait&lt;br /&gt;
 [12:29]  Fu Barr: but the world ain&amp;#039;t perfect - lol&lt;br /&gt;
 [12:30]  albertlr Landar: Ok well bye all,&lt;br /&gt;
 [12:30]  Fu Barr: okay my job is done here - thanks again and tc all!&lt;br /&gt;
 [12:30]  albertlr Landar: take care.&lt;br /&gt;
 [12:30]  Fu Barr is Offline&lt;br /&gt;
 [12:30]  Arielle Popstar: tc  Fu&lt;/div&gt;</summary>
		<author><name>Osgridadmin</name></author>
	</entry>
</feed>