Dunbaratu Posted September 6, 2013 Share Posted September 6, 2013 You can. The IF condition is the thing you want to respond to, and the UNTIL condition is for when you're done caring about the IF condition.until stage:liquidfuel < 50 { if alt:radar < 200 { lock throttle to 1. }. if alt:radar > 1000 { lock throttle to 0.}.}.That isn't the same. It requires putting all your logic in one loop that blocks all other code from running, instead of starting a recurring check in the background and then going on to do other things. The WHEN is the one and only place in the scripting language that allows you to break out a little bit from the single-thread style of thinking. Link to comment Share on other sites More sharing options...
TMS Posted September 6, 2013 Share Posted September 6, 2013 Is there an easy way of getting kOS to return the current number of stages you have in your vessel? Link to comment Share on other sites More sharing options...
Dunbaratu Posted September 7, 2013 Share Posted September 7, 2013 Accessing the elements of a vector will also be essential for calculating the magnitude.Edit: It's revealed in the 0.4 video (and apparently nowhere else) you can do X:pitch, X:roll, and X:yaw on R() structures. No word on V().print prograde:pitch.0.01print velocity:pitch.unrecognized term: 'velocity:x'.Nope. Too bad. That would actually be useful. It works ONLY on R() vectors and not velocity. I don't know what it is about velocity but despite having 3 numbers when you print it out, it doesn't seem to behave like other vectors like prograde.On an unrelated note. Has anyone else had problems with the text suddenly going invisible?I tried this to see what it would do, knowing it probably wouldn't work to add a vector to a scalar:print velocity + 1.and the cursor became invisible and the mod started acting all wonky. Link to comment Share on other sites More sharing options...
curiousepic Posted September 7, 2013 Share Posted September 7, 2013 (edited) I know if you revert flight and the console is still open, any text you input will be blank. Never had it happen during a flight though.Still looking for a way to round off numbers with long decimals... is there some simple arithmetic way without needing a built in round() function? Or just to restrict the number of digits returned? Edited September 7, 2013 by curiousepic Link to comment Share on other sites More sharing options...
Sma Posted September 7, 2013 Share Posted September 7, 2013 (edited) I just started playing with this mod today, only about an hour or two maybe. I did have problems with it not locking the inputs while typing in the window, but I soon found out it was conflicting somehow with remotech, well remotech 2 (the playtesting version, not full release, which isn't available yet, just to be clear, being as that some don't get that it seems).Currently working on an orbit program. Right now just testing it with infinite fuel, but will eventually see if I can come up with one that works regardless of the number of stages. Guess I'll have to figure out a way to detect when stages burn out some how. Right now though I'm having problems with the ap going WAY above what I want it to before the PE gets to where I want. Right now I'm trying different levels of thrust, and I may try changing the thrust and pitch if the ap goes above a certain level. Was also thinking of maybe trying a while loop to circularize. Either way, it's fun playing around with it. Just wish I didn't have to "remove" RT2 to get it to work.EDIT: Right...just saw this in the GIT page for stages: STAGE:LIQUIDFUEL and STAGE:OXIDIZER That'll help Was just trying a "until" loop, but as soon as it got to it, it threw an error. I saw that someone else was having this problems with nested if statements. I'll have to go back and see if i can find the post about that. This sort of reminds me when I grew up programming on C64 and Atari 2600, then IBM PC Jr (8086cpu with a switch that switched it to 286), then a stand alone 286 (with and without mathco) with a whopping 20mb hd, then on to 386, 486dx4 I think and then they quit calling them by those names. Good times.EDIT 2: SMH... As is usually the case in programing, I forgot the line terminator "." in this case lol. Lately I've been doing PHP so I'm use to using ; guess I should get use to using . Edited September 7, 2013 by Sma Link to comment Share on other sites More sharing options...
Panichio Posted September 7, 2013 Share Posted September 7, 2013 Except he's not using <liquidfuel>, he's using stage:liquidfuel, which should work.Panichio:Try:wait until stage:liquidfuel < 0.01.Yeah, that didn't work. Trust me, I've tried every number imaginable in that place and they have not worked. There is something else going on here, but I don't know what it is. The numbers don't seem to be the problem. Link to comment Share on other sites More sharing options...
KevinLaity Posted September 7, 2013 Author Share Posted September 7, 2013 print prograde:pitch.0.01print velocity:pitch.unrecognized term: 'velocity:x'.Nope. Too bad. That would actually be useful. It works ONLY on R() vectors and not velocity. I don't know what it is about velocity but despite having 3 numbers when you print it out, it doesn't seem to behave like other vectors like prograde.On an unrelated note. Has anyone else had problems with the text suddenly going invisible?I tried this to see what it would do, knowing it probably wouldn't work to add a vector to a scalar:print velocity + 1.and the cursor became invisible and the mod started acting all wonky.Getting :X :Y and :Z from a vector will happen. Add it to the giant list of things that need to be done. Link to comment Share on other sites More sharing options...
KevinLaity Posted September 7, 2013 Author Share Posted September 7, 2013 This sort of reminds me when I grew up programming on C64 and Atari 2600, then IBM PC Jr (8086cpu with a switch that switched it to 286), then a stand alone 286 (with and without mathco) with a whopping 20mb hd, then on to 386, 486dx4 I think and then they quit calling them by those names. Good times.Exactly what I was going for, in fact that is the original C64 font. Link to comment Share on other sites More sharing options...
KevinLaity Posted September 7, 2013 Author Share Posted September 7, 2013 Is there an easy way of getting kOS to return the current number of stages you have in your vessel?You would think this would be easy to find in the KSP assembly. What I did find was surprisingly difficult to understand. If somebody does know how to get the simple number of stages I'll add it in. Link to comment Share on other sites More sharing options...
Payload Posted September 7, 2013 Share Posted September 7, 2013 You would think this would be easy to find in the KSP assembly. What I did find was surprisingly difficult to understand. If somebody does know how to get the simple number of stages I'll add it in.Kevin do you plan on allowing us to check against a string? such as...If body = "Kerbin" { do something. }.That would really help. Also It would allow us to use all of those status flags. Link to comment Share on other sites More sharing options...
Kainne Posted September 7, 2013 Share Posted September 7, 2013 (edited) Kevin,I was wondering how you structured the longitude coordinate system. My observations have shown that the coordinates change value seemingly at random. I'm sure there is an order I'm not perceiving, or perhaps the program is conflicting with some of the mods I have, but if you could set me straight that would be awesome. Right now I've got mechjeb and kethane, both showing me coordinates that agree with one another, and KOS seems to deviate by either 360, or 180 from these standard points. However, occasionally KOS will jump to a different variation of the angle it's measuring, and I haven't figured why. If you could shed some light on this puzzle, it would be much appreciated. I think this mod is great and I would love to use it to coordinate reentry programs with ground coordinates.Edit: I tried making a program that compensated for variation in the numerical angle designation but kept the true angle the same and it caused ksp to crash lol. here's the program:clearscreen.set k to -245.58.set i to -65.58.set p to 6.28*( (altitude+600000)^3/(3.5316*10^12))^0.5.set x to 0.5.set y to 0.482.set a to (x*p)/60.set b to (a*p)/360.set d to x*(p+b)/60.set tVal to 0.lock throttle to tVal.if apoapsis > 105000 {wait until (longitude > i and longitude < i+1) or(longitude > i+360 and longitude < i+361).if longitude > i and longitude < i+1 {wait until longitude > i and longitude < i+1.lock steering to retrograde.print "go for altitude change.".until periapsis < 96000 {wait until longitude > i+d and longitude < (i+d)+1.if longitude > i+d { set tVal to 1.}.if periapsis < 97000 {set tVal to 0.print "altitude change complete.".}.}.}.if longitude > i+360 and i+361 {wait until longitude > i+360 and longitude < i+361.lock steering to retrograde.print "go for altitude change.".until periapsis < 96000 {wait until longitude > (i+360)+d and longitude < (i+361)+d.if longitude > (i+360) {set tVal to 1.}.if periapsis < 97000 {set tVal to 0.print "altitude change complete.".}.}.}.}.set x to y.print "coasting to deorbit coordinates.".wait until (longitude > k and longitude < k+1) or (longitude > k+360 and longitude < k+361).if longitude > k and longitude < k+1 {wait until longitude > k and longitude < k+1.lock steering to retrograde.clearscreen.print "go for deorbit burn.".until periapsis < 1 {if longitude > k+d and periapsis > 1 {set tVal to 1.clearscreen.print "initiating deorbit burn.".}.}.}.if longitude > k+360 and longitude < k+361 {wait until longitude > k+360 and longitude < k+361.lock steering to retrograde.clearscreen.print "go for deorbit burn.".until periapsis < 1 {if longitude > (k+360)+d and periapsis > 1 {set tVal to 1.clearscreen.print "initiating deorbit burn.".}.}.}.if periapsis < 1 {set tVal to 0.lock steering to prograde + R(0,5,0).print "deorbit burn complete.".}.As you can see, it relies on longitude for it's calculations, but I can't get it to work with KSP's wonky longitude system. Any help would be much appreciated. Edited September 7, 2013 by Kainne Link to comment Share on other sites More sharing options...
Sma Posted September 7, 2013 Share Posted September 7, 2013 Exactly what I was going for, in fact that is the original C64 font.Ahh, nice. Didn't really notice at first, but I guess that explains why it feels a little familur. Now, if only there was some reason to use ",8,1" or....like I had wished back then ",8,2". Never really had a chance to daisy chain the drives together. I also wanted the Spartan II expansion thing for C64, but that never happened, and neither did getting a C128. lol I'm sure there is one or 2 c64's lurking around my parents somewhere...wonder if they still work. Though I imagine the disks have been corrupted by now, and that's if the belts in the drive units haven't deteriorated. Link to comment Share on other sites More sharing options...
KevinLaity Posted September 7, 2013 Author Share Posted September 7, 2013 Kevin do you plan on allowing us to check against a string? such as...If body = "Kerbin" { do something. }.That would really help. Also It would allow us to use all of those status flags.Yes, I do plan on it especially since you can already concatenate with +, it just makes sense Link to comment Share on other sites More sharing options...
Dunbaratu Posted September 7, 2013 Share Posted September 7, 2013 Are there any plans to adjust the speed with which lines execute, or is it meant to be very slow on purpose? I've been having difficulty trying to write a program to hover a craft in place because it only seems to be able to run a loop maybe 3 times a second or so and that's not precise enough to respond in time to the inputs. The best I can manage is a thing that bobbles up and down wobbly covering an altitude range of about 40 meters. Once it eventually settles down it does seem to dampen to a wobble over 10 meters but that's the best I seem to be able to do.On an unrelated note, the only way I could find to make a negative number (say negative 5) was to subtract it from zero like so:set x to 0 - 5 .These don't work:set x to -5.set x to -1*5.set y to 5. set x to -y.set y to 5. set x to -1*y.I suppose that's a thing to add to that list - the ability to parse negative signs as unary operators rather than just as subtraction binary operators. Link to comment Share on other sites More sharing options...
Gaius Posted September 7, 2013 Share Posted September 7, 2013 (edited) Yeah, there seems to be a bug in the parser. The first three statements work fine, but the fourth causes an error.set pitch to 20.set pitch to -20.set pitch to 20 - (altitude / 1000).set pitch to -20 - (altitude / 1000).Unrecognized term: ''.// But this works:set pitch to (-20) - (altitude / 1000).// But this does not:set x to (-y).Unrecognized term: ''.Go figure... Edited September 7, 2013 by Gaius Link to comment Share on other sites More sharing options...
razark Posted September 7, 2013 Share Posted September 7, 2013 Yeah, that didn't work. Trust me, I've tried every number imaginable in that place and they have not worked. There is something else going on here, but I don't know what it is. The numbers don't seem to be the problem.Sorry, it was the only thing I could think of. The only other thing that comes to mind is a conflict with another mod or a bad install. Have you tried a clean install of kOS?Gaaah so much undocumented stuff here. (Call me an old school grognard but I really dislike the modern trend of people wanting to use video clips as the primary means of documenting how software works over using the written word. Looking things up in a video takes longer and it's harder to skim.)I can agree with this. Any volunteers to write the textbook/reference? Link to comment Share on other sites More sharing options...
TMS Posted September 7, 2013 Share Posted September 7, 2013 You would think this would be easy to find in the KSP assembly. What I did find was surprisingly difficult to understand. If somebody does know how to get the simple number of stages I'll add it in.I'm sure you'll get tired of hearing this... but Mechjeb appears to have some code in it that seems to understand it's current position in the staging process (as the ascent module allows you to specify at what stage the autopilot should stop at).I'm just wondering if there's inspiration within the source code? Link to comment Share on other sites More sharing options...
Dunbaratu Posted September 7, 2013 Share Posted September 7, 2013 Sorry, it was the only thing I could think of. The only other thing that comes to mind is a conflict with another mod or a bad install. Have you tried a clean install of kOS?I can agree with this. Any volunteers to write the textbook/reference?The project is hosted on GitHub, and one of the feaures of GitHub is to give each project a Wiki. If permissions were opened up for us to do it, we on this thread could communally work on populating that Wiki with documentation. Link to comment Share on other sites More sharing options...
TMS Posted September 7, 2013 Share Posted September 7, 2013 ^ Agreed, that's probably the best way of getting this thing fleshed out quickly. Link to comment Share on other sites More sharing options...
Dunbaratu Posted September 7, 2013 Share Posted September 7, 2013 Another thing the language could use that I just ran into:There's no way to abort the program other than trying to if-check around the whole thing. I wanted to put a check at the front of my script to say this:if maxthrust = 0 { print "ABORTING PROGRAM: No active engines right now.". print "Do not run until after you've started up the engines.". ...Crud what goes here? break? abort?...}.... rest of program continues on from here.There needs to be an "exit" or something like that. Or perhaps allow "break" outside a loop to mean exit. Link to comment Share on other sites More sharing options...
Ozin Posted September 7, 2013 Share Posted September 7, 2013 (edited) Another thing the language could use that I just ran into:There's no way to abort the program other than trying to if-check around the whole thing. I wanted to put a check at the front of my script to say this:if maxthrust = 0 { print "ABORTING PROGRAM: No active engines right now.". print "Do not run until after you've started up the engines.". ...Crud what goes here? break? abort?...}.... rest of program continues on from here.There needs to be an "exit" or something like that. Or perhaps allow "break" outside a loop to mean exit.Can't you just wrap the program into an until block?set manualAbort to 0.until maxthrust = 0 OR manualAbort = 1 { (looping program)}.edit: for a non looping program you could do thisif maxthrust = 0 { print "ABORTING PROGRAM: No active engines right now.". print "Do not run until after you've started up the engines.". ...Crud what goes here? break? abort?...}.if maxthrust > 0 { ... rest of program continues on from here.}. Edited September 7, 2013 by Ozin Link to comment Share on other sites More sharing options...
betaking Posted September 7, 2013 Share Posted September 7, 2013 I apologise for my earlier post, it had a poor tone in it, kind of bossy and dumb of me.Is there any chance however, that this mod could possibly be made as to rely off of scientific/sensor information rather than like the data in the game iteslf? Link to comment Share on other sites More sharing options...
JewelShisen Posted September 7, 2013 Share Posted September 7, 2013 Use CNTRL-C in the kOS window to break out of the program if you need to. I'm not really sure what your issue is. If you program is written correctly it should end when it's end conditions are met. The end condition can be written in to your main loop or it can be set to be before that with a "when then". I don't think this is something wrong with kOS or it's missing anything. It has everything you need. You just have to learn to use it. For instance my launch to orbit script ends when you are either in orbit or it knows you aren't going to make it.Clearly you missed what he is looking for. He is looking for some way to have the program self abort if you haven't started the engines. There is no 'abort' command to kill an entire program. Link to comment Share on other sites More sharing options...
Sma Posted September 7, 2013 Share Posted September 7, 2013 Is there a way, or is there plans for a way to display a sort of debug table? Like during a loop instead of having print...print on a new line, have it set to a specific position. Maybe just using columns/rows. For example:print position (0,0) "Throttle:" + throttle.print position (0,1) "Altitude:" + altitude.etc... Link to comment Share on other sites More sharing options...
drtedastro Posted September 7, 2013 Share Posted September 7, 2013 That would be great and very useful... also way to have or dont have CR CrLF used... Then we can setup formatted screen output just like the good old days... well, ok, just the old days... Link to comment Share on other sites More sharing options...
Recommended Posts