Panichio Posted August 31, 2013 Share Posted August 31, 2013 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.I only just downloaded the newest version, and have checked that the Archive folder is exactly where you mentioned it should be, which it is. Link to comment Share on other sites More sharing options...
Payload Posted August 31, 2013 Share Posted August 31, 2013 (edited) Ok guys.. Here is the example launch to orbit script that I have written. It does everything from auto staging to letting you set your orbit altitude with a user interface. There is an example craft that I have hosted on my clans website.Get it here.http://clansmokejaguar.enjin.com/forums/m/423292/viewthread/8558153-thread-for-hosting-ksp-crafts/page/1Modparts:B9 red light.Novapunch NP_lfe_125m_berthaminiquad engine.kOS version .43.Scroll down to under the chat box. You will see the post. You will have to sign up for the site but it's the best I can do. At least you wont get spammed and I don't have to make a dummy e-mail to signup for media fire.FOR THE UI TO WORK YOU MUST NOT HAVE FOCUS ON THE kOS TERMINAL. Once you run the script it will tell you how to set your orbit altitude. Click outside the terminal window and set your orbit with the keys instructed. This craft has one B9 red light on it. Other than the kOS computer, the rest is stock. EDIT: I forgot it also has a nova punch engine on it. Sorry. The light is required to function. I challenge you to learn why and to gain understanding of this very rudimentary method of user input. Here is the script. It's ugly. Without most of the operators I am used to working with and without nested "IF" support, it's what I have come up with. Please don't hate. Just Update. The power is in your hands.clearscreen.set rpAlt to 100.set rProgram to 90.set r to 180.set p to 0.set y to 0.set orbit to 0.set tOrbit to 100000.set hAtmo to 69500.set tAngle to up + R(y,p,r).set tThr to 1.set turn1 to 9999.set turn2 to 14999.set turn3 to 19999.set turn4 to 24999.set turn5 to 49000.set selection to 0.set flagup to 0.set flagdown to 0.set confirm to 0.set autoliquid to 0.set autosolid to 0.print "Select your orbit altitude.".print "--------------------------------".print " ".print "Default orbit alt is set to 100km.".print " ".print "Use action group 9 to add 10Km to orbit alt.".print " ".print "Use action group 8 to remove 10Km from orbit alt.".print " ".print "Use action group 7 to confirm orbit alt.".until selection = 1 { on ag9 set flagup to 1. on ag8 set flagdown to 1. on ag7 set confirm to 1. if flagup = 1 { clearscreen. set tOrbit to tOrbit + 10000. print tOrbit. toggle ag9. set flagup to 0. }. if flagdown = 1 { clearscreen. set tOrbit to tOrbit - 10000. print tOrbit. toggle ag8. set flagdown to 0. }. if confirm = 1 { clearscreen. print "You have confirmed " + tOrbit. print "Begin countdown.". toggle ag7. set confirm to 0. wait 5. set selection to 1. }. }.set cAlt to tOrbit - (tOrbit*.2).set xAlt to tOrbit - 1000.set hAlt to tOrbit - 5.clearscreen.print "Orbit altitude set to " + tOrbit.print "3". wait 1.print "2". wait 1.print "1". Wait 1.Print "Lift Off!". stage.lock steering to tAngle.lock throttle to tThr.when altitude > rpAlt then { set r to rProgram. print "Roll Program". }.when altitude > turn1 then set p to -35.when altitude > turn2 then set p to -45.when altitude > turn3 then set p to -60.when altitude > turn4 then set p to -75.when apoapsis > turn5 then set p to -90.when apoapsis > tOrbit then { { set tThr to 0. }. until altitude > hAtmo { if apoapsis < hAlt { set tThr to .05. }. if apoapsis > tOrbit { set tThr to 0. }. }. when Eapoapsis < 1 then set tThr to 1. }.when periapsis > cAlt then set tThr to .05.when periapsis > xAlt then { set tThr to 0. sas on. print "You Are Now In Orbit". wait 1. set orbit to 1. }.until orbit = 1 { set StageLiquid to stage:liquidfuel. set StageSolid to stage:solidfuel. set Eapoapsis to eta:apoapsis. set tAngle to up + R(y,p,r). set throttle to tThr. if StageLiquid > 0 { set autoliquid to 1. }. when autoliquid = 1 then { if StageLiquid < 1 { stage. }. }. if StageLiquid = 0 { set autoliquid to 0. }. if StageSolid > 0 { set autosolid to 1. }. when autosolid = 1 then { if StageSolid < 1 { stage. }. }. if StageSolid = 0 { set autosolid to 0. }. }.Have fun. Make it better! Edited August 31, 2013 by Payload Link to comment Share on other sites More sharing options...
KevinLaity Posted August 31, 2013 Author Share Posted August 31, 2013 Ok guys.. Here is the example launch to orbit script that I have written. It does everything from auto staging to letting you set your orbit altitude with a user interface. There is an example craft that I have hosted on my clans website.Holy crap, good work! Link to comment Share on other sites More sharing options...
Nicksil Posted September 1, 2013 Share Posted September 1, 2013 Hey Kevin, is it possible to check against a boolean?Doing something such as this: set x to 1.print x = 1. #TrueReturns true and that's just fine, but I've been trying to check against the values themselves. Like, x = true. I've tried it as a string and otherwise, but can't seem to figure it out.Also, one more thing: With the new STATUS addition (great, by the way), I'm trying to run a check on it as well but cannot seem to figure out how. For example: until status = landed. Though a very rough example, I think you get what I'm saying. Any thoughts?Thanks! Link to comment Share on other sites More sharing options...
Elliptical Orbit Posted September 1, 2013 Share Posted September 1, 2013 Holy crap, good work!Great work with the latest version sir! Back in action again. Link to comment Share on other sites More sharing options...
Payload Posted September 1, 2013 Share Posted September 1, 2013 (edited) What I want to know is who is going to write a plugin to play an alarm sound when it's toggled? We don't even need a model. We can use a dupe cfg from a rcs thruster. It kinda even looks like an alarm. I tried getting the light to play a sound but it was a no go. Squad broke standard sound loading a few updates ago. It will require a plugin as far as I know. The good thing is we need a generic sound module anyway. Firespitter's only works for engines.Hey Kevin, is it possible to check against a boolean?Doing something such as this: set x to 1.print x = 1. #TrueReturns true and that's just fine, but I've been trying to check against the values themselves. Like, x = true. I've tried it as a string and otherwise, but can't seem to figure it out.Also, one more thing: With the new STATUS addition (great, by the way), I'm trying to run a check on it as well but cannot seem to figure out how. For example: until status = landed. Though a very rough example, I think you get what I'm saying. Any thoughts?Thanks!I know I'm not kevin but from my experience it does not work. If you want to check against a boolean, then you will have to use 0 or 1. I tried checking against True False for action groups and it failed. I had to use them as a trigger to set my boolean value to a variable. Edited September 1, 2013 by Payload Link to comment Share on other sites More sharing options...
jsalexan Posted September 1, 2013 Share Posted September 1, 2013 List parts on vessel given the vessel object:Stolen from orbital construction codebase public static double DetermineMassOfVessel(Vessel v) { double totalmass = 0; foreach (Part p in v.parts) { MonoBehaviour.print("Part:" + p.name); MonoBehaviour.print("Mass:" + p.mass); totalmass += p.mass; //we also need to coutn the resouces in each part, and multiply that by density... but that can wait. double resMass = (double)p.GetResourceMass(); MonoBehaviour.print("ResMass:" + p.GetResourceMass()); totalmass += resMass; } MonoBehaviour.print("Mass of vessel: " + totalmass); return totalmass; } Link to comment Share on other sites More sharing options...
Stuntaneous Posted September 1, 2013 Share Posted September 1, 2013 I'm keen-as about kOS. I'm glued to your updates. Keep at it!And now, some stray suggestions. I've written up notes on all sorts of possibilities and will keep adding to them, I can't help myself. Here's a snippet. - The ability to create multiple console windows so you can, for instance, have another window streaming values in real-time. Or, visualising / graphing data. - A bit more involved: kOS as a means of writing AI.I should ask, is an instance of this able to run on a craft when it isn't in focus? If not, it's pretty important stuff :0 Link to comment Share on other sites More sharing options...
jsalexan Posted September 1, 2013 Share Posted September 1, 2013 (edited) He's got a dual simultaneous launch in one of his videos. I think the only limitation is that the two ships need to be in physics range of one another.This will be a godsend in docking if you can keep the remote ship's docking port always pointed towards your docking port. Edited September 1, 2013 by jsalexan Link to comment Share on other sites More sharing options...
KevinLaity Posted September 1, 2013 Author Share Posted September 1, 2013 List parts on vessel given the vessel object:I don't know if this is in reference to addressing individual parts in code, if it is:Listing the parts is not the issue. This problem is, I need to assign an identifier to each part.KSP gives each part a "unique ID" already. However it's quite long, random, and CHANGES every time the ship loads. If you write a program that addresses part# 11708957121, that program will be useless when you save and come back.So the next thought is "ok, I'll assign one myself!" but then I have to bring that number back later. So I assign them in order. Starting from the root part, part 1 gets #1, part 2 gets #2 and so on. This should work fine and I can rebuild it later after you reload. So far so good.And then you go and dock two ships.Now I have a conflict, there are two #1's, two #2's etc. AND I can't rebuild that later, one of the root parts is no longer a root. Link to comment Share on other sites More sharing options...
meve12 Posted September 1, 2013 Share Posted September 1, 2013 Maybe you could start with the terminal's ID number, then add to it for root parts?This would also mean you could run two terminals without interfering with each other's parts. Link to comment Share on other sites More sharing options...
Stuntaneous Posted September 1, 2013 Share Posted September 1, 2013 You could calculate a value, a signature, (er, a hash?) that's based on the collection of a craft's parts. When you come back to find a mishmash of two crafts with two #1's.. two #2's.. and so on, you calculate signatures for the possibilities of their combination to work out which parts belong to each original craft, and then spot a match. Sounds inefficient I know (relatively anyway - what is it, 2^[no. of parts]? possibilities) but then again, the way the two sets of parts arrange themselves in your new, combined list, would be the same from each pair to pair of the same number I would imagine, if you know what I mean, yeah. E.g. it turns out the order is #1a, #1b, #2a, #2b, #3a, #3b.. as opposed to something like #1a, #1b, #2a, #2b, #3b, #3a..So.. at the very least, you've now been mentally stimulated. I hope. Haha. Link to comment Share on other sites More sharing options...
whiterock Posted September 1, 2013 Share Posted September 1, 2013 Hello,I seem to have problems with saving my scripts. When I revert my ship back to launch, my script is gone. This makes it impossible for me to make more advanced scripts.Anybody has the same problem or knows how to fix it ? (:Best Regards,whiterock Link to comment Share on other sites More sharing options...
TouhouTorpedo Posted September 1, 2013 Share Posted September 1, 2013 (edited) Just started fiddling with this. I'd say a wonderful addition would be copying the previous line typed by pressing "up".Pretty much every other console interface can do this, its frustrating when you have to retype after forgetting a full stop on the end.So files can be copied out of the Archive but can they be copied to it?Yes the can, I finally got it to work. Keep forgetting full stops all the time. (extra reason why lack of copy previous lines is frustrating!) Edited September 1, 2013 by TouhouTorpedo Link to comment Share on other sites More sharing options...
Payload Posted September 1, 2013 Share Posted September 1, 2013 (edited) Sweet noticed the update. Do nested If statements work now? If so... This crap just got real.Hello,I seem to have problems with saving my scripts. When I revert my ship back to launch, my script is gone. This makes it impossible for me to make more advanced scripts.Anybody has the same problem or knows how to fix it ? (:Best Regards,whiterockSaving just updates the changes you made so the program will run with them. You have to copy the program to the archive. Using "Copy myprogram to archive." Conversely, you could just use an external editor like notepad or notepad++ and save as plain text to the archive. When you want to run the program all you have to do is "Copy my program from archive." then "Run my program." The programs are saved as txt files and it's really easy to manipulate them. Just make sure you put them in the archive folder or preform a copy to archive. Edited September 1, 2013 by Payload Link to comment Share on other sites More sharing options...
CaptainKipard Posted September 1, 2013 Share Posted September 1, 2013 (edited) I'm having a lot of fun with this plugin but I've got a little problem. I wrote a little script that allows me to keep a constant vertical speed in the atmosphere (also useful for hovering) by keeping my TWR at 1.I've taken into account the mass, maxthrust, and even compensated for gravity changes at different altitudes, but my test rocket is still accelerating ever so slightly (about 0.15m/s^2). Here's the scriptset radius to 600000.sas off.lock steering to up+r(0,0,180).until stage:liquidfuel = 0 {lock throttle to (mass*9.81*((radius/(radius+altitude))^2)/maxthrust).}.unlock steering.print "ABANDON SHIP!".I'm able to compensate for the acceleration by using RCS but still, it would be nice to keep my ship still. Edited September 1, 2013 by Cpt. Kipard Link to comment Share on other sites More sharing options...
Payload Posted September 1, 2013 Share Posted September 1, 2013 I'm having a lot of fun with this plugin but I've got a little problem. I wrote a little script that allows me to keep a constant speed in the atmosphere (also useful for hovering) by keeping my TWR at 1.I've taken into account the mass, maxthrust, and even compensated for gravity changes at different altitudes, but my test rocket is still accelerating ever so slightly (about 0.15m/s^2). Here's the scriptsnipI'm able to compensate for the acceleration by using RCS but still, it would be nice to keep my ship still.Have you tried printing the throttle value? Maybe it's not what you expect. I'm not sure about the situation with the math right now. Kevin had stated that the divide and multiply were executing out of order. I would print that value over some seconds to make sure the math is correct. Also there is a value called verticalspeed. You can use that directly to hover in place. I setup an on/off hover and landing system that preforms flawlessly unless it has to cancel horizontal speed. There is obviously not a good way to do that right now.Also someone brought up earlier, the game is only single precision floating point. Could just be that small variance. Seems plausible. Also there is lagg to this. I learned really quickly that this wasn't a real time microprocessor like I was used to working with.My opinion, forget trying to set the throttle to anything other than 0 or 1. Check against a variable and set the throttle on if < and off if >. That is self regulating and your average height will only vary a few mm. Link to comment Share on other sites More sharing options...
gravspeed Posted September 1, 2013 Share Posted September 1, 2013 nice, unfortunately, buggy as hell in windows 8... Link to comment Share on other sites More sharing options...
TouhouTorpedo Posted September 1, 2013 Share Posted September 1, 2013 (edited) You'd do better I'd say to write a controller to get the set value spot on. I've done the same thing but I'm not even using TWR on the first version, just PID values that I've tuned by trail and error.while we're on the subject, whats the syntax for testing a string?I'm tryingif BODY = "Kerbin" {set g to 9.81.}.if BODY == "Kerbin" {set g to 9.81.}.if BODY = Kerbin {set g to 9.81.}.no luck on any of those variants, they all throw expression error.edit again : do we have any mathematics code? like sine, cosine, that kind of thing? we've only got direction output available at the moment but I really need vector output for a target thing I'm doing.Also, translation control would be pretty awesome. Edited September 1, 2013 by TouhouTorpedo Link to comment Share on other sites More sharing options...
GavinZac Posted September 1, 2013 Share Posted September 1, 2013 Woohoo! I've been away for a few days and bam! Nine version increments. Awesome stuff. Link to comment Share on other sites More sharing options...
Panichio Posted September 1, 2013 Share Posted September 1, 2013 I really hate to be the one to nag, but I'm not sure if my response to your last comment to me was overlooked, Kevin. Programs still won't be saved to the Archive folder, and I checked I have the latest reversion (even re-downloaded it) and triple-checked that the folder is in the right place. I have KSP installed on the desktop so it shouldn't have anything to do with permission issues, either. Link to comment Share on other sites More sharing options...
Payload Posted September 1, 2013 Share Posted September 1, 2013 (edited) I hate to be the bearer of bad news or bugs, however, string concatenation is bugged. print "Default orbit alt is set to " + tOrbit + "m". no longer works as of the newest version. It throws up an error when it gets to the t of tOrbit. Unrecognized term 't'. And I had just spent five minutes making my UI look all spiffy and everything. Darn. No more "m" at the end for now.EDIT:Well it's worse than that actually. It doesn't work at all anymore. Edited September 1, 2013 by Payload Link to comment Share on other sites More sharing options...
CaptainKipard Posted September 1, 2013 Share Posted September 1, 2013 (edited) Have you tried printing the throttle value? Maybe it's not what you expect. I'm not sure about the situation with the math right now. Kevin had stated that the divide and multiply were executing out of order. I would print that value over some seconds to make sure the math is correct.Good idea. I should have thought of this but it's been years since I had to debug a program. While I'm on the subject:BUG REPORTThe whole game freezes when your brackets don't match up.Anyway you're probably right. I just added this into the loop and ran the thing for 5 minutes:print (mass*9.81*((radius/(radius+altitude))^2))/(maxthrust*(mass*9.81*((radius/(radius+altitude))^2)/maxthrust))Now every teenager will tell you that should equate to 1 because everything cancels out but I got 0.999999999 about a dozen times, so yeah, the thrust is just a little bit too high.My opinion, forget trying to set the throttle to anything other than 0 or 1. Check against a variable and set the throttle on if < and off if >. That is self regulating and your average height will only vary a few mm.I'll try that, thanks.You'd do better I'd say to write a controller to get the set value spot on. I've done the same thing but I'm not even using TWR on the first version, just PID values that I've tuned by trail and error.I just looked up PID controller on wikipedia and it's way over my head.We should probably get a script exchange and tutorial section going somewhere.Also, translation control would be pretty awesome.Second.Can't wait for automated docking. Edited September 1, 2013 by Cpt. Kipard Link to comment Share on other sites More sharing options...
Ralathon Posted September 1, 2013 Share Posted September 1, 2013 Is it me, or is the break command giving syntax errors? I have a program with an infinite loop that I'd like to cancel on a simple buttonpress. So the loop contains the line: "ON AG9 BREAK.". For some reason this gives me a syntax error. If I put the break command between brackets the program only experiences a syntax error when I press 9. So that sort of works, but it is rather cludgy and prevents me from doing anything after the infinite loop. Am I just failing at something simple here, or did I find a bug? Link to comment Share on other sites More sharing options...
razark Posted September 1, 2013 Share Posted September 1, 2013 I hate to be the bearer of bad news or bugs, however, string concatenation is bugged. ...EDIT:Well it's worse than that actually. It doesn't work at all anymore.I'm not having that problem here. I'm seeing lines with multiple variable and literal strings printing fine.print missiontime + ": Stage 1 separation.".print "MECO: " + missiontime + " " + altitude.print missiontime + ": " + status + " " + body.print alt:apoapsis + " x " + alt:periapsis.All of these have worked fine. Link to comment Share on other sites More sharing options...
Recommended Posts