sketchucation logo sketchucation
    • Login
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Failing Formulas?

    scheduled pinned locked moved SketchyPhysics
    11 Posts 3 Posters 981 Views 3 Watching
    loading-more-posts
    • oldest-to-newest
    • newest-to-oldest
    • most-votes
    reply
    • reply-as-topic
    guest-login-reply
    deleted-message
    • P Offline
      Physicsguy1
      last edited by

      can formulas be set to fail to function after a certain number of frames?

      one-reply-to-this-post last-reply-time reply quote 0
      • C Offline
        CPhillips
        last edited by

        What do you mean by "fail"?

        one-reply-to-this-post last-reply-time reply quote 0
        • B Offline
          BTM
          last edited by

          ...I think he means to stop working.

          one-reply-to-this-post last-reply-time reply quote 0
          • B Offline
            BTM
            last edited by

            yup.

            if frame==0 then setVar("foo",1);elsif frame==100 then setVar("foo",0);end;
            

            What it means: if frame is at 0, then set the variable "foo" to 1. if the frame is at 100, then get the variable "foo", and set it to 0. End.
            fails at 100.skp
            NOTE: the script can be put in the onTick box of any object.

            one-reply-to-this-post last-reply-time reply quote 0
            • P Offline
              Physicsguy1
              last edited by

              I need to know how to get a controlled script to fail, like a car out of gas

              one-reply-to-this-post last-reply-time reply quote 0
              • C Offline
                CPhillips
                last edited by

                Somewhere give it a full tank.

                setVar("gas",100) if frame==0
                

                In the motor accel

                (getVar("gas")<0? 0;1)*whatevermotorstrength;
                

                Somewhere consume the gas

                if(key("up")>0);g=getVar("gas");setVar("gas",g-1);end
                
                one-reply-to-this-post last-reply-time reply quote 0
                • P Offline
                  Physicsguy1
                  last edited by

                  The example wasn't what i wanted an example for. i need a thruster on a plane to not function regardless of control inputs.

                  one-reply-to-this-post last-reply-time reply quote 0
                  • B Offline
                    BTM
                    last edited by

                    ...That is what you're looking for physicsguy, isn't it?

                    one-reply-to-this-post last-reply-time reply quote 0
                    • B Offline
                      BTM
                      last edited by

                      ...my first example? all you have to do is type getVar("foo")* before each value. Here's something you may find familiar, with this technique in use πŸ˜‰
                      Dies completely (except bombs) after frame 500.

                      By the way, C.Phillips, mind explaning that script? I wouldn't mind figuring out how it works πŸ˜‰ What's g?
                      ...all I can get so far is that gas is 100, if gas is smaller than 0, then the motor stops, and when up is pressed, g is equal to gas, which is equal to one less than g, thus lowering the value by 1 each frame up is>0 (pressed). But can you just use a letter as a variable? It doesn' seem to work for me...

                      one-reply-to-this-post last-reply-time reply quote 0
                      • P Offline
                        Physicsguy1
                        last edited by

                        thanks

                        one-reply-to-this-post last-reply-time reply quote 0
                        • C Offline
                          CPhillips
                          last edited by

                          @unknownuser said:

                          By the way, C.Phillips, mind explaning that script? I wouldn't mind figuring out how it works πŸ˜‰ What's g?
                          ...all I can get so far is that gas is 100, if gas is smaller than 0, then the motor stops, and when up is pressed, g is equal to gas, which is equal to one less than g, thus lowering the value by 1 each frame up is>0 (pressed). But can you just use a letter as a variable? It doesn' seem to work for me...

                          Yes "g" is a temporary variable. It could have been "gas" or (almost) anything. I tested the code and it seems to work as expected. How does it not work for you?

                          one-reply-to-this-post last-reply-time reply quote 0
                          • 1 / 1
                          • first-post
                            last-post
                          Buy SketchPlus
                          Buy SUbD
                          Buy WrapR
                          Buy eBook
                          Buy Modelur
                          Buy Vertex Tools
                          Buy SketchCuisine
                          Buy FormFonts

                          Advertisement