Jump to content

akrasuski1

Members
  • Posts

    8
  • Joined

  • Last visited

Reputation

4 Neutral

Profile Information

  • About me
    Bottle Rocketeer

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hello. I've been working on a kOS project for the last couple of weeks. I'm proud to present to you the akrOS - as far as I know, the first kOS window-based operating system. Main features: windows processes - yes, you may run multiple programs at the same time, and they'll all update at the same time! action group controls focus mechanics automatic screen resizing (when you resize terminal) user tutorials (first steps in akrOS) developer tutorials (how to make your own widget) Everything is made in a modular way - every process/widget is contained in a separate file, so a fellow developer will be able to quite easily add his own contribution to this project. Link to a reddit post containing images and download: http://www.reddit.com/r/Kos/comments/35ufj1/akros_the_window_operating_system/
  2. There isn't any, though I heard it is on the to-be-done list. For now, you can use some libraries from KSLib: https://github.com/KSP-KOS/KSLib If what you really need, is a simple menu, there is a code for that there.
  3. Sorry for a double post, but I want to separate this (my creation) from the issues described above. I created a nice small utility that enables people to input numbers to their scripts - for example, you can ask to enter desired apoapsis and such. The second script is similar, but instead creates a menu to be chosen from. Since we don't have functions yet, they are still made as scripts, but when functions come, it would be trivial to rewrite it for the new function syntax. 1. Numpad: // This script shows a numpad on the terminal allowing user to // type in any number (including floating point ones) and return // it to calling script. clearscreen. set finished to false. set number_so_far to 0. set dot_encountered to 0. set digits_so_far to 0. set current_x to 0. set current_y to 0. set was_pause to true. lock steering to ship:facing. //print calculator once print "+===================+" at (0,0). print "| |" at (0,1). print "| |" at (0,2). print "| |" at (0,3). print "+===================+" at (0,4). print "| |" at (0,5). print "| +---+---+---+---+ |" at (0,6). print "| | | | | | |" at (0,7). print "| | 7 | 8 | 9 | C | |" at (0,8). print "| | | | | l | |" at (0,9). print "| +---+---+---+ e | |" at (0,10). print "| | | | | a | |" at (0,11). print "| | 4 | 5 | 6 | r | |" at (0,12). print "| | | | | | |" at (0,13). print "| +---+---+---+---+ |" at (0,14). print "| | | | | | |" at (0,15). print "| | 1 | 2 | 3 | | |" at (0,16). print "| | | | | | |" at (0,17). print "| +---+---+---+ | |" at (0,18). print "| | | | | |" at (0,19). print "| | . | 0 | Enter | |" at (0,20). print "| | | | | |" at (0,21). print "| +---+---+-------+ |" at (0,22). print "| |" at (0,23). print "+===================+" at (0,24). print "| |" at (0,25). print "| Outside terminal, |" at (0,26). print "| press: |" at (0,27). print "| |" at (0,28). print "| - WASD to move |" at (0,29). print "| - E to select |" at (0,30). print "| |" at (0,31). print "+===================+" at (0,32). until finished{ //only update important bits wait 0.001. print "| |" at (0,2). print "| | | | | | |" at (0,7). print "| | 7 | 8 | 9 | C | |" at (0,8). print "| | | | | l | |" at (0,9). print "| +---+---+---+ e | |" at (0,10). print "| | | | | a | |" at (0,11). print "| | 4 | 5 | 6 | r | |" at (0,12). print "| | | | | | |" at (0,13). print "| | | | | | |" at (0,15). print "| | 1 | 2 | 3 | | |" at (0,16). print "| | | | | | |" at (0,17). print "| +---+---+---+ | |" at (0,18). print "| | | | | |" at (0,19). print "| | . | 0 | Enter | |" at (0,20). print "| | | | | |" at (0,21). print number_so_far at (10-floor(digits_so_far/2+0.001),2). //print selection around current key if current_x=3 { if current_y=1{ print "+-+" at(15,7). print "|C|" at(15,8). print "|l|" at(15,9). print "|e|" at(15,10). print "|a|" at(15,11). print "|r|" at(15,12). print "+-+" at(15,13). } else{ print "+-+" at(15,15). print "| |" at(15,16). print "| |" at(15,17). print "| |" at(15,18). print "+---+ |" at(11,19). print "|Enter|" at(11,20). print "+-----+" at(11,21). } } else{ print "+-+" at(4*current_x+3,4*current_y+7). print "|" at(4*current_x+3,4*current_y+8). print "|" at(4*current_x+5,4*current_y+8). print "+-+" at(4*current_x+3,4*current_y+9). } //input from user set going_up to -(SHIP:CONTROL:PILOTPITCH). set going_right to SHIP:CONTROL:PILOTYAW. set push to SHIP:CONTROL:PILOTROLL. set key_pressed_now to false. if going_up<-0.5 or going_up>0.5 or going_right>0.5 or going_right<-0.5 or push>0.5{ set key_pressed_now to true. } if not key_pressed_now{ set was_pause to true. } else if was_pause{ //only allow button press after at least a frame without button set was_pause to false. if going_up>0.5{ set current_y to current_y-1. } else if going_up<-0.5{ set current_y to current_y+1. } if going_right>0.5{ set current_x to current_x+1. } else if going_right<-0.5{ set current_x to current_x-1. } //boundary checks: if current_x<0{ set current_x to 0. } if current_x>3{ set current_x to 3. } if current_y<0{ set current_y to 0. } if current_y>3{ set current_y to 3. } //check for clear if current_x=3 and current_y<=1{ set current_y to 1. } //check for enter if current_x=3 and current_y>1{ set current_y to 2. } if current_x=2 and current_y=3{ set current_y to 2. set current_x to 3. } //done with moving. //now check if key is pressed if push{ if current_x=3 and current_y=1{//clear set number_so_far to 0. set dot_encountered to 0. set digits_so_far to 0. } else if current_x=3 and current_y=2{//enter set finished to true. } else if current_x=0 and current_y=3{//dot set dot_encountered to 1. set digits_so_far to digits_so_far+1. } else{//digit set digits_so_far to digits_so_far+1. set digit to 0. if current_x=0 and current_y=0{set digit to 7.} if current_x=1 and current_y=0{set digit to 8.} if current_x=2 and current_y=0{set digit to 9.} if current_x=0 and current_y=1{set digit to 4.} if current_x=1 and current_y=1{set digit to 5.} if current_x=2 and current_y=1{set digit to 6.} if current_x=0 and current_y=2{set digit to 1.} if current_x=1 and current_y=2{set digit to 2.} if current_x=2 and current_y=2{set digit to 3.} if dot_encountered=0{ set number_so_far to number_so_far*10+digit. } else{ set number_so_far to number_so_far+digit*0.1^dot_encountered. set dot_encountered to dot_encountered+1. } } } } } clearscreen. unlock steering. set retVal to number_so_far. 2. Menu: // This script shows a simple menu on the terminal allowing user to // select one of the options and return its index to calling script. declare parameter list_of_names. set current_option to 0. set len to list_of_names:length(). set finished to false. set was_pause to true. lock steering to ship:facing. clearscreen. print "+================Menu================+" at(0,0). set i to 0. until i=len+2{ print "| |" at(0,i+1). set i to i+1. } print "+====================================+" at(0,len+3). print "| |" at(0,len+4). print "| Use W/S outside terminal to move |" at(0,len+5). print "| and E to select an option. |" at(0,len+6). print "| |" at(0,len+7). print "+====================================+" at(0,len+8). until finished{ wait 0.001. //print list set i to 0. until i=len{ if i=current_option{ print " ===> " + list_of_names[i] + " <===" at(2,i+2). } else{ print " - " + list_of_names[i] + " - " at(2,i+2). } set i to i+1. } //get input set going_up to -(SHIP:CONTROL:PILOTPITCH). set push to SHIP:CONTROL:PILOTROLL. set key_pressed_now to false. if going_up<-0.5 or going_up>0.5 or push>0.5{ set key_pressed_now to true. } if not key_pressed_now{ set was_pause to true. } else if was_pause{ //only allow button press after at least a frame without button set was_pause to false. if going_up>0.5{ set current_option to current_option-1. } if going_up<-0.5{ set current_option to current_option+1. } if(current_option<0){ set current_option to 0. } if(current_option>len-1){ set current_option to len-1. } if push{ set finished to true. } } } clearscreen. unlock steering. set retval to current_option. I don't think there's currently any way to provide direct input to kOS, so instead I made user select options or move around the numpad via their WASD keys and use E as Enter key. Images: Note: if the code doesn't work for you, make sure you aren't in docking mode - I thought there's a bug in my code for over an hour due to that.
  4. Some weird stuff is going on with ship:control. Consider the following command: SET ship:control:pitch to 0. Then, nothing happens (as expected). If I press W, I can normally control my ship (it rotates). But if I type: SET ship:control:pitch to 0.02. Then, the ship starts to very slowly accelerate (also, as expected). But now, I'm locked out of control of the ship. I don't think this is consistent behaviour. Normally this wouldn't be a problem, since usually you want to control to be either yours or script's (with you not touching the controls at all). But I want to use WASD input (using pilotpitch, etc. sufixes) to control some things in kOS without rotating my ship at all. I already tried neutralizing input from script in a few combinations, and setting pitch to 0 (as above). Due to the above "undocumented behaviour", I don't think I'm able to lock manual steering. Any way to do that? Also, as a side thing, printing ship:control:pilotneutral yields True or False, while printing ship:control:neutral gives "kOS.Safe.Utilities.Flushable`i[system.Boolean]]" whatever it means. EDIT: As a workarond, I can use "lock steering to ship:facing" which will lock any user WASD input from triggering rotation. Still, this is just a workaround.
  5. Bug report: one seismic instrument deployed on the Minmus can send multiple science reports from one impact. I don't think that is supposed to happen.
  6. What should I do if my Accelerometers only have stock option (Log Seismic Data), but no Record Impact Data? I can't collect science from crashing stuff into planet...
  7. Hello. I always wanted to have something like kOS functions available in KSP. Separate files almost make it, but one thing that bothered me for quite a long time was lack of local variables. This makes recursion impossible, and I have to use long names (can't use just "start" as name, because it is very likely used somewhere else too). So, I wrote a "preprocessor" for kOS. The idea is that the computer should have a stack for keeping separate functions' variables separately. This is implemented as a kOS list in boot.ks, which looks as follows: SET stack_size TO 1000. PRINT "Initializing stack (size: "+stack_size+" variables).". SET __STACK TO LIST(). SET __SP TO 0. UNTIL __SP>=stack_size { __STACK:ADD(0). // placeholder SET __SP TO __SP+1. } SET __SP TO 0. PRINT "Done.". Then, let's say I want the following code, calculating factorial, to work: //@return varToReturn DECLARE PARAMETER varNum. IF varNum<=1{ SET varToReturn TO 1. } ELSE{ RUN factorial(varNum-1). SET varToReturn TO retVal*varNum. } PRINT "Factorial of "+varNum+" is "+varToReturn+".". So I pass it through my preprocessor: python stack_maker.py < factorial_old.ks > factorial.ks That gives me a new file, called factorial.ks, with the following contents: //@return __STACK[__SP] DECLARE PARAMETER varNum. SET __STACK[__SP+1] TO varnum. IF __STACK[__SP+1]<=1{ SET __STACK[__SP] TO 1. } ELSE{ SET __SP TO __SP+2. RUN factorial(__STACK[__SP-1]-1). SET retval TO __STACK[__SP]. SET __SP TO __SP-2. SET __STACK[__SP] TO retVal*__STACK[__SP+1]. } PRINT "Factorial of "+__STACK[__SP+1]+" is "+__STACK[__SP]+".". Yeah, I know it's ugly, but you won't be looking at this code. You should only edit "source file" - the original one, and then run through the preprocessor again. When you're ready, go to KSP and run the program: run factorial(5). Factorial of 1 is 1. Factorial of 2 is 2. ... Factorial of 5 is 120. If anyone wants to use it, here are some design decisions I had to make: - all variables need to start with the prefix "var" (case doesn't matter) - this is because I am not skilled enough to write a full-scale language parser, which distinguishes between variables and function names, and so on. Also, even if I did that, my preprocessor would change built-in variables, such as "TIME" to stack variables too, which would be a bad thing. As a compromise, I made the user explicitly name variables varStuff (at least it's not kerStuff ) - you have to initialize stack before calling any program (just run boot.ks) - if you want to return something (one variable at most), you have to put the "//@return varStuff" directive on the top of the source. - if you want to access the returned value, you have to use variable called "retVal". See above for example use. Link to the preprocessor itself: https://github.com/akrasuski1/KerbalPreprocessor/tree/master Note that you have to have Python installed to run it. Thanks for any feedback. Note to developers: maybe something similar to this can be implemented in the kOS itself? It would definitely be better, because all of the above decisions wouldn't matter - I'm sure you already recognize variables in some way - so the prefix "var" would not be needed. If new syntax was added, "retVal" variable wouldn't be needed too - how about: "SET f TO RUN factorial(5)." ? IDK, it's just an idea.
  8. Hello, in the current release (1.4.0) the changelog says that the following issue: "Fixed electric charge consumption at higher time-warp factors" is fixed.However, when my energy consumption from my dishes is about 13e.c. per second, and I start to warp at no matter what speed (5x, 10x...), the electricity consumption is staying at 13, while it should increase.
×
×
  • Create New...