SolarLiner Posted August 31, 2013 Share Posted August 31, 2013 I already have a working UI for my launch to orbit script. It only lets you scroll through preset values and select one but it could easily be expanded.What? How? I can't seem to have anything to let the user interact, other than editing the script itself. Link to comment Share on other sites More sharing options...
razark Posted August 31, 2013 Share Posted August 31, 2013 What? How? I can't seem to have anything to let the user interact, other than editing the script itself.With "ON AGx SET variable TO value." type of stuff and loops, I could see input being done in a primitive way. I haven't tried it, but I wouldn't mind knowing how it was done. Link to comment Share on other sites More sharing options...
itchyDoggy Posted August 31, 2013 Share Posted August 31, 2013 Hey there...I've got a problem with my program. kOS keeps saying that I have an error in my code, while I have not.Here is my program:clearscreen.print "Launching in 3...". wait 1. clearscreen.print "Launching in 2...". wait 1. clearscreen.print "Launching in 1...". wait 1. clearscreen.print "Launching!".set tLevel to 1.lock steering to UP + R(0,0,-180).lock throttle to tLevel.stage.wait until verticalspeed > 100.set lastV to verticalspeed - 1.until altitude > 9999 { if verticalspeed > 100 { if lastV < verticalspeed { set tLevel to tLevel - 0.02. }. }. set lastV to verticalspeed.}.set tLevel to 1.lock steering to UP + R(0,-60,-180).wait until apoapsis > 75000.And this is the error I get: Link to comment Share on other sites More sharing options...
StainX Posted August 31, 2013 Share Posted August 31, 2013 (edited) Hey there...And this is the error I get:If boxing seems to be a problem...but you can use as many if's as you like after each other in an loop.Edit:U may use something like this instead:set th to 1.lock throttle to th.stage.until altitude > 15000 { if verticalspeed > 200 { set th to th -0.1. }. if verticalspeed < 190 { set th to th +0.1. }. wait 1.}. Edited August 31, 2013 by StainX Link to comment Share on other sites More sharing options...
itchyDoggy Posted August 31, 2013 Share Posted August 31, 2013 (edited) Thanks alot StainX, that does work Still weird you can't use an if in an if.EDIT:I now use this code, and it balances excellently on 100 m/s.set tLevel to 1.lock steering to UP + R(0,0,-180).lock throttle to tLevel.stage.wait until verticalspeed > 100.set lastV to verticalspeed - 1.until altitude > 9999 { if lastV < verticalspeed { set tLevel to tLevel - 0.02. }. if verticalspeed < 100 { set tLevel to tLevel + 0.03. }. set lastV to verticalspeed.}. Edited August 31, 2013 by itchyDoggy Link to comment Share on other sites More sharing options...
Nicok Posted August 31, 2013 Share Posted August 31, 2013 I totally cant use ressources...I have a thing atop of a solid booster with a decoupler between them.here is the code :stage.wait until stage:solidfuel = 0.stage.i've checked with a print stage:solidfuel and it does reach 0 when depleted. I have even test with a <solidfuel> before launch and the amount is ok. the first line works and ignitiate the solid booster. I just don't understand why it doesn't work.... Link to comment Share on other sites More sharing options...
itchyDoggy Posted August 31, 2013 Share Posted August 31, 2013 Maybe if you try this:wait until stage:solidfuel < 1. Link to comment Share on other sites More sharing options...
jsalexan Posted August 31, 2013 Share Posted August 31, 2013 Payload, To respectfully disagree with your statement about kOS interacting with Infernal Robotics: interacting with an action group is not quite the same thing as interacting with Infernal Robotics. toggling action groups is nowhere near the same thing as setting a direct value or incrementing/decrementing a value buffer by a set amount.It's close, and an awesome mod in its own right and one I'm watching very carefully because it makes a lot of things like autonomous probe networks and multiple launch base missions, automated kethane mining outposts, etc possible above and beyond its robotics applications.This is one of those mods that I'm really excited to see and I'm looking forward to making some amazing things with it! Link to comment Share on other sites More sharing options...
Nicok Posted August 31, 2013 Share Posted August 31, 2013 No, doesn't work. It's like i couldn't use ressources variables in tests. Link to comment Share on other sites More sharing options...
gravspeed Posted August 31, 2013 Share Posted August 31, 2013 maybe i'm just not clear enough on the coding here... is there anywhere besides this forum people are posting scripts?certainly the ascent guidance would be about the easiest mechjeb function to replicate, but what about autostaging? is there a way for kos to know when a stage has run out of fuel? all the examples i see are done with wait unitl fuel < x, but that can be tricky to figure out when you have 15 asparagus stages.... MJ does that flawlessly.i would really like to see your hohmann transfer code, how do you calculate when to burn back to the smaller orbit?using action groups to control robotics would only allow very basic control of 10 groups of parts, it would be nice to be able to say something like set hinge1 = 45, set rotatron2 = 15, etcpretty much the same with kethane mods, i suppose some better groupings could save me a few slots, but it would be nice to call those parts to action without using all my groups...again i totally understand that this will almost certainly require a rewrite of both mods and i shouldn't hold my breath... but maybe one of those devs will see this and agree... Link to comment Share on other sites More sharing options...
jsalexan Posted August 31, 2013 Share Posted August 31, 2013 I was looking a little at the RemoteTech code on GitHub. There's a couple of public interfaces in the plugin that might be of interest to send commands to.At first glance it looks like all that needs to be done is to include the RT antenna parts in the internal list of antennas. Just query the existing RT interface for ship in range and that sort of thing.Remote programs would have to set up their own time delays prior to run I think but it could be done. Link to comment Share on other sites More sharing options...
razark Posted August 31, 2013 Share Posted August 31, 2013 I was looking a little at the RemoteTech code on GitHub. There's a couple of public interfaces in the plugin that might be of interest to send commands to.What I'd love to see with regard to RT and kOS integration is the ability to enter a program, hit an "Upload" routine to load the program to the ship. The length of path and length of program would determine the time needed to complete the upload. Once you had uploaded programs to the ship, you could send run commands to those programs, and they'd execute at the appropriate time. Results would arrive after the delay as well. Link to comment Share on other sites More sharing options...
jsalexan Posted August 31, 2013 Share Posted August 31, 2013 What I'd love to see with regard to RT and kOS integration is the ability to enter a program, hit an "Upload" routine to load the program to the ship. The length of path and length of program would determine the time needed to complete the upload. Once you had uploaded programs to the ship, you could send run commands to those programs, and they'd execute at the appropriate time. Results would arrive after the delay as well.You may not even need RT for that, it could just see if an antenna is in range of the currently selected ship and if it is, how far away it is and if it's connectable. Calculate your delays and set a timer in the remote kOS to switch to that remote ship and execute the program. You'd need to do this to ensure the ship is loaded into the physics engine. Would get interesting if you're in the middle of a landing or something when the switch unloads your current ship out of the engine though. Link to comment Share on other sites More sharing options...
Payload Posted August 31, 2013 Share Posted August 31, 2013 I totally cant use ressources...I have a thing atop of a solid booster with a decoupler between them.here is the code :stage.wait until stage:solidfuel = 0.stage.i've checked with a print stage:solidfuel and it does reach 0 when depleted. I have even test with a <solidfuel> before launch and the amount is ok. the first line works and ignitiate the solid booster. I just don't understand why it doesn't work.... That is because it tanks on those. You will need to make a variable and wrap it in an until loop.like until condition = 1 { set StageSolid to stage:solidfuel. }.The problem is now how do you wrap all the things that are dynamic into that loop? The good thing is that isn't too hard. I'm working on a pretty dynamic launch to orbit script right now that I will release for you all to fondle to your hearts desire in a little while. I am still working on the UI. It's a little wonky and crappy right now though it does function.Then you all will have a solid if ugly example. Link to comment Share on other sites More sharing options...
Wice Posted August 31, 2013 Share Posted August 31, 2013 Does this still work if the focus is not on the craft? Link to comment Share on other sites More sharing options...
Ozin Posted August 31, 2013 Share Posted August 31, 2013 It would be great if if-blocks could be nested in each other. Using an if in an if block currently doesn't work, not sure if that's a bug or if it's just not supported (yet?). Link to comment Share on other sites More sharing options...
Jeridal Posted August 31, 2013 Share Posted August 31, 2013 Help !Nothing appends when I press ENTER/RETURN except that the cursor go to a new line. Link to comment Share on other sites More sharing options...
Panichio Posted August 31, 2013 Share Posted August 31, 2013 Alright, I'm confused. I don't understand how to save your programs to Archive. I can set Archive as the active volume. But when I write something and press F5, it won't save it. Link to comment Share on other sites More sharing options...
KevinLaity Posted August 31, 2013 Author Share Posted August 31, 2013 It would be great if if-blocks could be nested in each other. Using an if in an if block currently doesn't work, not sure if that's a bug or if it's just not supported (yet?).It's something I haven't tested fully yet. The intent is to have it nestable yes, but I can see people are having a lot of issues. Currently doing an IF inside an UNTIL works well.Fixing up if statements is something I want to do in the next big release, along with boolean operators (AND, OR) Link to comment Share on other sites More sharing options...
KevinLaity Posted August 31, 2013 Author Share Posted August 31, 2013 I totally cant use ressources...I have a thing atop of a solid booster with a decoupler between them.here is the code :stage.wait until stage:solidfuel = 0.stage.i've checked with a print stage:solidfuel and it does reach 0 when depleted. I have even test with a <solidfuel> before launch and the amount is ok. the first line works and ignitiate the solid booster. I just don't understand why it doesn't work.... To anybody having this kind of problem: Check out 0.43. There was an issue regarding compound statements in that they wouldn't get recalculated when used in WAITs and LOCKs. Link to comment Share on other sites More sharing options...
KevinLaity Posted August 31, 2013 Author Share Posted August 31, 2013 (edited) is there a way for kos to know when a stage has run out of fuel?Try 0.43, you can use STAGE:LiquidFuel, which will give you the total fuel that is connected to all of the engines which are currently active. However, this value will not read zero if you're doing asparagus staging, since you'll have one or more engines that still have fuel at the time you want to stage.using action groups to control robotics would only allow very basic control of 10 groups of parts, it would be nice to be able to say something like set hinge1 = 45, set rotatron2 = 15, etcpretty much the same with kethane mods, i suppose some better groupings could save me a few slots, but it would be nice to call those parts to action without using all my groups...I haven't worked out a reasonable way to refer to individual parts in code. A lot of this kind of stuff will open up when I find a way. Edited August 31, 2013 by KevinLaity typo Link to comment Share on other sites More sharing options...
KevinLaity Posted August 31, 2013 Author Share Posted August 31, 2013 Alright, I'm confused. I don't understand how to save your programs to Archive. I can set Archive as the active volume. But when I write something and press F5, it won't save it.Which version are you using? I observed this problem in 0.40 and released a fix for it. Can you check if this folder exists? <KSP Folder>\Plugins\PluginData\Archive kOS can't write to Archive if it doesn't. 0.41 fixed that by ensuring that that folder exists on startup. Link to comment Share on other sites More sharing options...
zekes Posted August 31, 2013 Share Posted August 31, 2013 ooohl i like this, great for Ion burns... Link to comment Share on other sites More sharing options...
Ozin Posted August 31, 2013 Share Posted August 31, 2013 (edited) It's something I haven't tested fully yet. The intent is to have it nestable yes, but I can see people are having a lot of issues. Currently doing an IF inside an UNTIL works well.Fixing up if statements is something I want to do in the next big release, along with boolean operators (AND, OR)Sounds good! The != operator would be handy as well.Here is my hover and landing script in case anyone wants to have a look. It works pretty well, at least for medium to light rockets.hover.txt - AG2: Ascend, AG3: Hover, AG4: Descend, AG5 Switch to land script.clearscreen.print "Activated autohover..".sas off.lock steering to R(up:pitch,up:yaw,prograde:roll - 90).set t to 0.set first to 1.set targetAlt to 0.set x to 0.until x = 1 { on ag2 set t to 3. on ag3 set t to 0. on ag4 set t to -3. set thr to (maxthrust/10). set thr to thr + 0.5. set m to mass. set TWR to (thr/m). set WTR to (m/thr). set mod to 0. if first = 1 { set keepAlt to 1. }. if first = 0 { set keepAlt to 0. }. if t > 0 { set first to 1. set keepAlt to 0. set targetAlt to 0. }. if t < 0 { set first to 1. set keepAlt to 0. set targetAlt to 0. }. if verticalspeed < t { set mod to 0.02. }. if verticalspeed < (t - 1) { set mod to 0.04. set keepAlt to 0. }. if verticalspeed < (t - 4) { set mod to 0.1. }. if verticalspeed < (t - 8) { set mod to 0.3. }. if verticalspeed > t { set mod to -0.02. }. if verticalspeed > (t + 1) { set mod to -0.04. set keepAlt to 0. }. if verticalspeed > (t + 4) { set mod to -0.1. }. if verticalspeed > (t + 8) { set mod to -0.3. }. if keepAlt = 1 { set first to 0. set targetAlt to altitude. }. if altitude > targetAlt { set mod2 to -0.02. }. if altitude < targetAlt { set mod2 to 0.02. }. if targetAlt > 0 { set mod to mod2. }. lock throttle to (WTR + mod). print "---". print "first: " + first. print "keepAlt: " + keepAlt. print "targetAlt: " + targetAlt. print "altitude: " + altitude. print "target v: " + t. print "mod: " + mod. print "vSpeed: " + verticalspeed. on ag5 set x to 1.}.run land.It's a bit messy without nested if statements, but it does the job land.txt - AG2: abort. AG4: shut down engines (you got 10 seconds to turn down throttle manually or shut down engines before script ends)print "Landing..".set x to 0.set offset to 5.until x > 0 { set t to -1. if alt:radar > (20 + offset) { set t to -4. }. if alt:radar > (100 + offset) { set t to -8. }. if alt:radar > (200 + offset) { set t to -16. }. if alt:radar > (400 + offset) { set t to -40. }. set thr to (maxthrust/10). set thr to thr + 0.5. set m to mass. set TWR to (thr/m). set WTR to (m/thr). set mod to 0. if verticalspeed < t { set mod to 0.03. }. if verticalspeed < (t - 2) { set mod to 0.07. }. if verticalspeed < (t - 8) { set mod to 0.2. }. if verticalspeed < (t - 16) { set mod to 0.4. }. if verticalspeed > t { set mod to -0.02. }. if verticalspeed > (t + 2) { set mod to -0.04. }. if verticalspeed > (t + 8) { set mod to -0.1. }. if verticalspeed > (t + 16) { set mod to -0.3. }. if verticalspeed > (t + 40) { set mod to -0.5. }. lock throttle to (WTR + mod). print "---". print "target v: " + t. print "mod: " + mod. print "vSpeed: " + verticalspeed. print "altradar: " + alt:radar. on ag4 set x to 1. on ag2 set x to 2.}.if x = 1 { lock throttle to 0. print "Shut down engines within 10 seconds!". wait 10. unlock throttle.}.if x = 2 { print "Abort landing! ". run hover.}. Edited August 31, 2013 by Ozin Link to comment Share on other sites More sharing options...
Nicok Posted August 31, 2013 Share Posted August 31, 2013 (edited) To anybody having this kind of problem: Check out 0.43. There was an issue regarding compound statements in that they wouldn't get recalculated when used in WAITs and LOCKs.I'm using 0.43.... edit : i thought i was with the 0.43, but it was the 0.42.... i just update, will test.edit² : it works now, thanks. Edited August 31, 2013 by Nicok Link to comment Share on other sites More sharing options...
Recommended Posts