Juno New Origins – Useful Simple Script to Maintain TWR

In this guide I share my extremely limited knowledge on rockets, programming, and math to create some simple scripts that you may want to use and adapt to your own needs. I will update this guide with some regularity and add new scripts as I discover them. Hope you enjoy!

Introduction

I am new to Juno, and know very little about rockets, rocketry, etc. I know programming somewhat well, though I know nothing about Vizzy or whatever the visual editor in this is called. Part of the reason I am making this guide is to document what I personally learn as a result of playing around with this curious game. I hope you find this guide useful, and that it helps you come up with your own ideas and implementations of various scripts and/or concepts in Juno.

Maintain Thrust-To-Weight Ratio (TWR)

Keeping with the theme that I know very little about rockets, I heard that having the highest possible TWR is “inefficient” due to drag and other variables that I frankly can’t remember. So, ideally I’d like to be able to automatically adjust my throttle to maintain a steady TWR during a burn. There’s a few things to keep in mind if we want to do this “correctly”:

1 – Our target TWR we wish to maintain

2 – The mass of the craft.

3 – The gravitational effect of a planet on our craft

4 – Our maximum thrust for the current stage

5 – The loss of mass over time (as we burn through fuel)

Regarding number 5, we don’t have to think about it too much. All we’re considering is the current mass of the craft, which will change as we burn through fuel, so I only mention it so we keep that in mind as we make our script.

Vizzy is new to me (this whole game is) but I think I get the gist of it. It’s a visual programming tool, and it allows us to make some scripts. With this in mind, I realize that I’m probably not going to be making the most optimal scripts here. This is a “Simple Scripts” guide after all. Perhaps in the future I will make better, more detailed scripts.

First, I’ll show you a screenshot of what it looks like, and then I’ll go over the process and math behind it:

Simple, right? So what’s going on here?

On start, we start the script.

We do a couple of display messages at 3 second intervals for no reason other than to pause for dramatic effect.

We set the throttle to 77%, no real reason just an arbitrary number (you can set this to 0 if you want.)

We activate the stage, wait 3 seconds, and then initialize a While(true) infinite loop. Bear in mind, that in this configuration this script will theoretically run forever, so there’s no further logic to this script. You’ll have to implement your own.

Now, the loop part of this, and the math. We want to maintain a certain TWR. I’ve created a custom variable called Target_TWR which takes in a float (decimal number) input. In my case I set it to 1.8 because I want to maintain a TWR of 1.8 throughout the entire burn. Obviously, if your craft cannot actually reach the target TWR, this will not work and your throttle will remain at 100% whilst attempting to reach the Target_TWR.

This loop has a single instruction, to set the throttle to a value. As such, this will continue to run and readjust the throttle every single frame (presumably). The value the throttle is being set to will ideally always be between 1 and 0. If the result of this operation is greater than 1, the throttle will default to 1, and if it is below 0, the throttle will default to 0.

Here’s the simple math:

Throttle% = (Target_TWR * (CurrentMass * CurrentGravity)) / MaxThrust

Try it yourself and mess around with the Target_TWR variable. Set it to 1 if you wish to maintain a hover. Though, any added force or momentum carried over from any previous action will inevitably force the craft to continue moving. So it won’t actually hover in this configuration. It’ll just maintain whatever speed is achieved between stage activation and loop start.

In the near future, I will expand upon this simple script, and show you a practical application for it in Juno. I think my next simple script will be a simple hover script at a desired altitude ASL.

I hope this simple script helps you, and gives you some ideas as to what you can do with scripts like these.

This guide about Juno: New Origins was written by Aloe. You can visit the original publication from this link. If you have any concerns about this guide, please don't hesitate to reach us here.

About the author