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

    Using formulas

    Scheduled Pinned Locked Moved SketchyPhysics
    18 Posts 4 Posters 2.1k Views 4 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.
    • A Offline
      Alienizer
      last edited by

      @wacov said:

      Whoa, slow down. The blue fields are the ones that can use code...

      I got all excited here didn't I

      Can you enter more than one line in the Blue field? What's "Code: Select all" I see in both of your examples?

      I'm from Mars and moved to Earth to alienize you. Unfortunately, I became humanized.

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

        oh no. that will select it all if you click on it. That will help copy the formula so you can paste it in the fields

        1 Reply Last reply Reply Quote 0
        • A Offline
          Alienizer
          last edited by

          ok thanks again for the help. Do you know where I can find the "codes" we can enter?

          I'm from Mars and moved to Earth to alienize you. Unfortunately, I became humanized.

          1 Reply Last reply Reply Quote 0
          • W Offline
            Wacov
            last edited by

            Scripting is kind of up to you; what you want is to end up with a value, which is what the joint/thruster/emitter/magnet/whatever will be set to. Scripts run each frame of the simulation, so if something changes, like an input from a joystick, then the script will update using this new input. The codes do logical calculations, putting them together, changing them and making them do what you want is up to you; a basic understanding of algebra will help. Search through the forums for the specifics, but there are 'if' functions, which do a test and give a value for either true or false. 'if, elsif' functions do a new test if the first one was false. There is a script that will cycle through values based on the frame number, and there are little snippets which do nice, easy to understand stuff like '0.5-lefty', which, on a motor, allows reversable control using lefty, which is w,s or the left joystick's up/down.

            http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

            1 Reply Last reply Reply Quote 0
            • A Offline
              Alienizer
              last edited by

              Thank you Wacov. I'm a Delphi programmer so I'll have no problem with little functions. What I meant to ask was, where do I find the "keywords" that the blue fields understand. There is the "if,else" but is there any "not,and,or,xor", there is "lefty, leftx" but what about other ones? What about math like sin, cos etc? and of course, things like +-* (/ or \ or both?) what about =, ==, === which is used? bla bla bla. you know! Or maybe I'm looking too hard, is it a ruby script we enter? and all ruby functions will work? Sorry for my ignorance.

              I'm from Mars and moved to Earth to alienize you. Unfortunately, I became humanized.

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

                Its all Ruby syntax. So anything that is legal Ruby should work.
                http://web.njit.edu/all_topics/Prog_Lang_Docs/html/ruby/syntax.html

                Sin is Math.sin()

                The SP specific keywords are not fully documented yet. My top priority.

                1 Reply Last reply Reply Quote 0
                • W Offline
                  Wacov
                  last edited by

                  Some useful stuff (in the new syntax):

                  joy("leftx")
                  joy("lefty")
                  joy("rightx")
                  joy("righty")
                  joyRY (Analogue triggers on a 360 style pad)

                  joybutton("a,b,x,y,rb,lb")
                  key("q,w,e,r,t,y,etc")

                  All the buttons work through joystick emulation, with off being 0.0 and on 1.0. leftx and y are also w,a,s,d on the keyboard, rightx and y are the arrow buttons.

                  http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

                  1 Reply Last reply Reply Quote 0
                  • A Offline
                    Alienizer
                    last edited by

                    Perfect πŸ‘ Thank you guys 😍

                    I'm from Mars and moved to Earth to alienize you. Unfortunately, I became humanized.

                    1 Reply Last reply Reply Quote 0
                    • W Offline
                      Wacov
                      last edited by

                      Oh, don't forget setVar("var") and getVar("var"). This creates and retrieves global variables that carry between frames.

                      http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

                      1 Reply Last reply Reply Quote 0
                      • A Offline
                        Alienizer
                        last edited by

                        @wacov said:

                        Oh, don't forget setVar("var") and getVar("var"). This creates and retrieves global variables that carry between frames.

                        This will be very handy, thank you.

                        I'm from Mars and moved to Earth to alienize you. Unfortunately, I became humanized.

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

                          One other variable function is

                          
                          #get the var foo and set it to 0
                          v=getSetVar("foo",0)
                          

                          It can be a useful shortcut.

                          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