Drew Kerman Posted September 25, 2015 Share Posted September 25, 2015 here's another slightly more advanced option for staging using part modules if all you want to do is know when your engine has stopped (example code pulled from my USI Sounding Rockets launch script)// tagged name for my first stage boosterset sre1 to ship:partstagged("sre1")[0].// wait for the engine to flame outuntil sre1:getmodule("ModuleEnginesFX"):getfield("status") = "flame-out!" {}.// do staging stuff Link to comment Share on other sites More sharing options...
Gaarst Posted September 25, 2015 Share Posted September 25, 2015 (edited) @Steven Mading, @GaiidenThank you both for your answers !I'll try Steven's things to hopefully be able to launch a rocket straight up properly I noted Gaiiden's tweak but that's a bit advanced for my kOS level: I'll consider using it whenever I get more comfortable with kOS.EDIT:So the staging thing is solved (also realised I had a double "stage" instruction in the code).But the wobbling is still present: I tried rolling the rocket in the VAB so that the red north line on the navball is right, but the only thing that changes is that the rocket rolls itself back to north-up on the navball. Pitch and yaw still wobble like crazy. Adding fins prevent it from flipping, but it doesn't solve the issue though.On the other hand, rolling works perfectly... EDIT2:OK, it seems I can't run the program at all anymore :/ Edited September 25, 2015 by Gaarst Link to comment Share on other sites More sharing options...
damerell Posted September 25, 2015 Share Posted September 25, 2015 But the wobbling is still present: I tried rolling the rocket in the VAB so that the red north line on the navball is right, but the only thing that changes is that the rocket rolls itself back to north-up on the navball. Pitch and yaw still wobble like crazy. Adding fins prevent it from flipping, but it doesn't solve the issue though.Well, kOS's "cooked" steering modes use KSP's PID controller, which is a bit dubious. If you were to use stock SAS to try and send the same rocket upwards, I imagine it would weave just as much. You could write your own PID controller and use raw control, or use a mod that lets you tweak the stock PID controller (they exist), or ask about kOS / MechJeb integration... Link to comment Share on other sites More sharing options...
Dunbaratu Posted September 25, 2015 Share Posted September 25, 2015 Well, kOS's "cooked" steering modes use KSP's PID controller, which is a bit dubious.That's not really true. It uses its own steering mechanism that is just as poor as KSP's stock one, but it isn't *actually* using the same code as the stock one unless you use the SAS steeringmodes like set sasmode to "prograde"..It actually is sharing the same code as RT's flight computer uses, although that won't be true anymore on the next release.- - - Updated - - -OK, it seems I can't run the program at all anymore :/The output_log message that accompanies that screen message will have the more detailed description, more verbose than what's in the terminal screenshot. Can you post that? Link to comment Share on other sites More sharing options...
Gaarst Posted September 25, 2015 Share Posted September 25, 2015 (edited) The output_log message that accompanies that screen message will have the more detailed description, more verbose than what's in the terminal screenshot. Can you post that?output_log here, but good luck with finding anything in it, as I get spammed with the same line of codes over and over again (that's another thing... )I'll try to find the relevant section and isolate it.Edit: removed the spam on the output_log Edited September 25, 2015 by Gaarst Link to comment Share on other sites More sharing options...
Dunbaratu Posted September 26, 2015 Share Posted September 26, 2015 output_log here, but good luck with finding anything in itIt looks like this bug:https://github.com/KSP-KOS/KOS/issues/1117Maybe.Is there a FROM loop with a lock throttle in it? If so, try re-writing it as an UNTIL loop for the temp workaround. It's fixed in develop, but that's not released yet. Link to comment Share on other sites More sharing options...
Gaarst Posted September 26, 2015 Share Posted September 26, 2015 It looks like this bug:https://github.com/KSP-KOS/KOS/issues/1117Maybe.Is there a FROM loop with a lock throttle in it? If so, try re-writing it as an UNTIL loop for the temp workaround. It's fixed in develop, but that's not released yet.Yes there is: print "..." + countdown. wait 1. if countdown = 2 { lock throttle to 1.0. print "Throttling up to 100% !". }}lock steering to up.stage.when ship:maxthrust = 0 then { print "No liquid fuel. Attempting to stage.". stage. print "Stage activated.". preserve.}wait until ship:altitude > 70000.print "Counting down:".from {local countdown is 10.} until countdown = 0 step {set countdown to countdown -1.} do {I put the lock throttle command inside the countdown because i wanted the rocket to actually launch at 0 (not like in the tutorial).Thanks for the answer, I'll just move the lock throttle outside the from and it should fix it. Link to comment Share on other sites More sharing options...
Shumihazai Posted September 27, 2015 Share Posted September 27, 2015 hi everyone, does anybody have a code how to predict landing location on the surface of Kerbin using kOS? I'm writing a code for an ICBM. Thanks a lot! Link to comment Share on other sites More sharing options...
Dunbaratu Posted September 28, 2015 Share Posted September 28, 2015 hi everyone, does anybody have a code how to predict landing location on the surface of Kerbin using kOS? I'm writing a code for an ICBM. Thanks a lot!This would be a very hard problem to solve without very hard math (likely differential equations), because Kerbin has atmosphere. On a world without air it would be easier to predict. Link to comment Share on other sites More sharing options...
Dr_Goddard Posted September 30, 2015 Share Posted September 30, 2015 Everything you need to start your robot domination of the Kerbal system.https://github.com/pgodd/Petes-Craft-Repository Link to comment Share on other sites More sharing options...
ruairiau Posted October 1, 2015 Share Posted October 1, 2015 I can't seem to get the Waypoints structure working. I've tried manually creating a waypoint using Kerbal Waypoint Manager, then doing thisPRINT WAYPOINT("wp"):Name.I tried to list all waypoints...LIST ALLWAYPOINTS().LIST Name IN ALLWAYPOINTS().LIST Name FROM WAYPOINT IN ALLWAYPOINTS().Nothing seems to work. Any tips would be appreciated. Link to comment Share on other sites More sharing options...
Lookerksy Posted October 1, 2015 Share Posted October 1, 2015 By kOS, Can I create, compile or run a .ks file in the folder "GamePath\Ships\Script\NewFolder\"?Thanks. Link to comment Share on other sites More sharing options...
Dr_Goddard Posted October 1, 2015 Share Posted October 1, 2015 the gamepath folder is complicated with Steam./Users/myname/Library/Application Support/Steam/SteamApps/common/Kerbal Space Program/Ships/scriptis the folder where my k-OS scripts are stored on my Mac. Link to comment Share on other sites More sharing options...
Dunbaratu Posted October 1, 2015 Share Posted October 1, 2015 I can't seem to get the Waypoints structure working. I've tried manually creating a waypoint using Kerbal Waypoint Manager, then doing thisPRINT WAYPOINT("wp"):Name.I tried to list all waypoints...LIST ALLWAYPOINTS().LIST Name IN ALLWAYPOINTS().LIST Name FROM WAYPOINT IN ALLWAYPOINTS().Nothing seems to work. Any tips would be appreciated.Define "nothing seems to work". Its impossible to diagnose without being told what you're seeing when you try. Link to comment Share on other sites More sharing options...
Dunbaratu Posted October 1, 2015 Share Posted October 1, 2015 By kOS, Can I create, compile or run a .ks file in the folder "GamePath\Ships\Script\NewFolder\"?Thanks.It doesn't support subdirectories. Everything has to be Gamepath\Ships\Script\*.ks. Link to comment Share on other sites More sharing options...
Lookerksy Posted October 1, 2015 Share Posted October 1, 2015 Thanks for you quick reply. Now I have a new Question:In Program A, can I call a function in Program B? Link to comment Share on other sites More sharing options...
Dr_Goddard Posted October 1, 2015 Share Posted October 1, 2015 You can't call a function in a separate script or on a separate processor. A limited workaround is to run a script on a separate core, and have it watch for some condition like a change in the nametag of a part.Script 1 changes the nametag, script 2 sees the change and runs it's routine. Link to comment Share on other sites More sharing options...
Lookerksy Posted October 1, 2015 Share Posted October 1, 2015 Q1: How to change kOS's full physics range? (i.e. 2.5 km)A1:Q2: Online manual(http://ksp-kos.github.io/KOS_DOC/) says:Once a vessel is more than 100,000 meters away from mission control, by default it cannot access the files on the archive. But I succeed to cpoy files from Volume_0 to VOlume_1 when I was very far from Kerbin(when I was near Dres). What did I do wrong? and How shall I verify this rule?A2:Q3: There are two keywords("batch" and "deploy") in online manual. How to use these keywords?A3:A4: what's meaning of the math function round(a,? Online manual says "Rounds to the nearest place value". Waht's the nearest place value meaning?A4: Link to comment Share on other sites More sharing options...
Dunbaratu Posted October 1, 2015 Share Posted October 1, 2015 (edited) You can't call a function in a separate script or on a separate processor. A limited workaround is to run a script on a separate core, and have it watch for some condition like a change in the nametag of a part.Script 1 changes the nametag, script 2 sees the change and runs it's routine.No no no. Absolutely false.This works:program1.ksfunction aaaa { return "aaaa".}program2.ksrun program1.print "now calling aaaa: it returned:" + aaaa().What you can't do is call a function from the interpreter when it was declared in a program.This is how libraries are designed to work in kerboscript. They are programs you run which contain nothing but functions in them that are left behind for you to call later. Edited October 1, 2015 by Steven Mading Link to comment Share on other sites More sharing options...
Lookerksy Posted October 2, 2015 Share Posted October 2, 2015 how to use "WHEELSTEERING"?I shall Lock it to...?Thanks. Link to comment Share on other sites More sharing options...
Dr_Goddard Posted October 3, 2015 Share Posted October 3, 2015 `lock wheelsteering to...`eg: 'lock wheelsteering to 205.1.' (compass heading is slightly broken in the current release and needs a decimal number)or `lock wheelsteering to target` Link to comment Share on other sites More sharing options...
Drew Kerman Posted October 3, 2015 Share Posted October 3, 2015 since the RT config option may be going away, I'm wondering how I might go about recovering log data from a local volume that I can't connect to? As in I launch a ballistic sounding rocket from KSC that's not meant to have a connection but is logging data locally, data which I would prefer be saved to a text file rather than just the console. Given that I can go out and recover the vehicle if it lands okay, I should also be able to recover this log data in text form. It would be nice if it were dumped to a text file when the vessel is unloaded from the persistence file upon recovery. Link to comment Share on other sites More sharing options...
kendoka15 Posted October 3, 2015 Share Posted October 3, 2015 By kOS, Can I create, compile or run a .ks file in the folder "GamePath\Ships\Script\NewFolder\"?Thanks.You can make a symbolic link to the folder. For example, my scripts are in C:\KSP\Script which is linked to C:\KSP\Kerbal Space Program RP-0\Ships\Script Link to comment Share on other sites More sharing options...
Nerd1000 Posted October 4, 2015 Share Posted October 4, 2015 I have a strange and nasty bug with my RO install. If I timewarp with my execute maneuver node script running the gimballing section of any engine that has previously been activated starts to flicker. Throttling up in this state causes the game to crash with the navball disappearing, the screen turning black, and altitude and velocity displays showing NaN.Has anyone else had symptoms like this? I inspected the log file and oddly the first error that appears is FAR complaining that something to do with its voxelisation process being NaN. Link to comment Share on other sites More sharing options...
Lookerksy Posted October 5, 2015 Share Posted October 5, 2015 How to disable the control from Keyboard? I want to reprogram for pilot input like W A S D Q E keys. Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts