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); 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.
-
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.5
with a,s,d,f,g for gears, e for empty and r for reverse
Advertisement