Jump to content

kOS scripting discussion


impyre

Recommended Posts

I've been working with this for a bit and thought that we should have a page just to talk about kOS-related stuff. Right now it seems like you can't use for-loops to create a main program control loop that cycles through a list of installed subroutines. Even though it's a bit rough around the edges, I'm using this to get around that:

boot file


//boot file
set ag9 to false.
set halt to false.
set ag8 to true.
copy ctrl from 0.
copy printtest from 0. //just testing to ensure that it works.
set hasprinttest to true.
run ctrl.

main loop file


//ctrl file
delete boot from 1.
until halt
{
wait .000001. //with such a short loop this keeps it from looking glitchy.
print "main control loop running.". //testing purposes
on ag9
{
set halt to true. // action group 0 stops program.
preserve. // later will add code to unlock steering/thrust to return control to user.
}
if ag8 //allow ag8 to toggle routines off and on. (can be used to put program to sleep temporarily)
{
if hasprinttest {run printtest.} //check if this subroutine is installed, if so then run it.
}
}
print "Program ended!".

Basically i'll flesh this out with all my short and simple subroutines, and then tack on a "management" subroutine at the end that will take care of any clean-up duties like reset variables that need to be reset, deleting unused programs to free up space, etc. I'm hoping to keep subroutines as short and simple as possible to give the software a sort-of multitasking capability.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...