Jump to content

kilman54

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by kilman54

  1. This should work for radar in all cases. set altAGL to alt:radar. if altAGL < 0 or altitude < altAGL { set altAGL to altitude. }.
  2. SMA, You would get more accurate fuel values if you activate the asparagus stages first, check the fuel, then active the main engine - all before launch. Assuming all asparagus stages are identical: set acount to 3. // How many stages are asparagus. set totalfuel to <liquidfuel>. stage. wait 1. //all asparagus stages activated but not main engine. set aspfuel to stage:liquidfuel. //total fuel in the 3 stages set eachstagefuel to aspfuel /acount. stage. //main engine start and clamp release lock throttle to 1. set x to acount. set spentstages to 0. until x = 0 { set currenttotal to <liquidfuel> if currenttotal < (totalfuel-(eachstagefuel *(spentstages+1)) { stage. set x to spentstages+1. set spentstages to acount-x. }. }. Obviously, you have to adjust to include launch code, like the gravity turn but it's a start!
  3. TMS, Lock statements don't work inside programs except for the throttle. Also, I suggest always using lowercase letters except inside a print quotation as it sometimes bugs out. Since steering does not actually lock, you have to create an until loop to continuously lock the steering to the new value. You would also run your general burn loop inside the same until. clearscreen. set closeprogram to 0. set yaw to 0. set pitch to 90. set roll to 0. set inittime to missiontime. set vardirection to up + r(yaw,pitch,roll). lock steering to vardirection. until closeprogram = 0 { set newtime to missiontime. if (newtime-inittime)>5 { set pitch to -90. }. set vardirection to up + r(yaw,pitch,roll). lock steering to vardirection. print "Steering is Y:" + steering:yaw + " P:" + steering:pitch + " R:" + steering:roll at (0,0). if Some Condition { set closeprogram to 1. }. }.
  4. I froze KSP! I tested it and it will freeze a fresh kOS. This should give a Syntax error. Set DirectionX to R(100,100,100. razark, I had the same problem when creating programs to use as resusable functions. It isn't just THROTTLE or STEERING, it is other LOCK variables as well. Code example 1: Only THROTTLE lock inherits from parent Set x to 1. lock throttle to x. // causes throttle to 100% lock y to x. run ProgA. set x to 0.5. // throttles down to 50%. print y. // prints "1" not "0.5" as expected print throttle. //prints "0.5" as expected Program Ended. print y. // prints 0.5 as expected //throttle remains at 50% I am thinking that THROTTLE is passed as a reference (pointer) and easily inherits the LOCK from the parent program (or kOS console). Other LOCK variables are passed as a value instead of a reference. Once out of the program, the LOCK returns to normal in the parent that originally LOCKed the variable. Code example 2: No lock inherits from child run ProgB. Set x to 1. LOCK THrottle to x. //Throttle to 100% LOCK y to x. run ProgC. set x to 0.5. //Throttle to 50% print y. //Prints 1 - expected 0.5 Program Ended. print y. //prints 0.5 as expected Program Ended. //Throttle value remains 1 but returns to 0% set x to 0.75. // Throttle remains at 0%. print y. //prints 0.5 - expected 0.75. It appears that LOCKs made in a child program are converted to SET variables when it returns to the parent program (or console).
×
×
  • Create New...