sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Failing Formulas?

    Scheduled Pinned Locked Moved SketchyPhysics
    11 Posts 3 Posters 929 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P Offline
      Physicsguy1
      last edited by

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

      1 Reply Last reply Reply Quote 0
      • C Offline
        CPhillips
        last edited by

        What do you mean by "fail"?

        1 Reply Last reply Reply Quote 0
        • B Offline
          BTM
          last edited by

          ...I think he means to stop working.

          1 Reply Last reply 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.

            1 Reply Last reply 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

              1 Reply Last reply 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
                
                1 Reply Last reply 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.

                  1 Reply Last reply Reply Quote 0
                  • B Offline
                    BTM
                    last edited by

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

                    1 Reply Last reply 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...

                      1 Reply Last reply Reply Quote 0
                      • P Offline
                        Physicsguy1
                        last edited by

                        thanks

                        1 Reply Last reply 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?

                          1 Reply Last reply 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