Panauto Model A + Competizione + Imola

View previous topic View next topic Go down

Panauto Model A + Competizione + Imola

Post by Echo_Delta_Oscar on Sun Jun 05, 2016 2:20 pm

If you manage to get one started, you may experience some fun.

I have finally modeled a power curve consistent with one of a real engine. I gave the parameters of said power curve to LUA, coupled with a gear selector, and this little cars are the results.

Instructions:


Up for throttle, Left and Right for steering
E is the Clutch: hold it down and press Z to switch on/off engine
Release Clutch when ready to go: beware, if you go too slow, the engine stalls!
To change gear, Lift the finger off the throttle, then W or S. This car has 5 gears + reverse
The dashboard will light up in three colours:
Yellow if you are low on RPMs
Green if you are in the high end of the power curve
Red if you are over-revving the engine
A operates both brakes, D operates rear wheel brakes


Model A:




Code:
Val
{
 Brake(default=0,min=0,max=380,step=380,disp=0)
 HBrake(default=0,min=0,max=500,step=500,disp=0)
 HandleF(default=0,min=-45,max=45,step=5,disp=0)
 HandleR(default=0,min=-36,max=36,step=5,disp=0)
 Engine(default=0,min=-2500,max=2500,disp=1)
 Flout(default=0,min=0,max=2500,step=1250,disp=1)
 MAXPOW(default=2500)
 IGN(disp=1)
 Clutch(default=1000, max=1000, min=0, step=10, disp=1)
 Gear(default=1, min=0, max=4, step=0,disp=1)
 OMG(default=0, disp=0)
 G(default=0, disp=0)
 N(default=5, disp=0)
 D(default=1, disp=0)
 R(default=1, min=-1, disp=0)
 A(disp=0)
 B(min=-1000000, disp=0)
 C(min=-1, disp=0)
 Stop(default=#9090,step=100000,disp=0)
 Stop2(default=#0000,disp=0)
 Stop(default=#9090,step=100000,disp=0)
 Stop2(default=#0000,disp=0)
 Back(default=#ffff,step=100000,disp=0)
 BAck2(default=#0000,disp=0)
 SPR(disp=0)
 DMP(disp=0)
 Int(default=#604000, disp=0)
 Col1(default=#ffffaa, disp=0)
 Col2(default=#003c20, disp=0)
 Extr(default=#000000, disp=0)
 Roof(default=1, disp=0)
 Capote1(default=-179, min=-179, max=-60, disp=0)
 Capote2(default=179, min=60, max=179, disp=0)
 Capote3(default=-179, min=-179, max=0, disp=0)
 Capote4(default=180, min=91, max=180, disp=0)
 Capote5(default=180, min=59, max=180, disp=0)
 GCOL(default=#ffffff, step=1000000000, disp=0)
 GEFF(default=#ffff, step=1000000000, disp=0)
 DCOL1(default=#00ff00, disp=0)
 DCOL2(default=#aaaa00, disp=0)
 DCOL3(default=#ff0000, disp=0)
 
}
Key
{
 0:Flout(step=500),Smoke(step=1)
 2:HandleR(step=-2)
 3:HandleR(step=2)
 7:Brake(step=5),HBrake(step=5)
 9:HBrake(step=100)
 16:Clutch(step=-1000)
}
Body {
 Core(){

 N:Frame(option=1){E:RudderF(angle=121, option=1){E:RudderF(angle=-121, option=1){
 N:Frame(angle=155, option=1){N:Frame(angle=-145, option=1){
 N:Frame(angle=80, option=1){N:Frame(angle=-90, option=1){N:Frame(option=1){

 E:Cowl(angle=-120, option=1){E:Cowl(angle=140, color=Col1){E:Cowl(angle=120, color=Col1){}}
 E:Cowl(angle=120, effect=#ffff){S:Cowl(angle=90, color=Col1){E:Cowl(angle=-90, color=Col1){E:Cowl(color=Col1){}}
 N:Cowl(angle=-150, color=Int){}N:Cowl(angle=-30, effect=#a000){E:Cowl(angle=-91,option=3, effect=#a000){}}
 S:Cowl(angle=-90, color=Extr){S:Cowl(color=Extr){}}}}}
 W:Cowl(angle=-120, option=1){W:Cowl(angle=140, color=Col1){W:Cowl(angle=120, color=Col1){}}
 W:Cowl(angle=120, effect=#ffff){S:Cowl(angle=90, color=Col1){W:Cowl(angle=-90, color=Col1){W:Cowl(color=Col1){}}
 N:Cowl(angle=-150, color=Int){}
 N:Cowl(angle=-149, option=2, effect=GEFF, color=GCOL){}
 N:Cowl(angle=-30, effect=#a000){W:Cowl(angle=-91, option=4, effect=#a000){}}
 S:Cowl(angle=-90, color=Extr){S:Cowl(color=Extr){}}}}}

 N:Weight(option=1, color=Extr){

 E:Cowl(angle=-120, option=1){
 E:Cowl(angle=100, effect=#ffff){E:Cowl(angle=20, color=Col2){W:Cowl(angle=89, color=Col2){}
 S:Cowl(angle=45, color=Col2){W:Cowl(angle=89, option=3, color=Col2){}S:Cowl(angle=-15, color=Col2){}}}}
 E:Cowl(angle=140, color=Col1){E:Cowl(angle=120, color=Col1){}
 N:Cowl(angle=175, color=#202020){N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){
 N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){N:Cowl(angle=-170, color=#202020){
 N:Cowl(angle=170, color=#202020){N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){}}}}}}}}}}}
 W:Cowl(angle=-120, option=1){
 W:Cowl(angle=100, effect=#ffff){W:Cowl(angle=20, color=Col2){E:Cowl(angle=89, color=Col2){}
 S:Cowl(angle=45, color=Col2){E:Cowl(angle=89, option=3, color=Col2){}S:Cowl(angle=-15, color=Col2){}}}}
 W:Cowl(angle=140, color=Col1){W:Cowl(angle=120, color=Col1){}
 N:Cowl(angle=175, color=#202020){N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){
 N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){N:Cowl(angle=-170, color=#202020){
 N:Cowl(angle=170, color=#202020){N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){}}}}}}}}}}}

 E:Frame(option=1){

 N:Cowl(angle=-150, option=1){N:Cowl(angle=150, effect=#ffff){
 N:Cowl(angle=-91, option=2, color=Col2){}
 N:Cowl(angle=-90, option=2, color=#ffff00, effect=#a000){
 N:Cowl(angle=-120, option=5, color=Col2){}
 S:Cowl(angle=-120, option=5, color=Col2){}
 E:Cowl(angle=-120, option=5, color=Col2){}
 W:Cowl(angle=-120, option=5, color=Col2){}}}}

 E:RudderF(angle=HandleR, option=1){N:Frame(angle=160, spring=SPR, damper=DMP, option=1){
 W:Wheel(angle=89, brake=Brake, option=1, effect=2, color=0){}}}}
 W:Frame(option=1){

 N:Cowl(angle=-150, option=1){N:Cowl(angle=150, effect=#ffff){
 N:Cowl(angle=-91, option=2, color=Col2){}
 N:Cowl(angle=-90, option=2, color=#ffff00, effect=#a000){
 N:Cowl(angle=-120, option=5, color=Col2){}
 S:Cowl(angle=-120, option=5, color=Col2){}
 E:Cowl(angle=-120, option=5, color=Col2){}
 W:Cowl(angle=-120, option=5, color=Col2){}}}}

 W:RudderF(angle=HandleR, option=1){N:Frame(angle=160, spring=SPR, damper=DMP, option=1){
 E:Wheel(angle=89, brake=Brake, option=1, effect=2, color=0){}}}}}}
 S:Frame(option=1){S:Frame(option=1){S:Frame(option=1){
 S:Frame(angle=0, option=1){S:Wheel(angle=-90, option=1, brake=100000, effect=2, color=0){}}

 E:Cowl(angle=-120, option=1){E:Cowl(angle=120, color=Col1){N:Cowl(angle=60, color=Int){}
 N:Cowl(angle=Capote1, effect=#a000){E:Cowl(angle=Capote4, color=Extr){}N:Cowl(angle=Capote2, color=Extr){
 S:Cowl(angle=Capote5, option=4, color=Extr){}E:Cowl(angle=Capote4, color=Extr){}N:Cowl(angle=Capote3, color=Extr){}}}
 S:Cowl(option=3, color=Col1){}E:Cowl(angle=90, color=Col1){
 E:Cowl(angle=90, color=Extr){S:Cowl(option=4, color=Extr){}}
 N:Cowl(color=Col1){E:Cowl(angle=90, color=Extr){}}S:Cowl(angle=45, color=Col1){}}}
 E:Cowl(angle=100, effect=#ffff){E:Cowl(angle=20, color=Col2){W:Cowl(angle=89, color=Col2){}
 N:Cowl(angle=45, color=Col2){W:Cowl(angle=89, option=4, color=col2){}}S:Cowl(angle=45, color=Col2){W:Cowl(angle=89, option=3, color=Col2){}
 S:Cowl(angle=-179, option=5, color=Extr){}S:Cowl(angle=-178, option=2, color=#aa0000, effect=Stop){}
 S:Cowl(angle=-177, option=2, color=#ffffff, effect=Back){}}}}}
 W:Cowl(angle=-120, option=1){W:Cowl(angle=120, color=Col1){N:Cowl(angle=60, color=Int){}
 N:Cowl(angle=Capote1, effect=#a000){W:Cowl(angle=Capote4, color=Extr){}N:Cowl(angle=Capote2, color=Extr){
 S:Cowl(angle=Capote5, option=3, color=Extr){}W:Cowl(angle=Capote4, color=Extr){}N:Cowl(angle=Capote3, color=Extr){}}}
 S:Cowl(option=4, color=Col1){}W:Cowl(angle=90, color=Col1){
 W:Cowl(angle=90, color=Extr){S:Cowl(option=3, color=Extr){}}
 N:Cowl(color=Col1){W:Cowl(angle=90, color=Extr){}}S:Cowl(angle=45, color=Col1){}}}
 W:Cowl(angle=100, effect=#ffff){W:Cowl(angle=20, color=Col2){E:Cowl(angle=89, color=Col2){}
 N:Cowl(angle=45, color=Col2){E:Cowl(angle=89, option=3, color=col2){}}S:Cowl(angle=45, color=Col2){E:Cowl(angle=89, option=3, color=Col2){}
 S:Cowl(angle=-179, option=5, color=Extr){}S:Cowl(angle=-178, option=2, color=#aa0000, effect=Stop){}}}}}

 E:Frame(option=1){N:Frame(angle=160, spring=SPR, damper=DMP, option=1){
 E:Wheel(name=EWL, angle=91, power=Engine, brake=HBrake, option=1, effect=2, color=0){}}}
 W:Frame(option=1){N:Frame(angle=160, spring=SPR, damper=DMP, option=1){
 W:Wheel(name=WWL, angle=91, power=-Engine, brake=HBrake, option=1, effect=2, color=0){}}}
}}}
}}}}
}}}}}

Lua

{
function main()
-- 316.00 sec
if _KEY(6) == 1 then
out(0,"Instructions:")
out(2,"Up for throttle, Left and Right for steering")
out(4,"E is the Clutch: hold it down and press Z to switch on/off engine")
out(6,"Release Clutch when ready to go: beware, is you go too slow, the engine stalls!")
out(8,"To change gear, Lift the finger off the throttle, press the clutch, then W or S. This car has 4 gears + reverse.")
out(10,"The dashboard will light up in three colours: ")
out(12," Yellow if you are low on RPMs")
out(14," Green if you are in the high end of the power curve")
out(16," Red if you are over-revving the engine")
out(18,"A operates both brakes, D operates rear wheel brakes")
out(20,"Q operates the capote")
else
out(1,"Need Help? Press C to read instructions.")
out(3,"For your first runs, I suggest keeping the variables on screen.")
end
_ZOOM(60)
TOTW=(_WY(EWL)-_WY(WWL))/2
ignition()
susp()
glever()
gearbox()
constants()
transmission()
shifter()
stoplight()
if IGN==1 then
GEFF=0
end
convertible()
end

function ignition()
if CLUTCH==0 then
IGN=math.mod(IGN+_KEYDOWN(4),2)
end
if IGN==1 and R*TOTW < 23/100 and CLUTCH > 900 then
IGN=0
end
if IGN==0 and R*TOTW >= 23/100 and CLUTCH > 900 and GEAR > 1 then
IGN=1
end
end

function susp()
SPR=1/4
DMP=1/5
end

function glever()
if CLUTCH == 0 and _KEY(0) == 0 then
GEAR=math.mod(GEAR+_KEYDOWN(15)-_KEYDOWN(8),5)
end
end

function gearbox()
if GEAR==0 then
OMG=1543/100
G=1
R=-1
BACK=BACK2
elseif GEAR==1 then
OMG=1543/100
G=1
R=1
elseif GEAR==2 then
OMG=3086/100
G=2
R=1
elseif GEAR==3 then
OMG=4630/100
G=3
R=1
elseif GEAR==4 then
OMG=6173/100
G=4
R=1
elseif GEAR==5 then
OMG=15432/100
G=5
R=1
else
OMG=300000/100
G=6
R=1
end
end

function constants()
A=MAXPOW/(D+G)
B=MAXPOW*N/((N-1)*OMG)*(1-1/(D+G))*(3/2*FLOUT-MAXPOW/2)/MAXPOW
C=-MAXPOW/((N-1)*math.pow(OMG,N))*(1-1/(D+G))*(FLOUT/MAXPOW)
end

function transmission()
ENGINE=IGN*R*(A+B*R*TOTW+C*math.pow(R*TOTW,5))*CLUTCH/1000
end

function shifter()

 if TOTW < OMG and ENGINE < 2*MAXPOW*FLOUT/MAXPOW/3 then
 GCOL=DCOL2
 elseif TOTW > OMG and ENGINE < 2*MAXPOW*FLOUT/MAXPOW/3 and G < 4 then
 GCOL=DCOL3
 else
 GCOL=DCOL1
 end
end

function stoplight()
if _KEY(7) > 0 then
STOP=STOP2
end
end


function convertible()

 ROOF=math.mod(ROOF+_KEYDOWN(14),2)

 if ROOF == 0 then
 CAPOTE1=CAPOTE1+1
 CAPOTE2=CAPOTE2-1
 CAPOTE3=CAPOTE3+2
 CAPOTE5=CAPOTE5-1
 end

 if CAPOTE1 > -61 and ROOF == 0 then
 CAPOTE4=CAPOTE4-1
 end

 if ROOF == 1 then
 CAPOTE4=CAPOTE4+1
 end

 if CAPOTE4 > 178 and ROOF == 1 then
 CAPOTE1=CAPOTE1-1
 CAPOTE2=CAPOTE2+1
 CAPOTE3=CAPOTE3-2
 CAPOTE5=CAPOTE5+1
 end
end
}

Model A Competizione:




Code:
Val
{
 Brake(default=0,min=0,max=380,step=380,disp=0)
 HBrake(default=0,min=0,max=500,step=500,disp=0)
 HandleF(default=0,min=-45,max=45,step=5,disp=0)
 HandleR(default=0,min=-36,max=36,step=5,disp=0)
 Engine(default=0,min=-3500,max=3500,disp=1)
 Flout(default=0,min=0,max=3500,step=1750,disp=1)
 MAXPOW(default=3500, disp=0)
 IGN(disp=1)
 Clutch(default=1000, max=1000, min=0, step=10, disp=1)
 Gear(default=1, min=0, max=4, step=0,disp=0)
 OMG(default=0, disp=0)
 G(default=0, disp=0)
 N(default=5, disp=0)
 D(default=2, disp=0)
 R(default=1, min=-1, disp=0)
 A(disp=0)
 B(min=-1000000, disp=0)
 C(min=-1, disp=0)
 Stop(default=#9090,step=100000,disp=0)
 Stop2(default=#0000,disp=0)
 Back(default=#ffff,step=100000,disp=0)
 BAck2(default=#0000,disp=0)
 SPR(disp=0)
 DMP(disp=0)
 Int(default=#604000, disp=0)
 Col2(default=#ffffaa, disp=0)
 Col1(default=#003c20, disp=0)
 Extr(default=#000000, disp=0)
 GCOL(default=#ffffff, step=1000000000, disp=1)
 GEFF(default=#ffff, step=1000000000, disp=1)
 DCOL1(default=#00ff00, disp=0)
 DCOL2(default=#aaaa00, disp=0)
 DCOL3(default=#ff0000, disp=0)
 
}
Key
{
 0:Flout(step=500),Smoke(step=1)
 2:HandleR(step=-2)
 3:HandleR(step=2)
 7:Brake(step=5),HBrake(step=5)
 9:HBrake(step=100)
 16:Clutch(step=-1000)
}
Body {
 Core(){

 N:Frame(option=1){E:RudderF(angle=121, option=1){E:RudderF(angle=-121, option=1){
 N:Frame(angle=175, option=1){N:Frame(angle=-165, option=1){
 N:Frame(angle=80, option=1){N:Frame(angle=-90, option=1){N:Frame(option=1){

 E:Cowl(angle=-120, option=1){E:Cowl(angle=140, color=Col1){E:Cowl(angle=120, color=Col1){}}
 E:Cowl(angle=120, effect=#ffff){S:Cowl(angle=90, color=Col1){E:Cowl(angle=-90, color=Col1){E:Cowl(color=Col1){}}
 N:Cowl(angle=-150, color=Int){}N:Cowl(angle=-30, effect=#a000){E:Cowl(angle=-91,option=3, effect=#a000){}}
 S:Cowl(angle=-90, color=Extr){S:Cowl(color=Extr){}}}}}
 W:Cowl(angle=-120, option=1){W:Cowl(angle=140, color=Col1){W:Cowl(angle=120, color=Col1){}}
 W:Cowl(angle=120, effect=#ffff){S:Cowl(angle=90, color=Col1){W:Cowl(angle=-90, color=Col1){W:Cowl(color=Col1){}}
 N:Cowl(angle=-150, color=Int){}
 N:Cowl(angle=-149, option=2, effect=GEFF, color=GCOL){}
 N:Cowl(angle=-30, effect=#a000){W:Cowl(angle=-91, option=4, effect=#a000){}}
 S:Cowl(angle=-90, color=Extr){S:Cowl(color=Extr){}}}}}

 N:Weight(option=1, color=Extr){

 E:Cowl(angle=-120, option=1){
 E:Cowl(angle=140, color=Col1){E:Cowl(angle=120, color=Col1){}
 N:Cowl(angle=175, color=#202020){N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){
 N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){N:Cowl(angle=-170, color=#202020){
 N:Cowl(angle=170, color=#202020){N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){}}}}}}}}}}}
 W:Cowl(angle=-120, option=1){
 W:Cowl(angle=140, color=Col1){W:Cowl(angle=120, color=Col1){}
 N:Cowl(angle=175, color=#202020){N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){
 N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){N:Cowl(angle=-170, color=#202020){
 N:Cowl(angle=170, color=#202020){N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){}}}}}}}}}}}

 E:Frame(option=1){

 N:Cowl(angle=-150, option=1){}

 E:RudderF(angle=HandleR, option=1){N:Frame(angle=160, spring=SPR, damper=DMP, option=1){
 W:Wheel(angle=89, brake=Brake, option=1, effect=2, color=0){}}}}
 W:Frame(option=1){

 N:Cowl(angle=-150, option=1){}

 W:RudderF(angle=HandleR, option=1){N:Frame(angle=160, spring=SPR, damper=DMP, option=1){
 E:Wheel(angle=89, brake=Brake, option=1, effect=2, color=0){}}}}}}
 S:Frame(option=1){S:Frame(option=1){S:Frame(option=1){

 E:Cowl(angle=-120, option=1){E:Cowl(angle=120, color=Col1){N:Cowl(angle=60, color=Int){}
 S:Cowl(option=3, color=Col1){}E:Cowl(angle=90, color=Col1){
 E:Cowl(angle=90, color=Extr){S:Cowl(option=4, color=Extr){}}
 N:Cowl(color=Col1){E:Cowl(angle=90, color=Extr){}}S:Cowl(angle=44, option=2, color=#aa0000, effect=Stop){}
 S:Cowl(angle=45, color=Col1){S:Cowl(angle=70, color=Col1){}S:Cowl(angle=68, effect=Back){}}}}}
 W:Cowl(angle=-120, option=1){W:Cowl(angle=120, color=Col1){N:Cowl(angle=60, color=Int){}
 S:Cowl(option=4, color=Col1){}W:Cowl(angle=90, color=Col1){
 W:Cowl(angle=90, color=Extr){S:Cowl(option=3, color=Extr){}}
 N:Cowl(color=Col1){W:Cowl(angle=90, color=Extr){}}S:Cowl(angle=44, option=2, color=#aa0000, effect=Stop){}
 S:Cowl(angle=45, color=Col1){S:Cowl(angle=70, color=Col1){}S:Cowl(angle=68, effect=Back){}}}}}

 E:Frame(option=1){

 N:Cowl(angle=-150, option=1){}

 N:Frame(angle=160, spring=SPR, damper=DMP, option=1){
 E:Wheel(name=EWL, angle=91, power=Engine, brake=HBrake, option=1, effect=2, color=0){}}}
 W:Frame(option=1){

 N:Cowl(angle=-150, option=1){}

 N:Frame(angle=160, spring=SPR, damper=DMP, option=1){
 W:Wheel(name=WWL, angle=91, power=-Engine, brake=HBrake, option=1, effect=2, color=0){}}}
}}}
}}}}
}}}}}

Lua

{
function main()
-- 316.00 sec
if _KEY(6) == 1 then
out(0,"Instructions:")
out(2,"Up for throttle, Left and Right for steering")
out(4,"E is the Clutch: hold it down and press Z to switch on/off engine")
out(6,"Release Clutch when ready to go: beware, if you go too slow, the engine stalls!")
out(8,"To change gear, Lift the finger off the throttle, press the clutch, then W or S. This car has 4 gears + reverse.")
out(10,"The dashboard will light up in three colours: ")
out(12," Yellow if you are low on RPMs")
out(14," Green if you are in the high end of the power curve")
out(16," Red if you are over-revving the engine")
out(18,"A operates both brakes, D operates rear wheel brakes")
else
out(1,"Need Help? Press C to read instructions.")
out(3,"For your first runs, I suggest keeping the variables on screen.")
end
_ZOOM(60)
TOTW=(_WY(EWL)-_WY(WWL))/2
ignition()
susp()
glever()
gearbox()
constants()
transmission()
shifter()
stoplight()
if IGN==1 then
GEFF=0
end
end

function ignition()
if CLUTCH==0 then
IGN=math.mod(IGN+_KEYDOWN(4),2)
end
if IGN==1 and R*TOTW < 23/100 and CLUTCH > 900 then
IGN=0
end
if IGN==0 and R*TOTW >= 23/100 and CLUTCH > 900 and GEAR > 1 then
IGN=1
end
end

function susp()
SPR=1/4
DMP=1/5
end

function glever()
if CLUTCH == 0 and _KEY(0) == 0 then
GEAR=math.mod(GEAR+_KEYDOWN(15)-_KEYDOWN(8),5)
end
end

function gearbox()
if GEAR==0 then
OMG=1543/100
G=1
R=-1
BACK=BACK2
elseif GEAR==1 then
OMG=1543/100
G=1
R=1
elseif GEAR==2 then
OMG=3086/100
G=2
R=1
elseif GEAR==3 then
OMG=4630/100
G=3
R=1
elseif GEAR==4 then
OMG=6173/100
G=4
R=1
elseif GEAR==5 then
OMG=15432/100
G=5
R=1
else
OMG=300000/100
G=6
R=1
end
end

function constants()
A=MAXPOW/(D+G)
B=MAXPOW*N/((N-1)*OMG)*(1-1/(D+G))*(3/2*FLOUT-MAXPOW/2)/MAXPOW
C=-MAXPOW/((N-1)*math.pow(OMG,N))*(1-1/(D+G))*(FLOUT/MAXPOW)
end

function transmission()
ENGINE=IGN*R*(A+B*R*TOTW+C*math.pow(R*TOTW,5))*CLUTCH/1000
end

function shifter()

 if TOTW < OMG and ENGINE < 2*MAXPOW*FLOUT/MAXPOW/3 then
 GCOL=DCOL2
 elseif TOTW > OMG and ENGINE < 2*MAXPOW*FLOUT/MAXPOW/3 and G < 4 then
 GCOL=DCOL3
 else
 GCOL=DCOL1
 end
end

function stoplight()
if _KEY(7) > 0 then
STOP=STOP2
end
end
}

Model A Imola:




Code:
Val
{
 Brake(default=0,min=0,max=380,step=380,disp=0)
 HBrake(default=0,min=0,max=500,step=500,disp=0)
 HandleF(default=0,min=-45,max=45,step=5,disp=0)
 HandleR(default=0,min=-36,max=36,step=5,disp=0)
 Engine(default=0,min=-4000,max=4000,disp=1)
 Flout(default=0,min=0,max=4000,step=2000,disp=1)
 MAXPOW(default=4000, disp=0)
 IGN(disp=1)
 Clutch(default=1000, max=1000, min=0, step=10, disp=1)
 Gear(default=1, min=0, max=5, step=0,disp=1)
 OMG(default=0, disp=0)
 G(default=0, disp=0)
 N(default=5, disp=0)
 D(default=2, disp=0)
 R(default=1, min=-1, disp=0)
 A(disp=0)
 B(min=-1000000, disp=0)
 C(min=-1, disp=0)
 Stop(default=#9090,step=100000,disp=0)
 Stop2(default=#0000,disp=0)
 Back(default=#ffff,step=100000,disp=0)
 BAck2(default=#0000,disp=0)
 SPR(disp=0)
 DMP(disp=0)
 Int(default=#604000, disp=0)
 Col1(default=#800000, disp=0)
 Col2(default=#003c20, disp=0)
 Extr(default=#000000, disp=0)
 GCOL(default=#ffffff, step=1000000000, disp=0)
 GEFF(default=#ffff, step=1000000000, disp=0)
 DCOL1(default=#00ff00, disp=0)
 DCOL2(default=#aaaa00, disp=0)
 DCOL3(default=#ff0000, disp=0)
 
}
Key
{
 0:Flout(step=500),Smoke(step=1)
 2:HandleR(step=-2)
 3:HandleR(step=2)
 7:Brake(step=5),HBrake(step=5)
 9:HBrake(step=100)
 16:Clutch(step=-1000)
}
Body {
 Core(){

 N:Frame(option=1){E:RudderF(angle=121, option=1){E:RudderF(angle=-121, option=1){
 N:Frame(angle=175, option=1){N:Frame(angle=-165, option=1){
 N:Frame(angle=80, option=1){N:Frame(angle=-90, option=1){N:Frame(option=1){

 E:Cowl(angle=-120, option=1){E:Cowl(angle=140, color=Col1){E:Cowl(angle=120, color=Col1){}}
 E:Cowl(angle=120, effect=#ffff){S:Cowl(angle=90, color=Col1){E:Cowl(angle=-90, color=Col1){E:Cowl(color=Col1){}}
 N:Cowl(angle=-90, color=Col1){N:Cowl(color=Col1){}}
 S:Cowl(angle=-90, color=Extr){S:Cowl(color=Extr){}}}}}
 W:Cowl(angle=-120, option=1){W:Cowl(angle=140, color=Col1){W:Cowl(angle=120, color=Col1){}}
 W:Cowl(angle=120, effect=#ffff){S:Cowl(angle=90, color=Col1){W:Cowl(angle=-90, color=Col1){W:Cowl(color=Col1){}}
 N:Cowl(angle=-150, color=Int){}
 N:Cowl(angle=-149, option=2, effect=GEFF, color=GCOL){}
 N:Cowl(angle=-50, effect=#a000){E:Cowl(angle=-91,option=3, effect=#a000){}W:Cowl(angle=-91, option=4, effect=#a000){}}
 S:Cowl(angle=-90, color=Extr){S:Cowl(color=Extr){}}}}}

 N:Weight(option=1, color=Extr){

 E:Cowl(angle=-120, option=1){
 E:Cowl(angle=140, color=Col1){E:Cowl(angle=120, color=Col1){}
 N:Cowl(angle=175, color=#202020){N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){
 N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){N:Cowl(angle=-170, color=#202020){
 N:Cowl(angle=170, color=#202020){N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){}}}}}}}}}}}
 W:Cowl(angle=-120, option=1){
 W:Cowl(angle=140, color=Col1){W:Cowl(angle=120, color=Col1){}
 N:Cowl(angle=175, color=#202020){N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){
 N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){N:Cowl(angle=-170, color=#202020){
 N:Cowl(angle=170, color=#202020){N:Cowl(angle=-170, color=#202020){N:Cowl(angle=170, color=#202020){}}}}}}}}}}}

 E:Frame(option=1){

 N:Cowl(angle=-150, option=1){}

 E:RudderF(angle=HandleR, option=1){N:Frame(angle=160, spring=SPR, damper=DMP, option=1){
 W:Wheel(angle=89, brake=Brake, option=1, effect=2, color=0){}}}}
 W:Frame(option=1){

 N:Cowl(angle=-150, option=1){}

 W:RudderF(angle=HandleR, option=1){N:Frame(angle=160, spring=SPR, damper=DMP, option=1){
 E:Wheel(angle=89, brake=Brake, option=1, effect=2, color=0){}}}}}}
 S:Frame(option=1){S:Frame(option=1){
 S:Chip(angle=-2, color=Extr){}
 S:Frame(option=1){

 E:Cowl(angle=-120, option=1){E:Cowl(angle=120, color=Col1){
 N:Cowl(color=Col1){W:Cowl(angle=90, color=Col1){N:Cowl(color=Col1){N:Cowl(color=Col1){}}}}
 S:Cowl(option=3, color=Col1){}E:Cowl(angle=90, color=Col1){
 E:Cowl(angle=90, color=Extr){S:Cowl(option=4, color=Extr){}}
 N:Cowl(color=Col1){E:Cowl(angle=90, color=Extr){}}S:Cowl(angle=44, option=2, color=#ff0000, effect=Stop){}
 S:Cowl(angle=45, color=Col1){S:Cowl(angle=70, color=Col1){}S:Cowl(angle=68, effect=Back){}}}}}
 W:Cowl(angle=-120, option=1){W:Cowl(angle=120, color=Col1){N:Cowl(angle=60, color=Int){}
 S:Cowl(option=4, color=Col1){}
 S:Cowl(angle=-140, color=Col1){S:Cowl(angle=-110, color=Int){}
 E:Cowl(angle=-91, option=5, color=Col1){}W:Cowl(angle=-91, option=5, color=Col1){}}
 W:Cowl(angle=90, color=Col1){
 W:Cowl(angle=90, color=Extr){S:Cowl(option=3, color=Extr){}}
 N:Cowl(color=Col1){W:Cowl(angle=90, color=Extr){}}S:Cowl(angle=44, option=2, color=#ff0000, effect=Stop){}
 S:Cowl(angle=45, color=Col1){S:Cowl(angle=70, color=Col1){}S:Cowl(angle=68, effect=Back){}}}}}

 E:Frame(option=1){

 N:Cowl(angle=-150, option=1){}

 N:Frame(angle=160, spring=SPR, damper=DMP, option=1){
 E:Wheel(name=EWL, angle=91, power=Engine, brake=HBrake, option=1, effect=4, color=0){}}}
 W:Frame(option=1){

 N:Cowl(angle=-150, option=1){}

 N:Frame(angle=160, spring=SPR, damper=DMP, option=1){
 W:Wheel(name=WWL, angle=91, power=-Engine, brake=HBrake, option=1, effect=4, color=0){}}}
}}}
}}}}
}}}}}

Lua

{
function main()
if _KEY(6) == 1 then
out(0,"Instructions:")
out(2,"Up for throttle, Left and Right for steering")
out(4,"E is the Clutch: hold it down and press Z to switch on/off engine")
out(6,"Release Clutch when ready to go: beware, if you go too slow, the engine stalls!")
out(8,"To change gear, Lift the finger off the throttle, then W or S. This car has 5 gears + reverse.")
out(10,"The dashboard will light up in three colours: ")
out(12," Yellow if you are low on RPMs")
out(14," Green if you are in the high end of the power curve")
out(16," Red if you are over-revving the engine")
out(18,"A operates both brakes, D operates rear wheel brakes")
else
out(1,"Need Help? Press C to read instructions.")
out(3,"For your first runs, I suggest keeping the variables on screen.")
end
_ZOOM(60)
TOTW=(_WY(EWL)-_WY(WWL))/2
ignition()
susp()
glever()
gearbox()
constants()
transmission()
shifter()
stoplight()
if IGN==1 then
GEFF=0
end
end

function ignition()
if CLUTCH==0 then
IGN=math.mod(IGN+_KEYDOWN(4),2)
end
if IGN==1 and R*TOTW < 23/100 and CLUTCH > 900 then
IGN=0
end
if IGN==0 and R*TOTW >= 43/100 and CLUTCH > 900 and GEAR > 1 then
IGN=1
end
end

function susp()
SPR=1/3
DMP=1/5
end

function glever()
if _KEY(0) == 0 then
GEAR=math.mod(GEAR+_KEYDOWN(15)-_KEYDOWN(8),6)
end
end

function gearbox()
if GEAR==0 then
OMG=3086/100
G=1
R=-1
BACK=BACK2
elseif GEAR==1 then
OMG=3086/100
G=1
R=1
elseif GEAR==2 then
OMG=6173/100
G=2
R=1
elseif GEAR==3 then
OMG=9259/100
G=3
R=1
elseif GEAR==4 then
OMG=12346/100
G=4
R=1
elseif GEAR==5 then
OMG=15432/100
G=5
R=1
else
OMG=300000/100
G=6
R=1
end
end

function constants()
A=MAXPOW/(D+G)
B=MAXPOW*N/((N-1)*OMG)*(1-1/(D+G))*(5/4*FLOUT-MAXPOW/4)/MAXPOW
C=-MAXPOW/((N-1)*math.pow(OMG,N))*(1-1/(D+G))*(FLOUT/MAXPOW)
end

function transmission()
ENGINE=IGN*R*(A+B*R*TOTW+C*math.pow(R*TOTW,5))*CLUTCH/1000
end

function shifter()

 if TOTW < OMG and ENGINE < 2*MAXPOW*FLOUT/MAXPOW/3 then
 GCOL=DCOL2
 elseif TOTW > OMG and ENGINE < 2*MAXPOW*FLOUT/MAXPOW/3 and G < 5 then
 GCOL=DCOL3
 else
 GCOL=DCOL1
 end
end

function stoplight()
if _KEY(7) > 0 then
STOP=STOP2
end
end
}

Instructions are in game, press "C" to show.

I suggest to use the car from Ctrl+F10 view (that is, from inside), for better use of the dashboard lighs.



if you are interested, here is how I created the power curves:
Some math:

Rigidchips provides "power as imput for the wheels. This makes sense: if the power parameter was actually torque (even divided by 6 as it happens with jets) a simple model with power = 1000 would tear up the road with no grip (that torque figure is plausible on a lorry, or on a very powerful, large displacement engined sportscar).

I defined the shape of my desired power curve:

1 - at zero angular velocity of the wheel, it should be a fraction of the maximum power (wrong in principle, right if we consider how RC computes torque from power)

2 - at a certain angular velocity of the wheel, the power output shall be at its maximum, and the curve flat.

3 - the curve shall plummet at angular velocities above the one chosen at step 2.

I constructed a curve with this structure:

Pwr(w) = A + B*w + C*w^N

where

Pwr is the power, w is the angular velocity, N is an integer of choice and A, B, C are constants to be determined.

step 3 is verified when C is negative and N greater than 1.

the other two conditions give actually three equations:

MaxPwr = A + B*wgr + C * wgr^N       -> Maximum power at design wheel angular velocity wgr

MaxPwr/D = A      -> Idle power, where D is a real number greather than one

0 = B + N*C*wgr^(N-1)       -> Power curve is flat @ wgr

the results are:

A = MaxPwr/D,   B = N*MaxPwr*(1-1/D)/((N-1)*wgr),   C = -MaxPwr*(1-1/D)/((N-1)*wgr^N)

By assigning different wgr values, one for each gear, we can plot the power curves, here shown for the 6-speed gearbox of the Panauto Model B Coupé:



Once the curves are defined, it is necessary to make them throttleable, by means of direct proportionality to a function of the throttle command.

How to change your gearbox:

That being said, if you don't like how the car behaves, of just want to try a new gear setting, here is what you may modify:

1 - inside the LUA, despite the Imola having only 5 speeds and the other two only 4, you will find a 6-speed layout. Just modify the math.mod value and the max gear value in Val Block
2 - for every gear, change the OMG parameter (wgr in the previous spoiler). Shorter gears will allow for faster accelleration, longer gears may reach higher speeds.
3 - modify the Maximum Power MAXPOW variable, along with maxiumu FLOUT and maximum ENGINE
4 - You could change the exponential N to have a leaner or sharper power curve. Unfortunately, there seems to be a bug in my code, for which the gearbox works properly only for N = 5

Have fun!
avatar
Echo_Delta_Oscar
Hover
Hover

Posts : 105
Join date : 2011-03-24

View user profile

Back to top Go down

Re: Panauto Model A + Competizione + Imola

Post by JosefYurnov99 on Sun Jun 05, 2016 3:57 pm

This is possibly the coolest manual transmission I've ever seen for RC. The fact that there's a clutch makes it so much fun! Very Happy
avatar
JosefYurnov99
Plane
Plane

Posts : 43
Join date : 2011-03-11
Age : 21
Location : America

View user profile

Back to top Go down

Re: Panauto Model A + Competizione + Imola

Post by Echo_Delta_Oscar on Mon Jun 06, 2016 3:41 pm

Next step: equally spaced gearboxes.

I am trying to find a way to have the lua compute the ideal gear change regime and display it n the dashboard. Right now it is only a rough estimate, based on the ratio between available and nominal power and wheter or not the wheels are rotating above or below design speed. That may be featured on either the Model A Monza or the Model B Salt Lake.
avatar
Echo_Delta_Oscar
Hover
Hover

Posts : 105
Join date : 2011-03-24

View user profile

Back to top Go down

Re: Panauto Model A + Competizione + Imola

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum