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

    Gearshifting with Variables?

    Scheduled Pinned Locked Moved SketchyPhysics
    4 Posts 3 Posters 461 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.
    • K Offline
      klaufi
      last edited by

      Hi

      i want to shift between gears using variables, for example pressing A for driving in first gear, S for second and so on. Would it work if I let the keys change a variable, for example setVar('acc',0.0);if Key('a')==1 setVar('acc',10.0) else if Key('S')==1 setVar('acc',20.0);end;
      (there are lots of mistakes in the syntax, could anyone help?)
      Also, is it possible to set a variable into a normal window like if you have a motorand write Accel: getVar('acc') ?

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

        Setting a variable with a key for each setting is easy.

        if key("a")==1; setVar("gear",1); end
        if key("s")==1; setVar("gear",2); end
        if key("d")==1; setVar("gear",3); end
        if key("f")==1; setVar("gear",4); end
        

        Should do it. You can't get variables in a white field, but a motor's controller will accept values over 1, so you can increase the speed by multiplying your normal controller by 1.something.

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

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

          hmmm... Wacov is right, sorta. That would be if the gears were all seperate though. Better way:

          if key("a")>=0.5 then setVar("gear",0.0);elsif key("s")>=0.5 then setVar("gear",10.0);elsif key("d")>=0.5 then setVar("gear",20.0);end;

          for the motor, type getVar("gear").

          that MIGHT work.

          1 Reply Last reply Reply Quote 0
          • K Offline
            klaufi
            last edited by

            thanks but meanwhile i've found out in SP-wiki^^
            my code so far:

            if frame==1;setVar("acc",0.5);end; 
            if key("a")==1;setVar("acc",0.6);
            elsif key("s")==1;setVar("acc",0.7);
            elsif key("d")==1;setVar("acc",0.8);
            elsif key("f")==1;setVar("acc",0.9);
            elsif key("g")==1;setVar("acc",1);
            elsif key("r")==1;setVar("acc",0.4);
            elsif key("e")==1;setVar("acc",0.5);end; 
            getVar("acc")-0.5
            

            with a,s,d,f,g for gears, e for empty and r for reverse

            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