Second Life Scripting: Beginner 01 - Creating a Simple Switch

Поделиться
HTML-код
  • Опубликовано: 24 янв 2025

Комментарии • 38

  • @greenthumb-greywraith7426
    @greenthumb-greywraith7426 4 года назад +5

    I would like to express my thanks for these tutorials you've uploaded. They've been a big help thus far in learning LSL. Keep up the good work and, thanks again!

    • @HumAiClub
      @HumAiClub 3 года назад

      I also would like to express my thanks for these very helpful tutorials.

  • @teachertang
    @teachertang Год назад +1

    Thank you for the technique. I'm learning programming.

  • @juliamilovat
    @juliamilovat 4 месяца назад

    Many, many thanks for making this crystal clear!

  • @RandomLabs
    @RandomLabs  11 лет назад +1

    Glad to hear it! Yes, when they are broken down into small parts, scripts are not as complicated as they first appear!

  • @RobbeyT1
    @RobbeyT1 9 лет назад +1

    Finally I get it...Thanks! Slowly (very slowly), working on a Hud that needs a small switch which will turn Black for off, and Red for on.

  • @RandomLabs
    @RandomLabs  9 лет назад +2

    @3dmaster Thanks!
    In this case, the word 'switch' has been set up as a variable that can hold any whole numbers (aka, an integer variable).
    When I first set it up using 'integer switch;' its initial default value will be zero (unless I specifically set it otherwise, e.g. integer switch=1;). I use that zero value to represent the switch being off.
    And so, when you touch the object, it will ask the question if (switch==0) or in other words... is 'switch' currently set to zero?
    When that is true, the code directly beneath inside the parentheses { } will be executed, setting the switch to 1, which represents the switch being on.
    The next time the question is asked, if (switch==0) the answer will no longer be true, because we set the value of switch to 1 (to represent that the switch is now on)
    so instead, it will move on to the next question.. else if (switch==1).. or in other words.. Ok, so if switch isn't set to 0.. is it set to 1??
    Now this question will be true, and so the code in those parentheses will be executed instead, setting 'switch' back to zero again.
    Having said all of this, the code would work just fine if you wrote it all the other way around...so...
    if(switch==1)
    {
    switch=0;
    doOtherStuff;
    }
    else if (switch==0)
    {
    switch = 1;
    etc;
    }
    ...would also work perfectly fine. In this case, the fist time you clicked the object with switch still set at its default zero, it would skip over the false first question and instead go to the true 2nd question.
    I only wrote it down in that particular order as that's how my brain works I suppose :)
    In more complicated scenarios the order you step through your if-then-else logic may well become more important, but in this case either way would work fine.
    Hope that helps! :)

  • @DarkKingBowser
    @DarkKingBowser 10 лет назад +2

    In college I did a lot of C++. I'm so glad those skills carry over...

  • @tommpimm
    @tommpimm 11 лет назад +1

    great! ,this is the push I needed to finely try understanding LLscript.Thanx

  • @immigration007
    @immigration007 11 лет назад +1

    very helpful. I kind of understand events now.

  • @RandomLabs
    @RandomLabs  11 лет назад +1

    Cool! I'm attempting to upload episode 2 right now :)

  • @jourdymoretti9081
    @jourdymoretti9081 9 лет назад +1

    Ok i'm looking for a way to write a scripts that is very specific and hoping that someone can point me in the right direction. I want to make a charm bracelet, so say you have the bracelet and you want to get a charm, i want you be able to touch that charm and add it to the bracelet. Does anyone know where or how I would look. I've asked people in SL but so far no responses.

  • @coolarine
    @coolarine 6 лет назад +1

    Thank you so much ♡
    This video helped me a lot 😍

    • @coolarine
      @coolarine 6 лет назад

      @steve gale i bought scripts from marketplace, but i didn't know how to add ... but after watching this i managed to do it..

    • @RandomLabs
      @RandomLabs  6 лет назад +1

      Hi Steve, this was a script for absolute beginners, I wrote it this way so that people could clearly see that the if statement is asking the question "if switch is currently set at a certain value, do this and change that value". I would also point out that lsl doesn't actually have proper bools, and TRUE and FALSE are just integer constants with a value of 1 and 0. If it were me writing it for myself, I would actually use...
      if (switch =! switch) // flip the switch
      {
      //Do true stuff
      }else
      //Do false stuff
      }
      But again, this isn't as clear for absolute beginners who have zero concept of what any of this means. This code clearly isn't for you as you're clearly not an absolute beginner.
      Showing it this way also makes it clearer that you could do something like...
      if (switch == 1)
      {
      }
      else if (switch == 2)
      {
      }
      else if (switch == 3)
      {
      }
      etc.
      Seeing as lsl also doesn't have any sort of switch / case statement, again, this is more helpful for the absolute beginner in my opinion.

  • @MManel
    @MManel 5 лет назад +1

    Very good
    Thanks for share !...

  • @YngPup
    @YngPup 3 года назад +2

    the problem I am seeing with every person that does lessons on scripting is they do not explain what every little mark on a keyboard means or does.... I.E. what an asterisk ( * ) does or a slash ( / ) does or the meaning of what a comma ( , ) does beforehand... they just shoot straight into a lesson of writing scripting

  • @Nekotico
    @Nekotico 8 лет назад

    dude, i have a question, im using a particle system, but i have a problem, the texture have a parameter that follow all the time the camera angle, i mean, every angle i see the texture, its all the time looking at me...what parameter do that? i wanna change it....im doing it for a car, so it let the whell mark in the floor, thanks good video!

    • @RandomLabs
      @RandomLabs  8 лет назад

      Hey Nekotico. You need to look in to Ribbon particles. They are relatively new in SL and I haven't played with them much, but that's what you should be searching for :) This video show a good example of what you're looking for... ruclips.net/video/qIjc5JkOgu8/видео.html and here is the wiki page for the particle system... wiki.secondlife.com/wiki/LlLinkParticleSystem#llLinkParticleSystem

  • @sniperunu7716
    @sniperunu7716 7 лет назад

    how i can make the tatto appllier to not show me more error is work fidne but is show me the error and idk how to stopthet can somabry help me ?

    • @emilyjohnson6096
      @emilyjohnson6096 6 лет назад

      sniper unu What. Do a try catch around the statement.

  • @sabiatounjoya7308
    @sabiatounjoya7308 4 года назад +2

    Thank you so MUCH! from SabiaLunaBitcoin.

  • @gundanga
    @gundanga 9 лет назад

    Why is every tutorial on LSL script the same. They all spend forever explaining the default state.

    • @RandomLabs
      @RandomLabs  9 лет назад +2

      Level: Beginner. I was trying to explain the structure of things for people who have never touched code.

    • @gundanga
      @gundanga 9 лет назад

      Random Labs Yeah I know but so have thousands of other people done since SL started. Search for any SL scripting tutorials and they all think the same as you and think. Anyone that is interested in scripting for SL damn well knows what the default state is because every tutorials spends forever explaining it and nothing new is learnt.

    • @RandomLabs
      @RandomLabs  9 лет назад

      +famous porn superstar™ Have you tried including the words "intermediate" or "advanced" in your searches? I went for a beginner tutorial because I felt I might be good at explaining things in a way a total beginner would understand. Too many people make assumptions about the level of understanding of their audience and will skim over things that they assume will be understood because it's just second nature for the tutor.

    • @gundanga
      @gundanga 9 лет назад

      Random Labs Yeah I have done searches for "intermediate" or "advanced" and they are just as painfully slow, irritating and dwell on the same old default states: Or they have no voice and have blurred video.

    • @gundanga
      @gundanga 9 лет назад

      Random Labs People like me that mesh want to know how to change skin texture with scripts. but having said that I know someone that will help me learn such things.

  • @emilyjohnson6096
    @emilyjohnson6096 6 лет назад +3

    SL is definitely broken script language

  • @wolflahti412
    @wolflahti412 2 года назад

    "First of all, I'm going to create a cube."
    First of all, tell beginners how to create a cube. (Most tutorials say to right-click on the ground, but that just brings up an edit window for the ground object.)

    • @RandomLabs
      @RandomLabs  2 года назад

      In the time it took you to write this comment, you could instead have just searched youtube for a beginners building tutorial. This is a beginners scripting tutorial.

  • @amyjames2077
    @amyjames2077 8 лет назад

    Think I'll leave this to the experts.

  • @NuevoVR
    @NuevoVR 10 лет назад

    this makes no fucking sense lmao.

    • @RandomLabs
      @RandomLabs  10 лет назад

      What part are you having trouble with Kuuro? Feel free to ask a question if you have one!

    • @NuevoVR
      @NuevoVR 10 лет назад

      its not your fault its just my poor understanding ahaha

    • @NuevoVR
      @NuevoVR 10 лет назад

      just trying to become familiar with LSL so I can edit scripts.