Scripting Tutorial-05: Difference between revisions
Appearance
Osgridadmin (talk | contribs) No edit summary |
Osgridadmin (talk | contribs) No edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
== Scripting Lessons #5 - Held August 11th, 2018 at Sandbox Plaza by Fu Barr == | |||
[11:35] Fu Barr: okay well i guess we can get started, theres a few of us and that's better than nobody :) | [11:35] Fu Barr: okay well i guess we can get started, theres a few of us and that's better than nobody :) | ||
| Line 365: | Line 367: | ||
[12:15] albertlr Landar: each block is like a room | [12:15] albertlr Landar: each block is like a room | ||
[12:15] Fu Barr: it may well be that there is code in a script that you will NEVER actually RUN | [12:15] Fu Barr: it may well be that there is code in a script that you will NEVER actually RUN | ||
[12:15] albertlr Landar: and you can have rooms inside those too. | [12:15] albertlr Landar: and you can have rooms inside those too. | ||
[12:15] Fu Barr: because the situation that needs that code never happens | [12:15] Fu Barr: because the situation that needs that code never happens | ||
[12:15] Koni Lanzius: ahh | [12:15] Koni Lanzius: ahh | ||
[12:15] Fu Barr: so a block might be used, it might not, it depends on the structure of the code. | [12:15] Fu Barr: so a block might be used, it might not, it depends on the structure of the code. | ||
[12:16] Fu Barr: so when you first read a script.... you have to look for its structure | [12:16] Fu Barr: so when you first read a script.... you have to look for its structure | ||
[12:16] Blue Bird: Like having a cat tree, but not having any cats yet... | [12:16] Blue Bird: Like having a cat tree, but not having any cats yet... | ||
[12:16] Fu Barr: yes, a bit :) | [12:16] Fu Barr: yes, a bit :) | ||
[12:16] Fu Barr: so this script has 3 parst. | [12:16] Fu Barr: so this script has 3 parst. | ||
[12:16] Koni Lanzius: i see | [12:16] Koni Lanzius: i see | ||
[12:16] Fu Barr: *parts | [12:16] Fu Barr: *parts | ||
[12:16] Fu Barr: the first part is called 'default' | [12:16] Fu Barr: the first part is called 'default' | ||
[12:17] Fu Barr: the second part is called 'unlit' | [12:17] Fu Barr: the second part is called 'unlit' | ||
[12:17] albertlr Landar: also too see if a script is correctly structured you can print it out and then connet each block with a line. | [12:17] albertlr Landar: also too see if a script is correctly structured you can print it out and then connet each block with a line. | ||
[12:17] Fu Barr: and the third part is called 'lit' | [12:17] Fu Barr: and the third part is called 'lit' | ||
[12:17] Fu Barr: now who wants to have a go at what these parts actually do? | [12:17] Fu Barr: now who wants to have a go at what these parts actually do? | ||
[12:17] Jeff Hall: it is a good habit to tell general algorithm at top section with comments too for helping other users | [12:17] Jeff Hall: it is a good habit to tell general algorithm at top section with comments too for helping other users | ||
[12:18] Fu Barr: lol - jeff and I have already 'fought' about commenting style before :) | [12:18] Fu Barr: lol - jeff and I have already 'fought' about commenting style before :) | ||
[12:18] Fu Barr: but in this case I agree :) | [12:18] Fu Barr: but in this case I agree :) | ||
[12:18] Arielle Popstar: have we learned what an algorithm is yet? | [12:18] Arielle Popstar: have we learned what an algorithm is yet? | ||
[12:18] Koni Lanzius: resting state, unlit state, lit state | [12:18] Koni Lanzius: resting state, unlit state, lit state | ||
[12:18] Fu Barr: nope that's happening right now | [12:18] Fu Barr: nope that's happening right now | ||
[12:18] Fu Barr: exactly | [12:18] Fu Barr: exactly | ||
[12:18] Arielle Popstar: or too much information at this point? | [12:18] Arielle Popstar: or too much information at this point? | ||
[12:18] Jeff Hall: i will always fight against about having no explanations Fu lol;) | [12:18] Jeff Hall: i will always fight against about having no explanations Fu lol;) | ||
[12:19] Fu Barr: nono - i'm getting to it right now | [12:19] Fu Barr: nono - i'm getting to it right now | ||
[12:19] Fu Barr: so what's this algorithm that is being mentioned. | [12:19] Fu Barr: so what's this algorithm that is being mentioned. | ||
[12:19] Fu Barr: well it's a fancy word for 'recipe' | [12:19] Fu Barr: well it's a fancy word for 'recipe' | ||
[12:19] Fu Barr: how to get stuff done | [12:19] Fu Barr: how to get stuff done | ||
[12:19] Fu Barr: i want a thing to light up when I click a button | [12:19] Fu Barr: i want a thing to light up when I click a button | ||
[12:20] Fu Barr: the algorith would be: | [12:20] Fu Barr: the algorith would be: | ||
[12:20] Fu Barr: 1. wait for click | [12:20] Fu Barr: 1. wait for click | ||
[12:20] Fu Barr: 2. detect click | [12:20] Fu Barr: 2. detect click | ||
[12:20] Fu Barr: 3. switch to the relevant state of lit or unlit | [12:20] Fu Barr: 3. switch to the relevant state of lit or unlit | ||
[12:20] Fu Barr: and this is exactly what happens | [12:20] Fu Barr: and this is exactly what happens | ||
[12:20] Fu Barr: look in the defaults code block - it says: | [12:20] Fu Barr: look in the defaults code block - it says: | ||
[12:21] Arielle Popstar: how does it remember the state of lit or unlit? | [12:21] Arielle Popstar: how does it remember the state of lit or unlit? | ||
[12:21] Fu Barr: when you enter the state, change the state from default to unlit. | [12:21] Fu Barr: when you enter the state, change the state from default to unlit. | ||
[12:21] Fu Barr: one sec Arielle - that's the next bit :) | [12:21] Fu Barr: one sec Arielle - that's the next bit :) | ||
[12:21] Arielle Popstar: ok :)\ | [12:21] Arielle Popstar: ok :)\ | ||
[12:22] Fu Barr: does every body see that in the default state it waits for state_entry and then sends the script to state unlit? | [12:22] Fu Barr: does every body see that in the default state it waits for state_entry and then sends the script to state unlit? | ||
[12:22] Kawaii Unicorn: yes | [12:22] Kawaii Unicorn: yes | ||
[12:22] Arielle Popstar: hazily | [12:22] Arielle Popstar: hazily | ||
[12:22] Arielle Popstar: sort of browned out atm | [12:22] Arielle Popstar: sort of browned out atm | ||
[12:22] Fu Barr: forget about the exact meaning of the code, there's details i'm leaving out, but whats important is the FLOW of the script | [12:22] Fu Barr: forget about the exact meaning of the code, there's details i'm leaving out, but whats important is the FLOW of the script | ||
[12:22] Fu Barr: ok. | [12:22] Fu Barr: ok. | ||
[12:23] Kawaii Unicorn: ok | [12:23] Kawaii Unicorn: ok | ||
[12:23] Fu Barr: let's do this slowly and i'll back up | [12:23] Fu Barr: let's do this slowly and i'll back up | ||
[12:23] Kawaii Unicorn: ok | [12:23] Kawaii Unicorn: ok | ||
[12:23] Fu Barr: dont want peple to get lost | [12:23] Fu Barr: dont want peple to get lost | ||
[12:23] Kawaii Unicorn: ty | [12:23] Kawaii Unicorn: ty | ||
[12:23] Boomslang Mamba: yeah man | [12:23] Boomslang Mamba: yeah man | ||
[12:23] Fu Barr: so arielle asked - how does the script know where it is | [12:23] Fu Barr: so arielle asked - how does the script know where it is | ||
[12:24] Fu Barr: well, the script has a 'life cycle' | [12:24] Fu Barr: well, the script has a 'life cycle' | ||
[12:24] Fu Barr: a scripts starts, loops for a while as long as it is needed, then it ends. and goes away | [12:24] Fu Barr: a scripts starts, loops for a while as long as it is needed, then it ends. and goes away | ||
[12:24] Fu Barr: start, do stuff, go away | [12:24] Fu Barr: start, do stuff, go away | ||
[12:24] Boomslang Mamba: yeah man | [12:24] Boomslang Mamba: yeah man | ||
[12:25] Koni Lanzius: but the lit state is the final state, is that correct? | [12:25] Koni Lanzius: but the lit state is the final state, is that correct? | ||
[12:25] Fu Barr: now this cycle moves through what OpenSim calls 'states' | [12:25] Fu Barr: now this cycle moves through what OpenSim calls 'states' | ||
[12:25] Jeff Hall: well the script is always listening for event too no Fu? | [12:25] Jeff Hall: well the script is always listening for event too no Fu? | ||
[12:25] Fu Barr: yeah - events is my next comment - but yes you're right :) | [12:25] Fu Barr: yeah - events is my next comment - but yes you're right :) | ||
[12:25] Fu Barr: so as the scripts moves through the states.... | [12:25] Fu Barr: so as the scripts moves through the states.... | ||
[12:25] Fu Barr: it experiences stuff. | [12:25] Fu Barr: it experiences stuff. | ||
[12:25] paela argus: script said per default offline and in end open if you not click again its not turned off | [12:25] paela argus: script said per default offline and in end open if you not click again its not turned off | ||
[12:26] Fu Barr: like people or avatars | [12:26] Fu Barr: like people or avatars | ||
[12:26] Fu Barr: i log on and go to lbsa, chat a bit, tp to someplace, then logoff. | [12:26] Fu Barr: i log on and go to lbsa, chat a bit, tp to someplace, then logoff. | ||
[12:26] Fu Barr: it's a sequence. | [12:26] Fu Barr: it's a sequence. | ||
[12:27] Fu Barr: now scripts tend to loop, forever till they are witched off... so koni | [12:27] Fu Barr: now scripts tend to loop, forever till they are witched off... so koni | ||
[12:27] Fu Barr: you said 'lit' was the end state | [12:27] Fu Barr: you said 'lit' was the end state | ||
[12:27] Koni Lanzius: yea? | [12:27] Koni Lanzius: yea? | ||
[12:27] Fu Barr: ein a way it's true | [12:27] Fu Barr: ein a way it's true | ||
[12:27] Fu Barr: but it's really just another intermediate step | [12:27] Fu Barr: but it's really just another intermediate step | ||
[12:27] Koni Lanzius: huh. | [12:27] Koni Lanzius: huh. | ||
[12:27] Fu Barr: if i click the button in the lit state it goes to the unlit state, | [12:27] Fu Barr: if i click the button in the lit state it goes to the unlit state, | ||
[12:28] Fu Barr: and vice versa | [12:28] Fu Barr: and vice versa | ||
[12:28] Fu Barr: on and on | [12:28] Fu Barr: on and on | ||
[12:28] Fu Barr: so there's actually no end to the CYCLE. | [12:28] Fu Barr: so there's actually no end to the CYCLE. | ||
[12:28] Koni Lanzius: ahhh | [12:28] Koni Lanzius: ahhh | ||
[12:28] Fu Barr: the states come to an end, but the lifecycle of the whole script (in this case) is an endless loop | [12:28] Fu Barr: the states come to an end, but the lifecycle of the whole script (in this case) is an endless loop | ||
[12:28] Koni Lanzius: i see | [12:28] Koni Lanzius: i see | ||
[12:29] Fu Barr: when I start the script it goes automatically to 'default'. | [12:29] Fu Barr: when I start the script it goes automatically to 'default'. | ||
[12:29] Fu Barr: that's just how it is, a rule in scripting. | [12:29] Fu Barr: that's just how it is, a rule in scripting. | ||
[12:29] Jeff Hall: it will wait for click event non stop | [12:29] Jeff Hall: it will wait for click event non stop | ||
[12:29] Koni Lanzius: i see | [12:29] Koni Lanzius: i see | ||
[12:29] Arielle Popstar: so the switch itself does not remember whether it is lit or unlit state but just acts as a toggle? | [12:29] Arielle Popstar: so the switch itself does not remember whether it is lit or unlit state but just acts as a toggle? | ||
[12:29] Fu Barr: then I the scripter decided that I wanted to switch the script to the unlit state | [12:29] Fu Barr: then I the scripter decided that I wanted to switch the script to the unlit state | ||
[12:29] Arielle Popstar: the default state does not = lit or unlit? | [12:29] Arielle Popstar: the default state does not = lit or unlit? | ||
[12:29] Fu Barr: no arielle - it's the EXACT opposite | [12:29] Fu Barr: no arielle - it's the EXACT opposite | ||
[12:30] Fu Barr: the only thing a script knows is in which state it is | [12:30] Fu Barr: the only thing a script knows is in which state it is | ||
[12:30] Fu Barr: when a script starts it automatically goes to defaut | [12:30] Fu Barr: when a script starts it automatically goes to defaut | ||
[12:30] Fu Barr: it just does | [12:30] Fu Barr: it just does | ||
[12:30] Fu Barr: then I the scripter force it to go to state 'unlit' | [12:30] Fu Barr: then I the scripter force it to go to state 'unlit' | ||
[12:31] Arielle Popstar: so the state entry is unlit | [12:31] Arielle Popstar: so the state entry is unlit | ||
[12:31] Arielle Popstar: ok | [12:31] Arielle Popstar: ok | ||
[12:31] Fu Barr: in the unlit state... i wait for something to happen.... if that something is a touch on the button.... I force the script to move to state 'lit' | [12:31] Fu Barr: in the unlit state... i wait for something to happen.... if that something is a touch on the button.... I force the script to move to state 'lit' | ||
[12:31] Fu Barr: the script drags it arse into the lit state. | [12:31] Fu Barr: the script drags it arse into the lit state. | ||
[12:31] Koni Lanzius: hehe | [12:31] Koni Lanzius: hehe | ||
[12:31] Fu Barr: then it sits and waits for he next thing to happen | [12:31] Fu Barr: then it sits and waits for he next thing to happen | ||
[12:32] Fu Barr: if it's a click on the button... | [12:32] Fu Barr: if it's a click on the button... | ||
[12:32] Jeff Hall: event programming | [12:32] Jeff Hall: event programming | ||
[12:32] Fu Barr: it moves back into the state 'unlit' | [12:32] Fu Barr: it moves back into the state 'unlit' | ||
[12:32] Fu Barr: yep jeff has the formal term right there. | [12:32] Fu Barr: yep jeff has the formal term right there. | ||
[12:32] Fu Barr: you make the script react to 'events' | [12:32] Fu Barr: you make the script react to 'events' | ||
[12:33] Blue Bird: What if you turn it on and your sim resets while it's "on"? | [12:33] Blue Bird: What if you turn it on and your sim resets while it's "on"? | ||
[12:33] Fu Barr: the event being script started, or button got pressed, or something was heard | [12:33] Fu Barr: the event being script started, or button got pressed, or something was heard | ||
[12:33] Fu Barr: it goes back to the starting point - ie. the default state | [12:33] Fu Barr: it goes back to the starting point - ie. the default state | ||
[12:33] Blue Bird: ohh | [12:33] Blue Bird: ohh | ||
[12:33] Fu Barr: scripts always start in default | [12:33] Fu Barr: scripts always start in default | ||
[12:33] Fu Barr: some scripters who dont really understand the power of states, they stick all their code in the defaults state... | [12:33] Fu Barr: some scripters who dont really understand the power of states, they stick all their code in the defaults state... | ||
[12:34] Blue Bird: yea, that would be me | [12:34] Blue Bird: yea, that would be me | ||
[12:34] Fu Barr: it's a nightmare to work with or change/improve their code | [12:34] Fu Barr: it's a nightmare to work with or change/improve their code | ||
[12:34] Koni Lanzius: thats like a header in writing? | [12:34] Koni Lanzius: thats like a header in writing? | ||
[12:34] Fu Barr: best to throw it all out and start fresh | [12:34] Fu Barr: best to throw it all out and start fresh | ||
[12:34] Fu Barr: well, it's how you decide to write, its more about coding style. | [12:34] Fu Barr: well, it's how you decide to write, its more about coding style. | ||
[12:35] Koni Lanzius: kk | [12:35] Koni Lanzius: kk | ||
[12:35] Fu Barr: i use the default state to set the stage for my scripts. | [12:35] Fu Barr: i use the default state to set the stage for my scripts. | ||
[12:35] Koni Lanzius: kk | [12:35] Koni Lanzius: kk | ||
[12:35] Fu Barr: then I move though the stages I need to deal with various events that might occur | [12:35] Fu Barr: then I move though the stages I need to deal with various events that might occur | ||
[12:35] Fu Barr: moving the script into stag X or Y as I see fit | [12:35] Fu Barr: moving the script into stag X or Y as I see fit | ||
[12:36] Fu Barr: manipulating the life cycle of the script | [12:36] Fu Barr: manipulating the life cycle of the script | ||
[12:36] Koni Lanzius: spacing is important too, isnt it? | [12:36] Koni Lanzius: spacing is important too, isnt it? | ||
[12:36] Fu Barr: if you read this script again quietly you'll see it clearly i'm sure | [12:36] Fu Barr: if you read this script again quietly you'll see it clearly i'm sure | ||
[12:36] Fu Barr: just for humans | [12:36] Fu Barr: just for humans | ||
[12:36] Koni Lanzius: extra spaces can kill a script? | [12:36] Koni Lanzius: extra spaces can kill a script? | ||
[12:36] Fu Barr: the script engine only cares about brackets and semi-colons | [12:36] Fu Barr: the script engine only cares about brackets and semi-colons | ||
[12:36] Koni Lanzius: no? | [12:36] Koni Lanzius: no? | ||
[12:37] Koni Lanzius: ohhh | [12:37] Koni Lanzius: ohhh | ||
[12:37] Koni Lanzius: guess thats just true in command line stuff | [12:37] Koni Lanzius: guess thats just true in command line stuff | ||
[12:37] Arielle Popstar: spaces break compiling though? | [12:37] Arielle Popstar: spaces break compiling though? | ||
[12:37] paela argus: well you can type script in km koni =) | [12:37] paela argus: well you can type script in km koni =) | ||
[12:37] Koni Lanzius: wut is km? | [12:37] Koni Lanzius: wut is km? | ||
[12:37] albertlr Landar: I have a question about the viewer editor. | [12:37] albertlr Landar: I have a question about the viewer editor. | ||
[12:37] Fu Barr: now i just want to spend the last few minutes about some of the othe code inside the state | [12:37] Fu Barr: now i just want to spend the last few minutes about some of the othe code inside the state | ||
[12:37] Fu Barr: shoot albertlr | [12:37] Fu Barr: shoot albertlr | ||
[12:37] paela argus: in one line but is just unreadable for human | [12:37] paela argus: in one line but is just unreadable for human | ||
[12:38] albertlr Landar: It says Edit at the bottom, and apparently that is for external editor how does one set that up in the viewer. | [12:38] albertlr Landar: It says Edit at the bottom, and apparently that is for external editor how does one set that up in the viewer. | ||
[12:38] Koni Lanzius: ahh | [12:38] Koni Lanzius: ahh | ||
[12:38] Fu Barr: i dont know - it varies per viewer in singu - which is what I use - i dont have that button | [12:38] Fu Barr: i dont know - it varies per viewer in singu - which is what I use - i dont have that button | ||
[12:38] albertlr Landar: hum my singularity has it. | [12:38] albertlr Landar: hum my singularity has it. | ||
[12:38] Fu Barr: i do all my scripting in the viewer editor - it works fine for me | [12:38] Fu Barr: i do all my scripting in the viewer editor - it works fine for me | ||
[12:39] Arielle Popstar: seems to want to open an extertnal app when clicking edit | [12:39] Arielle Popstar: seems to want to open an extertnal app when clicking edit | ||
[12:39] albertlr Landar: The reason I mention it is the lsleditor program now supports the ossl functions too. | [12:39] albertlr Landar: The reason I mention it is the lsleditor program now supports the ossl functions too. | ||
[12:39] Fu Barr: oh that edit - i never use that button - like I say i edit all my scripts in the viewer editor | [12:39] Fu Barr: oh that edit - i never use that button - like I say i edit all my scripts in the viewer editor | ||
[12:39] albertlr Landar: its set up somewhere in the advanced but not sure where. | [12:39] albertlr Landar: its set up somewhere in the advanced but not sure where. | ||
[12:39] Koni Lanzius: when i click the edit button it says "Complie successful! save complere" | [12:39] Koni Lanzius: when i click the edit button it says "Complie successful! save complere" | ||
[12:39] albertlr Landar: https://sourceforge.net/projects/lsleditor/ | [12:39] albertlr Landar: https://sourceforge.net/projects/lsleditor/ | ||
[12:39] Fu Barr: i never use the functions code completion stuff. I code from knowledge and use the various wiki pages all the time. | [12:39] Fu Barr: i never use the functions code completion stuff. I code from knowledge and use the various wiki pages all the time. | ||
[12:39] Arielle Popstar: so maybe point it at an installed lsleditor? | [12:39] Arielle Popstar: so maybe point it at an installed lsleditor? | ||
[12:40] albertlr Landar: That is the exteral editor for those that don't have it. | [12:40] albertlr Landar: That is the exteral editor for those that don't have it. | ||
[12:40] Fu Barr: yeah - i never use it. but that a distraction now - lets finish looking at the code. | [12:40] Fu Barr: yeah - i never use it. but that a distraction now - lets finish looking at the code. | ||
[12:40] albertlr Landar: The only reason I don't like the viewer one is it is so small. | [12:40] albertlr Landar: The only reason I don't like the viewer one is it is so small. | ||
[12:40] Koni Lanzius: k | [12:40] Koni Lanzius: k | ||
[12:40] Fu Barr: so small? | [12:40] Fu Barr: so small? | ||
[12:40] paela argus: good scripter doesnt need external editor internal editor of viewer i just perfect for typing a lsl code | [12:40] paela argus: good scripter doesnt need external editor internal editor of viewer i just perfect for typing a lsl code | ||
[12:40] paela argus: =) | [12:40] paela argus: =) | ||
[12:41] paela argus: is* | [12:41] paela argus: is* | ||
[12:41] Koni Lanzius: :) | [12:41] Koni Lanzius: :) | ||
[12:41] albertlr Landar: ok | [12:41] albertlr Landar: ok | ||
[12:41] Fu Barr: you can change the editor font size. | [12:41] Fu Barr: you can change the editor font size. | ||
[12:41] Arielle Popstar: ok so use it till i am good scripter? :) | [12:41] Arielle Popstar: ok so use it till i am good scripter? :) | ||
[12:41] albertlr Landar: oh you can | [12:41] albertlr Landar: oh you can | ||
[12:41] Fu Barr: but thats not for now. sorry :) | [12:41] Fu Barr: but thats not for now. sorry :) | ||
[12:41] Arielle Popstar: 10 years or so | [12:41] Arielle Popstar: 10 years or so | ||
[12:41] albertlr Landar: ok later. | [12:41] albertlr Landar: ok later. | ||
[12:41] Fu Barr: okay so final thing. | [12:41] Fu Barr: okay so final thing. | ||
[12:41] Fu Barr: lets look at the unlit state | [12:41] Fu Barr: lets look at the unlit state | ||
[12:41] Fu Barr: first let's find the blocks | [12:41] Fu Barr: first let's find the blocks | ||
[12:42] Toggle boxes: state: lit | [12:42] Toggle boxes: state: lit | ||
[12:42] Fu Barr: then lets see what those blocks are | [12:42] Fu Barr: then lets see what those blocks are | ||
[12:42] Toggle boxes: state: unlit | [12:42] Toggle boxes: state: unlit | ||
[12:42] Fu Barr: blocks as we now know live in between brackets | [12:42] Fu Barr: blocks as we now know live in between brackets | ||
[12:42] Fu Barr: so we have two main blocks in this state | [12:42] Fu Barr: so we have two main blocks in this state | ||
[12:42] Fu Barr: the first block is labelled state_entry() | [12:42] Fu Barr: the first block is labelled state_entry() | ||
[12:42] Fu Barr: the second block is labelled touch_end | [12:42] Fu Barr: the second block is labelled touch_end | ||
[12:43] Fu Barr: can you guys see that? | [12:43] Fu Barr: can you guys see that? | ||
[12:43] Koni Lanzius: yes | [12:43] Koni Lanzius: yes | ||
[12:43] Fu Barr: inside those blocks there are more blocks... | [12:43] Fu Barr: inside those blocks there are more blocks... | ||
[12:43] Fu Barr: liek we said.. russian dolls | [12:43] Fu Barr: liek we said.. russian dolls | ||
[12:43] Fu Barr: in the state_entry block there are 3 seperate bits | [12:43] Fu Barr: in the state_entry block there are 3 seperate bits | ||
[12:44] Fu Barr: if(DEBUG) | [12:44] Fu Barr: if(DEBUG) | ||
[12:44] Fu Barr: and 2x llSetPrimitiveBlaBLabLa | [12:44] Fu Barr: and 2x llSetPrimitiveBlaBLabLa | ||
[12:44] Koni Lanzius: right | [12:44] Koni Lanzius: right | ||
[12:44] Fu Barr: only the if(DEBUG) has BRACKETS | [12:44] Fu Barr: only the if(DEBUG) has BRACKETS | ||
[12:44] Fu Barr: so only the if(DEBUG) is a block | [12:44] Fu Barr: so only the if(DEBUG) is a block | ||
[12:45] Fu Barr: the other two are just 'commands' | [12:45] Fu Barr: the other two are just 'commands' | ||
[12:45] Fu Barr: but most commands need relevant information to work properly and all the () and [] and all that is to help structure the info the command needs | [12:45] Fu Barr: but most commands need relevant information to work properly and all the () and [] and all that is to help structure the info the command needs | ||
[12:46] Fu Barr: i've used a lot of white space here to make it all look a little neater | [12:46] Fu Barr: i've used a lot of white space here to make it all look a little neater | ||
[12:46] Fu Barr: but just to finish... | [12:46] Fu Barr: but just to finish... | ||
[12:46] Fu Barr: if i want to make the prim 'light up'... I can set all the sides to FULL_BRIGHT | [12:46] Fu Barr: if i want to make the prim 'light up'... I can set all the sides to FULL_BRIGHT | ||
[12:46] Fu Barr: is i want to turn the light off.... | [12:46] Fu Barr: is i want to turn the light off.... | ||
[12:47] Fu Barr: well i need to set FULL_BRIGHT to FALSE... | [12:47] Fu Barr: well i need to set FULL_BRIGHT to FALSE... | ||
[12:47] Fu Barr: now look at the code | [12:47] Fu Barr: now look at the code | ||
[12:47] Fu Barr: it's EXACTLY what is happening | [12:47] Fu Barr: it's EXACTLY what is happening | ||
[12:47] Fu Barr: i'm telling the script... | [12:47] Fu Barr: i'm telling the script... | ||
[12:48] Toggle boxes: state: unlit | [12:48] Toggle boxes: state: unlit | ||
[12:48] Fu Barr: find the linked prim which is the bulb prim (LAMP_PRIM =3) and set the prim value to something relevant | [12:48] Fu Barr: find the linked prim which is the bulb prim (LAMP_PRIM =3) and set the prim value to something relevant | ||
[12:48] Fu Barr: if you look at the link set of these prims | [12:48] Fu Barr: if you look at the link set of these prims | ||
[12:48] Fu Barr: you'll see that the prim that acta as a bulb is 3rd in the linkset | [12:48] Fu Barr: you'll see that the prim that acta as a bulb is 3rd in the linkset | ||
[12:49] Fu Barr: green cylinder = 1 | [12:49] Fu Barr: green cylinder = 1 | ||
[12:49] Fu Barr: the brown thing= 2 | [12:49] Fu Barr: the brown thing= 2 | ||
[12:49] Fu Barr: and the white one is 3 | [12:49] Fu Barr: and the white one is 3 | ||
[12:49] Fu Barr: so what this script does... | [12:49] Fu Barr: so what this script does... | ||
[12:49] Fu Barr: is | [12:49] Fu Barr: is | ||
[12:49] Fu Barr: cycle through lit/unlit states | [12:49] Fu Barr: cycle through lit/unlit states | ||
[12:49] Toggle boxes: state: unlit | [12:49] Toggle boxes: state: unlit | ||
[12:50] Fu Barr: and in each state set the relevant FULL_BRIGHT value on the 3rd prim | [12:50] Fu Barr: and in each state set the relevant FULL_BRIGHT value on the 3rd prim | ||
[12:50] Fu Barr: that's it | [12:50] Fu Barr: that's it | ||
[12:50] Fu Barr: nothing else | [12:50] Fu Barr: nothing else | ||
[12:50] Fu Barr: it just looks al ittle complicated but conceptually it's very simple | [12:50] Fu Barr: it just looks al ittle complicated but conceptually it's very simple | ||
[12:50] Koni Lanzius: ahh | [12:50] Koni Lanzius: ahh | ||
[12:51] Fu Barr: if i move into lit, set fullbright, if i moveinto unlit, urn fullbright off | [12:51] Fu Barr: if i move into lit, set fullbright, if i moveinto unlit, urn fullbright off | ||
[12:51] Fu Barr: and all i do is 'wait' for a touch event | [12:51] Fu Barr: and all i do is 'wait' for a touch event | ||
[12:51] Fu Barr: read the script again carefully and it'll be quite clear now that you understand the concept of script life cycle and states and 'brackets' | [12:51] Fu Barr: read the script again carefully and it'll be quite clear now that you understand the concept of script life cycle and states and 'brackets' | ||
[12:52] Koni Lanzius: on line 40, what is that number/letter series | [12:52] Koni Lanzius: on line 40, what is that number/letter series | ||
[12:52] Fu Barr: ah | [12:52] Fu Barr: ah | ||
[12:52] Fu Barr: that is the UUID of the 'blank texture' | [12:52] Fu Barr: that is the UUID of the 'blank texture' | ||
[12:52] Koni Lanzius: i see | [12:52] Koni Lanzius: i see | ||
[12:52] Fu Barr: everything in opensim/OSgrid has a unique number | [12:52] Fu Barr: everything in opensim/OSgrid has a unique number | ||
[12:52] paela argus: set texture on all face primitive :) | [12:52] paela argus: set texture on all face primitive :) | ||
[12:52] Koni Lanzius: i see | [12:52] Koni Lanzius: i see | ||
[12:52] Fu Barr: here I use that number to force the texture on the bulb prim to be pure white | [12:52] Fu Barr: here I use that number to force the texture on the bulb prim to be pure white | ||
[12:53] Jeff Hall: i have a question | [12:53] Jeff Hall: i have a question | ||
[12:53] Fu Barr: I'm setting TWO parametrs on the pri. 1. full bright, 2. the blank texture | [12:53] Fu Barr: I'm setting TWO parametrs on the pri. 1. full bright, 2. the blank texture | ||
[12:53] Fu Barr: sure jeff - | [12:53] Fu Barr: sure jeff - | ||
[12:53] Koni Lanzius: i see | [12:53] Koni Lanzius: i see | ||
[12:54] Fu Barr: btw. the SecondLife LSL wiki is ESSENTIAL | [12:54] Fu Barr: btw. the SecondLife LSL wiki is ESSENTIAL | ||
[12:54] Fu Barr: you cannot script without the LSL Wiki and the OSSL wiki | [12:54] Fu Barr: you cannot script without the LSL Wiki and the OSSL wiki | ||
[12:54] Arielle Popstar: i am still not getting how the script knows whether to use the lit or unlit block codes of script to toggle the light on or off depending on its present state. Seems to me it would just run the last bit of code to turn an allready on light to continue in the on state | [12:54] Arielle Popstar: i am still not getting how the script knows whether to use the lit or unlit block codes of script to toggle the light on or off | ||
[12:54] Jeff Hall: why do u have a state_entry embedded in state unlit since its allready called in default / state_entry? | depending on its present state. Seems to me it would just run the last bit of code to turn an allready on light to continue in the on state | ||
[12:54] Fu Barr: that's where all the info is of how to use the various functions | [12:54] Jeff Hall: why do u have a state_entry embedded in state unlit since its allready called in default / state_entry? | ||
[12:55] paela argus: http://wiki.osgrid.org/index.php/LSL_Functions | [12:54] Fu Barr: that's where all the info is of how to use the various functions | ||
[12:55] Fu Barr: jeff - because i need to turn off the light :) | [12:55] paela argus: http://wiki.osgrid.org/index.php/LSL_Functions | ||
[12:55] Fu Barr: one state turns it on | [12:55] Fu Barr: jeff - because i need to turn off the light :) | ||
[12:55] Fu Barr: the other off | [12:55] Fu Barr: one state turns it on | ||
[12:55] Fu Barr: i do that in the state_entry event of the relevant state | [12:55] Fu Barr: the other off | ||
[12:55] Fu Barr: arielle - | [12:55] Fu Barr: i do that in the state_entry event of the relevant state | ||
[12:55] Fu Barr: the script doesnt keep running | [12:55] Fu Barr: arielle - | ||
[12:56] Jeff Hall: u could remove the state_entry in state unlit and just make it turn off | [12:55] Fu Barr: the script doesnt keep running | ||
[12:56] Fu Barr: from state to state | [12:56] Jeff Hall: u could remove the state_entry in state unlit and just make it turn off | ||
[12:56] Fu Barr: it stays in one state untill you the scripter force it into another state | [12:56] Fu Barr: from state to state | ||
[12:56] Fu Barr: no you can't remove the state_entry - because the script engine always expect to see a state_entry block :) | [12:56] Fu Barr: it stays in one state untill you the scripter force it into another state | ||
[12:57] paela argus: there are several ways to do it, let's stay on the one of fu's or everybody will lose it | [12:56] Fu Barr: no you can't remove the state_entry - because the script engine always expect to see a state_entry block :) | ||
[12:57] Fu Barr: each state needs at least state_entry. otherwise it flags a vacant error | [12:57] paela argus: there are several ways to do it, let's stay on the one of fu's or everybody will lose it | ||
[12:57] Fu Barr: yeah - many ways to skin a cat. | [12:57] Fu Barr: each state needs at least state_entry. otherwise it flags a vacant error | ||
[12:57] Fu Barr: i chose this one because I felt it was the most 'clear' way to do it | [12:57] Fu Barr: yeah - many ways to skin a cat. | ||
[12:57] Jeff Hall: sorry, i just didnt think that way | [12:57] Fu Barr: i chose this one because I felt it was the most 'clear' way to do it | ||
[12:58] paela argus: yup | [12:57] Jeff Hall: sorry, i just didnt think that way | ||
[12:58] Fu Barr: jeff - you cannot not have a state_entry in a stte. | [12:58] paela argus: yup | ||
[12:58] Fu Barr: the script engine will flag an error | [12:58] Fu Barr: jeff - you cannot not have a state_entry in a stte. | ||
[12:59] Arielle Popstar: i am thinking of an ini file where the last entry of a variable is used no matter how many times it has a different variable for a certain thing, before that | [12:58] Fu Barr: the script engine will flag an error | ||
[12:59] Fu Barr: anyhow - thats it for this evening. i hope it wasn't too overwhelming and dont be embarassed to reach out to me in IM or here in chat with questions. Happy to help and go over things a million times | [12:59] Arielle Popstar: i am thinking of an ini file where the last entry of a variable is used no matter how many times it has a different variable for a | ||
[12:59] Jeff Hall: ty Fu | certain thing, before that | ||
[12:59] Koni Lanzius: was brilliant, thank you Fu!! | [12:59] Fu Barr: anyhow - thats it for this evening. i hope it wasn't too overwhelming and dont be embarassed to reach out to me in IM or here in chat with questions. Happy to | ||
[12:59] Koni Lanzius: ~** APPLAUSE **~ | help and go over things a million times | ||
[12:59] albertlr Landar: Well thanks for the lessons Fu Barr. | [12:59] Jeff Hall: ty Fu | ||
[12:59] Koni Lanzius: ~**YAY!!!!**~ | [12:59] Koni Lanzius: was brilliant, thank you Fu!! | ||
[13:00] Blue Bird: Thank you FU, you have helped a lot! | [12:59] Koni Lanzius: ~** APPLAUSE **~ | ||
[13:00] Fu Barr: i do suggest you just carefully read the script | [12:59] albertlr Landar: Well thanks for the lessons Fu Barr. | ||
[13:00] paela argus: meow meow | [12:59] Koni Lanzius: ~**YAY!!!!**~ | ||
[13:00] albertlr Landar: Also I solved my external editor question. | [13:00] Blue Bird: Thank you FU, you have helped a lot! | ||
[13:00] Fu Barr: so i guess we'll do another one next week? | [13:00] Fu Barr: i do suggest you just carefully read the script | ||
[13:00] Koni Lanzius: awesomes! | [13:00] paela argus: meow meow | ||
[13:00] paela argus: please clear stuff before leave peoples :) | [13:00] albertlr Landar: Also I solved my external editor question. | ||
[13:00] Koni Lanzius: yea really helped | [13:00] Fu Barr: so i guess we'll do another one next week? | ||
[13:00] Fu Barr: bring a friend etc. spread the word | [13:00] Koni Lanzius: awesomes! | ||
[13:00] Fu Barr: all of that jazz | [13:00] paela argus: please clear stuff before leave peoples :) | ||
[13:00] Koni Lanzius: kk | [13:00] Koni Lanzius: yea really helped | ||
[13:00] albertlr Landar: In Singularity its under Advanced and | [13:00] Fu Barr: bring a friend etc. spread the word | ||
[13:00] Koni Lanzius: bye for now | [13:00] Fu Barr: all of that jazz | ||
[13:00] Fu Barr: don't forget to clean up your prims | [13:00] Koni Lanzius: kk | ||
[13:01] Jeff Hall: ty Fu and see u soon | [13:00] albertlr Landar: In Singularity its under Advanced and Debug settings. Then you enter ExternalEditor and it allows you put in the link. | ||
[13:01] Fu Barr: thanks for coming and joining in all! | [13:00] Koni Lanzius: bye for now | ||
[13:00] Fu Barr: don't forget to clean up your prims | |||
[13:01] Jeff Hall: ty Fu and see u soon | |||
[13:01] Fu Barr: thanks for coming and joining in all! | |||
Latest revision as of 17:58, 24 August 2018
Scripting Lessons #5 - Held August 11th, 2018 at Sandbox Plaza by Fu Barr
[11:35] Fu Barr: okay well i guess we can get started, theres a few of us and that's better than nobody :) [11:36] Fu Barr: hey kawaii :) [11:36] Arcavius Stone: hiya, sis.. :) [11:36] paela argus: hi k [11:36] Kawaii Unicorn: fU! [11:37] Fu Barr: i'm going to rez a few primses in a minute [11:37] Fu Barr: they are very super most highly simple [11:37] Fu Barr: nothing spactacular [11:37] Kawaii Unicorn: HI BRO [11:37] Arielle Popstar: oh thought that said princesses [11:37] Fu Barr: then, if you please please take a copy of the prims and rez them for yourself [11:37] Koni Lanzius: there is a chair Paela [11:38] Fu Barr: click the button and see what it does. [11:38] Kawaii Unicorn: WHERE [11:38] Fu Barr: the 'lesson' will be about understanding what the script does to make the thing work. [11:38] Fu Barr: there [11:38] DJ Higher: lol [11:38] Boomslang Mamba: hO ALL [11:38] Kawaii Unicorn: HO [11:38] Boomslang Mamba: Hi [11:38] Fu Barr: 2 boxes and a cylinder - linked [11:38] Fu Barr: DO NOT UNLINK [11:38] Boomslang Mamba: hi kawaii hugg [11:39] Kawaii Unicorn: tf [11:39] Fu Barr: just rez and press the green cylinder a few times [11:39] Fu Barr: TAKE a copy and click on your OWN copy :) [11:39] Fu Barr: you do all know how to steal stuff? [11:39] Mirror Amorasi is Offline [11:39] Fu Barr: *grin* [11:39] Arielle Popstar: never [11:39] Fu Barr: right click and 'take' [11:39] Kawaii Unicorn: yea yea.. [11:40] Arielle Popstar: have to get another viewer [11:40] Arcavius Stone: not allowing me to take a copy [11:40] Fu Barr: huh? [11:40] Fu Barr: i set it full perm [11:40] Arielle Popstar: bought [11:40] paela argus: u need use boolean allow take a copy :) [11:40] Fu Barr: try again [11:41] Fu Barr whispers: yay! [11:41] stiofain mactomais is Offline [11:41] Kawaii Unicorn: nce chair lol [11:41] Fu Barr: okay everybody get a copy and try it out. it's a very simple light switch [11:41] Kawaii Unicorn: ty :) [11:41] Arcavius Stone: strange... I still can't get a copy of it [11:42] Kawaii Unicorn: buy it arc [11:42] Koni Lanzius: gotta buy it [11:42] Fu Barr: if you press the green cylinder - it switches on/off [11:42] Boomslang Mamba: got it [11:43] Fu Barr: now it's stupid it's a pointless thing - but it will serve to explain some very important programing in LSL basics [11:43] Koni Lanzius: nods [11:43] Fu Barr: first thing we'll learn is - where do scripts live. [11:44] Fu Barr: so - everybody please select the boxes in build mode, and go to the 'contents' tab... [11:44] Fu Barr: you'll find the script that it's running in there. [11:44] Boomslang Mamba: ty for chair [11:44] Fu Barr: please open the script by 2x clicking on it. [11:44] Kawaii Unicorn: w [11:44] Kawaii Unicorn: yw [11:44] Kawaii Unicorn: :) [11:44] Boomslang Mamba: hugg [11:45] Fu Barr: i'll wait a minute for everybody to find the script [11:45] Arcavius Stone: ah, nice [11:45] Fu Barr: 60... [11:45] Fu Barr: 59... [11:45] Fu Barr: 58... [11:45] Fu Barr: 57... [11:45] Fu Barr: 56... [11:45] Fu Barr: 55... [11:45] Koni Lanzius: ~** HAHAHA! **~ [11:45] Fu Barr: :) [11:45] paela argus: 0 [11:45] paela argus: -20 [11:45] Fu Barr: who DOESNT have the script open yet? Fu's basic light switch:
<source lang="lsl">
v0.1 - basic on/off toggle
/*
Fu's basic light switch
v0.1 - basic on/off toggle
- /
integer DEBUG = TRUE;
integer LINK_LAMP = 3; // named like this to match LSL's LINK_ROOT constant used below
default {
state_entry() {
state unlit; }
}
state unlit {
state_entry() {
if(DEBUG){ llOwnerSay("state: unlit"); }
llSetLinkPrimitiveParamsFast(LINK_ROOT,
[ PRIM_FULLBRIGHT, ALL_SIDES, FALSE ]
);
llSetLinkPrimitiveParamsFast(LINK_LAMP,
// the UUID here is the OSgrid specific one for 'Blank Texture'
[ PRIM_FULLBRIGHT, ALL_SIDES, FALSE,
PRIM_TEXTURE, ALL_SIDES, "5748decc-f629-461c-9a36-a35a221fe21f", <1,1,0>, <0,0,0>, 0 ]
);
}
touch_end(integer num_touches) {
if(llDetectedLinkNumber(0) == LINK_ROOT) {
state lit;
}
}
}
state lit {
state_entry() {
if(DEBUG){ llOwnerSay("state: lit"); }
llSetLinkPrimitiveParamsFast(LINK_ROOT,
[ PRIM_FULLBRIGHT, ALL_SIDES, TRUE ]
);
llSetLinkPrimitiveParamsFast(LINK_LAMP,
// like in the 'unlit' state, the UUID here is the OSgrid specific one for 'Blank Texture'
[ PRIM_FULLBRIGHT, ALL_SIDES, TRUE,
PRIM_TEXTURE, ALL_SIDES, "5748decc-f629-461c-9a36-a35a221fe21f", <1,1,0>, <0,0,0>, 0 ]
);
}
touch_end(integer num_touches) {
if(llDetectedLinkNumber(0) == LINK_ROOT) {
state unlit;
}
}
} </source>
[11:45] Toggle boxes: state: unlit
[11:45] Boomslang Mamba: was that it?
[11:45] Fu Barr: yeah - that one
[11:45] Boomslang Mamba: nice
[11:46] Kawaii Unicorn: ok
[11:46] Fu Barr: okay now we're going to read the script together
[11:46] mika mesmeriser: can i take box out of edit??
[11:46] Fu Barr: or rather I'm going to tell you what to read and how it's structured
[11:46] Fu Barr: sure
[11:46] mika mesmeriser: kk
[11:46] Fu Barr: we will only need the script for now
[11:46] mika mesmeriser: tx
[11:46] Fu Barr: first of all. anything in orange is a comment
[11:47] Fu Barr: ni the script window
[11:47] Fu Barr: orange == comment and it is NON FUNCTIONAL
[11:47] paela argus: -*- loOl -*-
[11:47] paela argus: i'm a rabbit
[11:47] Fu Barr: it doesn;t do anything
[11:47] Koni Lanzius: ~** HAHAHA! **~
[11:47] Fu Barr: it's just there to help you the scripter to member what you did 6 months ago
[11:47] Koni Lanzius: ahh
[11:48] mika mesmeriser: i need one for hour ago
[11:48] Fu Barr: so the first few orange lines just tell me that this is the first version and that it does next to nothing
[11:48] Arielle Popstar: hehe Mika
[11:48] Fu Barr: you can do this however you like
[11:48] Fu Barr: i like to add this stuff to the top of my scripts - it keeps me sane. but you dont have to d this.
[11:48] Fu Barr: after all this is non FUNCTIONAL stuff
[11:49] Fu Barr: now, under the comments you see two lines starting with 'integer'
[11:49] Fu Barr: those lines 'declare to the rest of the script that there are 2 values to be used in the whole script'
[11:49] Fu Barr: i declate the word DEBUG to beTRUE
[11:50] Fu Barr: and the word LINK_LAMP to be the number 3
[11:50] Fu Barr: *declare
[11:50] Koni Lanzius: the declaration is required?
[11:50] Fu Barr: if I use DEBUG or LINK_LAMP anywhere after these lines anyplace in the script... the cript will replace the WORD with the value
[11:50] Fu Barr: yes
[11:51] Koni Lanzius: ahh
[11:51] albertlr Landar: so an integer can be either True or False or a number?
[11:51] Fu Barr: yes
[11:51] Koni Lanzius: i see
[11:51] Fu Barr: because the script engine internally sets TRUE to 0
[11:51] Fu Barr: and FLASE to -1
[11:51] Fu Barr: *FALSE
[11:51] Koni Lanzius: is that minus one or just one
[11:52] Fu Barr: so we rea it as a word, but the script sees an integer
[11:52] Fu Barr: no MINUS one
[11:52] Arielle Popstar: is the word DEBUG arvbitrary?
[11:52] Fu Barr: -1
[11:52] Fu Barr: yes
[11:52] Arielle Popstar: can use anyword?
[11:52] Fu Barr: i chose
[11:52] Fu Barr: it
[11:52] Koni Lanzius: dash one
[11:52] paela argus: it works like a switch is electricity going on either not
[11:52] Fu Barr: but I chose it for a reason
[11:52] Fu Barr: we'll see why i chose it later in the script
[11:52] Koni Lanzius: kk
[11:52] Fu Barr: okay one lasst thing....
[11:53] Fu Barr: word you use as symbols for values, like here DEBUG or LINK_LAMP
[11:53] Fu Barr: are called 'variables'
[11:53] Fu Barr: and you can change the value at any time
[11:53] paela argus: hehe french world :D
[11:53] paela argus: word*
[11:53] Fu Barr: so if i declare LINK_LAMP = 3 at the top
[11:54] Koni Lanzius: :)
[11:54] Fu Barr: i can later decide to say: LINK_LAMP = 5
[11:54] Fu Barr: so now LINK_LAMP points to the number 5 not 3
[11:54] Fu Barr: variables are like little ziplock bags for data
[11:55] Koni Lanzius: ahh
[11:55] Fu Barr: any questions so far?
[11:55] Fu Barr: you should be asking me one
[11:55] albertlr Landar: each command line must end with ";"?
[11:55] Koni Lanzius: where is the 3 in the script?
[11:55] Fu Barr: yes
[11:55] Koni Lanzius: ahh
[11:55] Fu Barr: very good oni - we'll gt to that :)
[11:56] Fu Barr: *Koni
[11:56] Koni Lanzius: kk
[11:56] Fu Barr: but no you should be asking, 'Fu, do variables have to be in CAPITALS'?
[11:56] Koni Lanzius: do they?
[11:56] Fu Barr: and the answer is no, they dont
[11:56] Koni Lanzius: why do you use them?
[11:56] Fu Barr: but i'm using an old tradition from C programming
[11:56] Koni Lanzius: ahh
[11:57] Fu Barr: some variables never change during the life of the script
[11:57] Fu Barr: these sort of variables are called 'Constants'
[11:57] Fu Barr: sort of obvious :)
[11:57] Fu Barr: and in C there was a tradition that Constants were written in CAPITAL to make them 'jump out' as being constants
[11:57] Koni Lanzius: constant variables haha
[11:58] George Equus is Online
[11:58] Fu Barr: LSL itself uses this tradition too.
[11:58] Fu Barr: we already saw how LSL itself defines TRUE and FALSE as constant variables
[11:58] Fu Barr: TRUE = 0, FALSE = -1
[11:58] Koni Lanzius: ah ok
[11:58] Fu Barr: the idea should be clear. i hope
[11:58] Koni Lanzius: but why the dash before the one?
[11:59] Fu Barr: it's not a dash - it's a minus
[11:59] Fu Barr: -1 negative == false
[11:59] albertlr Landar: negative number
[11:59] Fu Barr: 0 is positive == true
[11:59] Koni Lanzius: oook
[11:59] Jeff Hall: boolean
[11:59] Fu Barr: okay let's move to the meat of the script
[11:59] Fu Barr: please look at the next line
[11:59] paela argus: yum
[11:59] Kawaii Unicorn: lol
[12:00] Fu Barr: it says 'default {'
[12:00] Fu Barr: the bracket is important
[12:00] Fu Barr: this left hand bracket is the 'beginning of a code block'
[12:00] Koni Lanzius: indicates the resting state of the object?
[12:00] Fu Barr: the code block is called default
[12:01] Fu Barr: one moemnt koni let me finish this first
[12:01] Koni Lanzius: kk
[12:01] Fu Barr: now a few lines later you see a single } on it's own
[12:01] Hud multi action 1.1 :D: paela argus spanks Koni Lanzius's ass.
[12:01] Fu Barr: line 21
[12:01] Koni Lanzius: hehe
[12:01] Fu Barr: so that's the close bracket on the block of code
[12:01] Fu Barr: open and close brackets ALWAYS need to be in balance
[12:02] Fu Barr: one open, one close
[12:02] Fu Barr: and the blocks can live inside of one another
[12:02] Fu Barr: look at line 17
[12:02] Fu Barr: state_entry() {
[12:02] Fu Barr: see, theres an open bracket
[12:02] Fu Barr: and the close bracket that belongs to it....
[12:02] Fu Barr: that's on line 20
[12:02] Azi Az is Online
[12:03] Fu Barr: see how they are always balanced?
[12:03] Lance Fang is Online
[12:03] Koni Lanzius: mine are not numbered
[12:03] Koni Lanzius: yes
[12:03] Fu Barr: one of the most annoying code things to go wrong is forgetting or deletingper accident a barcket
[12:03] Fu Barr: because you'll spend hour looking for the bracket
[12:04] Koni Lanzius: eep
[12:04] Koni Lanzius: pity they are not color coded
[12:04] Fu Barr: so keep your brackets balanced... and that's why you use tabs and indentation to help you 'show the structure of your code bloacks'
[12:04] paela argus: { //1 } //1
[12:04] Fu Barr: any questions about the brackets?
[12:05] Fu Barr: cool.
[12:05] Fu Barr: now find the line that says: state unlit {
[12:05] Jeff Hall: can u pass me a copy Fu pls?
[12:05] Fu Barr: then scroll down and find the close bracket for that first bracket...
[12:05] Fu Barr: sure
[12:06] Fu Barr: have you found it
[12:06] Koni Lanzius: would that be the next close braket in the script?
[12:06] paela argus: nuu
[12:06] paela argus: (sm-en) village
[12:06] paela argus: 42
[12:06] Fu Barr: nope
[12:07] Fu Barr: the open bracket is on line 24
[12:07] Fu Barr: nope not 42
[12:07] Koni Lanzius: mine has no numbered lines
[12:07] Object: Script running
[12:07] Fu Barr: soz koni :(
[12:07] Fu Barr: no the close bracket is further down on line 51
[12:08] albertlr Landar: just observation but if brackets are not properly balance script will not work.
[12:08] Fu Barr: exactly as i said before brackets HAVE to be balanced
[12:08] Koni Lanzius: ahh found it
[12:08] Fu Barr: can everybody see that the open bracket is on 24 and the close is on 51
[12:08] paela argus: -*- loOl -*-
[12:08] paela argus: have lost line 26
[12:08] Koni Lanzius: i can
[12:09] Fu Barr: well - i'll leave it as home work to find the missing bracket :)
[12:09] Fu Barr: like we said, we use brackets to define code BLOCKS
[12:09] Fu Barr: everything between the bracketss is ONE block
[12:09] Fu Barr: it looks like lots of lines etc. but it's one block
[12:10] Fu Barr: so we've seen that this script so far has 2 blocks - at least
[12:10] Fu Barr: the default block
[12:10] Fu Barr: and the 'unlit' block
[12:10] Fu Barr: there's another 3rd and final block - who can find it for me?
[12:11] Koni Lanzius: line 79?
[12:11] Fu Barr: dont be shy - just look for the brckets
[12:11] Fu Barr: almost koni
[12:11] Koni Lanzius: line 80
[12:11] paela argus: one more
[12:11] Fu Barr: 81 is the closing bracket - where's the opening bracket?
[12:11] Koni Lanzius: 54?
[12:12] Fu Barr: excellent! 54!
[12:12] paela argus: state lit { yup
[12:12] Koni Lanzius: ahh
[12:12] Fu Barr: it says 'state lit {
[12:12] Koni Lanzius: wouldnt that last bracket represent all the bl;ocks tho?
[12:12] Fu Barr: nope
[12:12] Koni Lanzius: huh.
[12:12] George Equus is Offline
[12:13] Fu Barr: check how the barckets are balnced you'll see there are 3 main BLOCKS of code
[12:13] Koni Lanzius: kk
[12:13] Fu Barr: there are brackets INSIDE of those blocks...
[12:13] Koni Lanzius: i see
[12:13] Fu Barr: but that's just blocks inside of block, a bit like the russian doll thing
[12:13] Fu Barr: one doll inside another doll
[12:13] albertlr Landar: One way I have found to trouble shoot is script is to print it out, and then draw lines between the First open bracket and its closed bracket. Think
of each block as a room.
[12:13] Fu Barr: one block inside another block
[12:13] Koni Lanzius: so there is not a encompassing block surrounding the three
[12:14] Jeff Hall: for those who dont know LSLEditor can highlight beginning and ending brackets, it can help
[12:14] Fu Barr: there are manny ways to do it - up to you to find one that works for you
[12:14] Fu Barr: so what have i been trying to show you guys so far...
[12:14] Fu Barr: well
[12:14] Fu Barr: i'm trying to show how code is mde of blocks and that these blocks have STRUCTURE
[12:14] Koni Lanzius: ahh
[12:14] Fu Barr: do this block. first
[12:15] Fu Barr: then if you need to, do this other block
[12:15] albertlr Landar: each block is like a room
[12:15] Fu Barr: it may well be that there is code in a script that you will NEVER actually RUN
[12:15] albertlr Landar: and you can have rooms inside those too.
[12:15] Fu Barr: because the situation that needs that code never happens
[12:15] Koni Lanzius: ahh
[12:15] Fu Barr: so a block might be used, it might not, it depends on the structure of the code.
[12:16] Fu Barr: so when you first read a script.... you have to look for its structure
[12:16] Blue Bird: Like having a cat tree, but not having any cats yet...
[12:16] Fu Barr: yes, a bit :)
[12:16] Fu Barr: so this script has 3 parst.
[12:16] Koni Lanzius: i see
[12:16] Fu Barr: *parts
[12:16] Fu Barr: the first part is called 'default'
[12:17] Fu Barr: the second part is called 'unlit'
[12:17] albertlr Landar: also too see if a script is correctly structured you can print it out and then connet each block with a line.
[12:17] Fu Barr: and the third part is called 'lit'
[12:17] Fu Barr: now who wants to have a go at what these parts actually do?
[12:17] Jeff Hall: it is a good habit to tell general algorithm at top section with comments too for helping other users
[12:18] Fu Barr: lol - jeff and I have already 'fought' about commenting style before :)
[12:18] Fu Barr: but in this case I agree :)
[12:18] Arielle Popstar: have we learned what an algorithm is yet?
[12:18] Koni Lanzius: resting state, unlit state, lit state
[12:18] Fu Barr: nope that's happening right now
[12:18] Fu Barr: exactly
[12:18] Arielle Popstar: or too much information at this point?
[12:18] Jeff Hall: i will always fight against about having no explanations Fu lol;)
[12:19] Fu Barr: nono - i'm getting to it right now
[12:19] Fu Barr: so what's this algorithm that is being mentioned.
[12:19] Fu Barr: well it's a fancy word for 'recipe'
[12:19] Fu Barr: how to get stuff done
[12:19] Fu Barr: i want a thing to light up when I click a button
[12:20] Fu Barr: the algorith would be:
[12:20] Fu Barr: 1. wait for click
[12:20] Fu Barr: 2. detect click
[12:20] Fu Barr: 3. switch to the relevant state of lit or unlit
[12:20] Fu Barr: and this is exactly what happens
[12:20] Fu Barr: look in the defaults code block - it says:
[12:21] Arielle Popstar: how does it remember the state of lit or unlit?
[12:21] Fu Barr: when you enter the state, change the state from default to unlit.
[12:21] Fu Barr: one sec Arielle - that's the next bit :)
[12:21] Arielle Popstar: ok :)\
[12:22] Fu Barr: does every body see that in the default state it waits for state_entry and then sends the script to state unlit?
[12:22] Kawaii Unicorn: yes
[12:22] Arielle Popstar: hazily
[12:22] Arielle Popstar: sort of browned out atm
[12:22] Fu Barr: forget about the exact meaning of the code, there's details i'm leaving out, but whats important is the FLOW of the script
[12:22] Fu Barr: ok.
[12:23] Kawaii Unicorn: ok
[12:23] Fu Barr: let's do this slowly and i'll back up
[12:23] Kawaii Unicorn: ok
[12:23] Fu Barr: dont want peple to get lost
[12:23] Kawaii Unicorn: ty
[12:23] Boomslang Mamba: yeah man
[12:23] Fu Barr: so arielle asked - how does the script know where it is
[12:24] Fu Barr: well, the script has a 'life cycle'
[12:24] Fu Barr: a scripts starts, loops for a while as long as it is needed, then it ends. and goes away
[12:24] Fu Barr: start, do stuff, go away
[12:24] Boomslang Mamba: yeah man
[12:25] Koni Lanzius: but the lit state is the final state, is that correct?
[12:25] Fu Barr: now this cycle moves through what OpenSim calls 'states'
[12:25] Jeff Hall: well the script is always listening for event too no Fu?
[12:25] Fu Barr: yeah - events is my next comment - but yes you're right :)
[12:25] Fu Barr: so as the scripts moves through the states....
[12:25] Fu Barr: it experiences stuff.
[12:25] paela argus: script said per default offline and in end open if you not click again its not turned off
[12:26] Fu Barr: like people or avatars
[12:26] Fu Barr: i log on and go to lbsa, chat a bit, tp to someplace, then logoff.
[12:26] Fu Barr: it's a sequence.
[12:27] Fu Barr: now scripts tend to loop, forever till they are witched off... so koni
[12:27] Fu Barr: you said 'lit' was the end state
[12:27] Koni Lanzius: yea?
[12:27] Fu Barr: ein a way it's true
[12:27] Fu Barr: but it's really just another intermediate step
[12:27] Koni Lanzius: huh.
[12:27] Fu Barr: if i click the button in the lit state it goes to the unlit state,
[12:28] Fu Barr: and vice versa
[12:28] Fu Barr: on and on
[12:28] Fu Barr: so there's actually no end to the CYCLE.
[12:28] Koni Lanzius: ahhh
[12:28] Fu Barr: the states come to an end, but the lifecycle of the whole script (in this case) is an endless loop
[12:28] Koni Lanzius: i see
[12:29] Fu Barr: when I start the script it goes automatically to 'default'.
[12:29] Fu Barr: that's just how it is, a rule in scripting.
[12:29] Jeff Hall: it will wait for click event non stop
[12:29] Koni Lanzius: i see
[12:29] Arielle Popstar: so the switch itself does not remember whether it is lit or unlit state but just acts as a toggle?
[12:29] Fu Barr: then I the scripter decided that I wanted to switch the script to the unlit state
[12:29] Arielle Popstar: the default state does not = lit or unlit?
[12:29] Fu Barr: no arielle - it's the EXACT opposite
[12:30] Fu Barr: the only thing a script knows is in which state it is
[12:30] Fu Barr: when a script starts it automatically goes to defaut
[12:30] Fu Barr: it just does
[12:30] Fu Barr: then I the scripter force it to go to state 'unlit'
[12:31] Arielle Popstar: so the state entry is unlit
[12:31] Arielle Popstar: ok
[12:31] Fu Barr: in the unlit state... i wait for something to happen.... if that something is a touch on the button.... I force the script to move to state 'lit'
[12:31] Fu Barr: the script drags it arse into the lit state.
[12:31] Koni Lanzius: hehe
[12:31] Fu Barr: then it sits and waits for he next thing to happen
[12:32] Fu Barr: if it's a click on the button...
[12:32] Jeff Hall: event programming
[12:32] Fu Barr: it moves back into the state 'unlit'
[12:32] Fu Barr: yep jeff has the formal term right there.
[12:32] Fu Barr: you make the script react to 'events'
[12:33] Blue Bird: What if you turn it on and your sim resets while it's "on"?
[12:33] Fu Barr: the event being script started, or button got pressed, or something was heard
[12:33] Fu Barr: it goes back to the starting point - ie. the default state
[12:33] Blue Bird: ohh
[12:33] Fu Barr: scripts always start in default
[12:33] Fu Barr: some scripters who dont really understand the power of states, they stick all their code in the defaults state...
[12:34] Blue Bird: yea, that would be me
[12:34] Fu Barr: it's a nightmare to work with or change/improve their code
[12:34] Koni Lanzius: thats like a header in writing?
[12:34] Fu Barr: best to throw it all out and start fresh
[12:34] Fu Barr: well, it's how you decide to write, its more about coding style.
[12:35] Koni Lanzius: kk
[12:35] Fu Barr: i use the default state to set the stage for my scripts.
[12:35] Koni Lanzius: kk
[12:35] Fu Barr: then I move though the stages I need to deal with various events that might occur
[12:35] Fu Barr: moving the script into stag X or Y as I see fit
[12:36] Fu Barr: manipulating the life cycle of the script
[12:36] Koni Lanzius: spacing is important too, isnt it?
[12:36] Fu Barr: if you read this script again quietly you'll see it clearly i'm sure
[12:36] Fu Barr: just for humans
[12:36] Koni Lanzius: extra spaces can kill a script?
[12:36] Fu Barr: the script engine only cares about brackets and semi-colons
[12:36] Koni Lanzius: no?
[12:37] Koni Lanzius: ohhh
[12:37] Koni Lanzius: guess thats just true in command line stuff
[12:37] Arielle Popstar: spaces break compiling though?
[12:37] paela argus: well you can type script in km koni =)
[12:37] Koni Lanzius: wut is km?
[12:37] albertlr Landar: I have a question about the viewer editor.
[12:37] Fu Barr: now i just want to spend the last few minutes about some of the othe code inside the state
[12:37] Fu Barr: shoot albertlr
[12:37] paela argus: in one line but is just unreadable for human
[12:38] albertlr Landar: It says Edit at the bottom, and apparently that is for external editor how does one set that up in the viewer.
[12:38] Koni Lanzius: ahh
[12:38] Fu Barr: i dont know - it varies per viewer in singu - which is what I use - i dont have that button
[12:38] albertlr Landar: hum my singularity has it.
[12:38] Fu Barr: i do all my scripting in the viewer editor - it works fine for me
[12:39] Arielle Popstar: seems to want to open an extertnal app when clicking edit
[12:39] albertlr Landar: The reason I mention it is the lsleditor program now supports the ossl functions too.
[12:39] Fu Barr: oh that edit - i never use that button - like I say i edit all my scripts in the viewer editor
[12:39] albertlr Landar: its set up somewhere in the advanced but not sure where.
[12:39] Koni Lanzius: when i click the edit button it says "Complie successful! save complere"
[12:39] albertlr Landar: https://sourceforge.net/projects/lsleditor/
[12:39] Fu Barr: i never use the functions code completion stuff. I code from knowledge and use the various wiki pages all the time.
[12:39] Arielle Popstar: so maybe point it at an installed lsleditor?
[12:40] albertlr Landar: That is the exteral editor for those that don't have it.
[12:40] Fu Barr: yeah - i never use it. but that a distraction now - lets finish looking at the code.
[12:40] albertlr Landar: The only reason I don't like the viewer one is it is so small.
[12:40] Koni Lanzius: k
[12:40] Fu Barr: so small?
[12:40] paela argus: good scripter doesnt need external editor internal editor of viewer i just perfect for typing a lsl code
[12:40] paela argus: =)
[12:41] paela argus: is*
[12:41] Koni Lanzius: :)
[12:41] albertlr Landar: ok
[12:41] Fu Barr: you can change the editor font size.
[12:41] Arielle Popstar: ok so use it till i am good scripter? :)
[12:41] albertlr Landar: oh you can
[12:41] Fu Barr: but thats not for now. sorry :)
[12:41] Arielle Popstar: 10 years or so
[12:41] albertlr Landar: ok later.
[12:41] Fu Barr: okay so final thing.
[12:41] Fu Barr: lets look at the unlit state
[12:41] Fu Barr: first let's find the blocks
[12:42] Toggle boxes: state: lit
[12:42] Fu Barr: then lets see what those blocks are
[12:42] Toggle boxes: state: unlit
[12:42] Fu Barr: blocks as we now know live in between brackets
[12:42] Fu Barr: so we have two main blocks in this state
[12:42] Fu Barr: the first block is labelled state_entry()
[12:42] Fu Barr: the second block is labelled touch_end
[12:43] Fu Barr: can you guys see that?
[12:43] Koni Lanzius: yes
[12:43] Fu Barr: inside those blocks there are more blocks...
[12:43] Fu Barr: liek we said.. russian dolls
[12:43] Fu Barr: in the state_entry block there are 3 seperate bits
[12:44] Fu Barr: if(DEBUG)
[12:44] Fu Barr: and 2x llSetPrimitiveBlaBLabLa
[12:44] Koni Lanzius: right
[12:44] Fu Barr: only the if(DEBUG) has BRACKETS
[12:44] Fu Barr: so only the if(DEBUG) is a block
[12:45] Fu Barr: the other two are just 'commands'
[12:45] Fu Barr: but most commands need relevant information to work properly and all the () and [] and all that is to help structure the info the command needs
[12:46] Fu Barr: i've used a lot of white space here to make it all look a little neater
[12:46] Fu Barr: but just to finish...
[12:46] Fu Barr: if i want to make the prim 'light up'... I can set all the sides to FULL_BRIGHT
[12:46] Fu Barr: is i want to turn the light off....
[12:47] Fu Barr: well i need to set FULL_BRIGHT to FALSE...
[12:47] Fu Barr: now look at the code
[12:47] Fu Barr: it's EXACTLY what is happening
[12:47] Fu Barr: i'm telling the script...
[12:48] Toggle boxes: state: unlit
[12:48] Fu Barr: find the linked prim which is the bulb prim (LAMP_PRIM =3) and set the prim value to something relevant
[12:48] Fu Barr: if you look at the link set of these prims
[12:48] Fu Barr: you'll see that the prim that acta as a bulb is 3rd in the linkset
[12:49] Fu Barr: green cylinder = 1
[12:49] Fu Barr: the brown thing= 2
[12:49] Fu Barr: and the white one is 3
[12:49] Fu Barr: so what this script does...
[12:49] Fu Barr: is
[12:49] Fu Barr: cycle through lit/unlit states
[12:49] Toggle boxes: state: unlit
[12:50] Fu Barr: and in each state set the relevant FULL_BRIGHT value on the 3rd prim
[12:50] Fu Barr: that's it
[12:50] Fu Barr: nothing else
[12:50] Fu Barr: it just looks al ittle complicated but conceptually it's very simple
[12:50] Koni Lanzius: ahh
[12:51] Fu Barr: if i move into lit, set fullbright, if i moveinto unlit, urn fullbright off
[12:51] Fu Barr: and all i do is 'wait' for a touch event
[12:51] Fu Barr: read the script again carefully and it'll be quite clear now that you understand the concept of script life cycle and states and 'brackets'
[12:52] Koni Lanzius: on line 40, what is that number/letter series
[12:52] Fu Barr: ah
[12:52] Fu Barr: that is the UUID of the 'blank texture'
[12:52] Koni Lanzius: i see
[12:52] Fu Barr: everything in opensim/OSgrid has a unique number
[12:52] paela argus: set texture on all face primitive :)
[12:52] Koni Lanzius: i see
[12:52] Fu Barr: here I use that number to force the texture on the bulb prim to be pure white
[12:53] Jeff Hall: i have a question
[12:53] Fu Barr: I'm setting TWO parametrs on the pri. 1. full bright, 2. the blank texture
[12:53] Fu Barr: sure jeff -
[12:53] Koni Lanzius: i see
[12:54] Fu Barr: btw. the SecondLife LSL wiki is ESSENTIAL
[12:54] Fu Barr: you cannot script without the LSL Wiki and the OSSL wiki
[12:54] Arielle Popstar: i am still not getting how the script knows whether to use the lit or unlit block codes of script to toggle the light on or off
depending on its present state. Seems to me it would just run the last bit of code to turn an allready on light to continue in the on state
[12:54] Jeff Hall: why do u have a state_entry embedded in state unlit since its allready called in default / state_entry?
[12:54] Fu Barr: that's where all the info is of how to use the various functions
[12:55] paela argus: http://wiki.osgrid.org/index.php/LSL_Functions
[12:55] Fu Barr: jeff - because i need to turn off the light :)
[12:55] Fu Barr: one state turns it on
[12:55] Fu Barr: the other off
[12:55] Fu Barr: i do that in the state_entry event of the relevant state
[12:55] Fu Barr: arielle -
[12:55] Fu Barr: the script doesnt keep running
[12:56] Jeff Hall: u could remove the state_entry in state unlit and just make it turn off
[12:56] Fu Barr: from state to state
[12:56] Fu Barr: it stays in one state untill you the scripter force it into another state
[12:56] Fu Barr: no you can't remove the state_entry - because the script engine always expect to see a state_entry block :)
[12:57] paela argus: there are several ways to do it, let's stay on the one of fu's or everybody will lose it
[12:57] Fu Barr: each state needs at least state_entry. otherwise it flags a vacant error
[12:57] Fu Barr: yeah - many ways to skin a cat.
[12:57] Fu Barr: i chose this one because I felt it was the most 'clear' way to do it
[12:57] Jeff Hall: sorry, i just didnt think that way
[12:58] paela argus: yup
[12:58] Fu Barr: jeff - you cannot not have a state_entry in a stte.
[12:58] Fu Barr: the script engine will flag an error
[12:59] Arielle Popstar: i am thinking of an ini file where the last entry of a variable is used no matter how many times it has a different variable for a
certain thing, before that
[12:59] Fu Barr: anyhow - thats it for this evening. i hope it wasn't too overwhelming and dont be embarassed to reach out to me in IM or here in chat with questions. Happy to
help and go over things a million times
[12:59] Jeff Hall: ty Fu
[12:59] Koni Lanzius: was brilliant, thank you Fu!!
[12:59] Koni Lanzius: ~** APPLAUSE **~
[12:59] albertlr Landar: Well thanks for the lessons Fu Barr.
[12:59] Koni Lanzius: ~**YAY!!!!**~
[13:00] Blue Bird: Thank you FU, you have helped a lot!
[13:00] Fu Barr: i do suggest you just carefully read the script
[13:00] paela argus: meow meow
[13:00] albertlr Landar: Also I solved my external editor question.
[13:00] Fu Barr: so i guess we'll do another one next week?
[13:00] Koni Lanzius: awesomes!
[13:00] paela argus: please clear stuff before leave peoples :)
[13:00] Koni Lanzius: yea really helped
[13:00] Fu Barr: bring a friend etc. spread the word
[13:00] Fu Barr: all of that jazz
[13:00] Koni Lanzius: kk
[13:00] albertlr Landar: In Singularity its under Advanced and Debug settings. Then you enter ExternalEditor and it allows you put in the link.
[13:00] Koni Lanzius: bye for now
[13:00] Fu Barr: don't forget to clean up your prims
[13:01] Jeff Hall: ty Fu and see u soon
[13:01] Fu Barr: thanks for coming and joining in all!