-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The given key was not present in the dictionary (probably solved?) #1347
Comments
I could narrow down the error. This code caused errors
while this one worked
You see the only real diffenences are the name of the variable it's now called maxTWR instead of limitTWR and the use of the SET SHIP:CONTROL:PILOTMAINTHROTTLE TO newThrottle instead of LOCK THROTTLE TO newThrottle. The last had to be changed due to another strage behavior where the thrust jumps up and down like crazy but thats not important here. If I had to guess what caused the crash I would say it was caused by the variable called like the function. Here is the now working code: |
Yeah I think this is a duplicate of an existing issue, then. |
I started doing a little debugging on this issue. It appears that you are correct, the root of the problem is that the function and the variable shared the same name. Under the hood, locks and functions share a naming structure ("$[name]*"). So kOS was trying to pull the "default" value of a So as you surmised, changing the name of the variable was the best fix to your problem. We could probably do something to improve the error message in this instance however to give you a chance at identifying the source of the issue instead of randomly changing things. Two other comments before I finish: First, you don't really need that extra variable in the function anyways because you can reference Second, I am not a fan of repeatedly locking the throttle or steering. We're working on updating our tutorial so that it doesn't imply this is a good code practice. Every time you create a new steering or throttle lock, the underpinnings of kOS set up the user function that returns the set value, as well as toggling the control parameter "on". It isn't as huge of an issue with the throttle, but it will reset the steering's integral component every time. You might consider revising the function to return the new throttle value, and then in your main body
or if you don't want to evaluate the whole function every single physics tick:
|
While trying to write an autopilot for launching a rocket I've got this error.
It appears while loading a custom lib written by me that contains all the functions of the script. Since there isn't a line of code that causes the error I'm not able to tell where it stoped working, The last thing I was working on was to regulate the throttle by locking at the TWR. --> function limitTWR and function startGravityturn.
Since this is one of my first scripts I probably did something horrible wrong and it's all my fault but as it tells me to show it to the dev's thats what I'm doing :)
Here are my two files that caused the Error:
launch003.ks.txt
lib_launch.ks.txt
and here is the output_log:
output_log.txt
Thanks for your help and greetings from Germany
The text was updated successfully, but these errors were encountered: