Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set steeringmanager:rollcontrolanglerange to 180.
- set proprad to 5.8.
- set rotormods to ship:modulesnamed("ModuleRoboticServoRotor").
- set rotors to list().
- for rm in rotormods {
- local rotor to lexicon().
- set rotor["part"] to rm:part.
- set rotor["mod"] to rm.
- set rotor["blades"] to list().
- for bm in rm:part:ModulesNamed("ModuleControlSurface") {
- set bladepart to bm:part.
- local blade to lexicon().
- set blade["mod"] to bm.
- set blade["offset"] to vdot(-bladepart:Facing:starvector, bladepart:position - bladepart:parent:position).
- set blade["proprad"] to proprad.
- bm:setfield("deploy", true).
- rotor["blades"]:add(blade).
- }
- rotors:add(rotor).
- //preflight checks
- if rotor:part:parent:name:contains("bay") {
- set baymod to rotor:part:parent:getmodule("ModuleAnimateGeneric").
- if baymod:hasevent("open") baymod:doevent("open").
- }
- rm:setfield("rpm limit",0).
- rm:setfield("brake",0).
- rm:setfield("motor",1).
- rm:setfield("torque limit(%)", 100).
- }
- set first to true.
- set tarbladeaoa to 4.5.
- set deploycopy to 9.
- Fuelcells on.
- //Lock Vars
- set rpmtarget to min(459,max(0, throttle * 460)).
- //Control Loop
- set LoopHz to 10.
- on round(time:seconds * LoopHz ) {
- set rpmtarget to min(459,max(0, throttle * 460)).
- set rpmcopy to rpmtarget.
- for rotor in rotors {
- local currrpm to rpmcopy.
- rotor:mod:setfield("rpm limit", rpmcopy ).
- set calcAirspeed to (2 * constant:pi * (rotor:blades[0]:proprad + rotor:blades[0]:offset) * currrpm/60).
- set deploycopy to max(3, tarbladeaoa + arctan2(airspeed, calcAirspeed)).
- for blade in rotor:blades {
- blade:mod:setfield("deploy angle", deploycopy).
- }
- }
- return first.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement