• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Two scripting questions

Scheduled Pinned Locked Moved SketchyPhysics
9 Posts 6 Posters 1.0k Views
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 6 Jun 2009, 17:50

    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 6 Jun 2009, 18:11

      2nd: yes.

      1 Reply Last reply Reply Quote 0
      • W Offline
        Wacov
        last edited by 6 Jun 2009, 20:30

        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 8 Jun 2009, 21:25

          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 8 Jun 2009, 23:56

            @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 9 Jun 2009, 04:21

              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 16 Jun 2009, 03:58

                Thats right.

                1 Reply Last reply Reply Quote 0
                • J Offline
                  Jaycephus
                  last edited by 16 Jun 2009, 04:32

                  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 16 Jun 2009, 13:17

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

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    1 / 1
                    • First post
                      2/9
                      Last post
                    Buy SketchPlus
                    Buy SUbD
                    Buy WrapR
                    Buy eBook
                    Buy Modelur
                    Buy Vertex Tools
                    Buy SketchCuisine
                    Buy FormFonts

                    Advertisement