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

    Two scripting questions

    Scheduled Pinned Locked Moved SketchyPhysics
    9 Posts 6 Posters 1.0k Views 6 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
      Platypus5
      last edited by

      I have two questions about the next version.

      First of all, will it be possible for an object to figure out which other object of a certain class is closest to it? That would be helpful in things like, turrets.

      2nd, will you be able to modify the ontouching event so that the event only applies when the object is touching one particular thing? As in, a cube being set to emit stuff when it is touched by the sphere "blah" but NOT by the cone "Dorg"

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

        2nd: yes.

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

          1st is already possible. Oh, and you'll be able to tell the name of the object that's touching, so, yes.

          For the first, you'd also be able to only start firing when the object is 'within range'. Oh, and you probably already know you can change lookAt... in the next version, you'll also be able to turn it off once started.

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

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

            Yes, in next version you can find the name of the object that touched and respond accordingly.

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

              @wacov said:

              1st is already possible. Oh, and you'll be able to tell the name of the object that's touching, so, yes.

              For the first, you'd also be able to only start firing when the object is 'within range'. Oh, and you probably already know you can change lookAt... in the next version, you'll also be able to turn it off once started.

              Could you tell me where I can find out the scripting nessicary for the "smart turret?" For example, HOW do you define object classes? HOW do you get the square root of something (square root is nessicary for the Pathagoream Therom and therefore the distance formula.)

              Also, I asuming that what you mean by "you can change lookAt" refers to their use along with "if statements". If not, I don't know what you mean.

              Please forgive my ignorance. I find it really hard to keep up with all the developments.

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

                Not really classes, but names are almost as good. Every body has a name. So you can (in next version) say:

                
                if toucher.name=="smallTurret"
                   #within range of 100?
                   if (position-toucher.position).length<100
                      #do something.
                   end
                end
                
                
                
                1 Reply Last reply Reply Quote 0
                • C Offline
                  CPhillips
                  last edited by

                  Thats right.

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    Jaycephus
                    last edited by

                    I haven't even gotten to looking at scripting yet, but it looks like the 'name' field is a string, so with a bit of extra code you could look at the prefix of the name as a class identifier, right?

                    so fire at all objects named: "enemy<something>"

                    or act on all objects named: "box<number>", but ignore anything else


                    • Jay
                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      Sgal
                      last edited by

                      If you need square root, this is my suggestion:
                      x**0.5

                      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