Gearshifting with Variables?
-
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') ? -
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); endShould 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.
-
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.
-
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.5with a,s,d,f,g for gears, e for empty and r for reverse
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement