Closed Feinbube closed 8 years ago
It probably is because there is no such thing as throttle variable before you lock it (setting throttle does nothing!). If you want to get the current throttle try using this: http://ksp-kos.github.io/KOS_DOC/commands/flight/pilot.html#ship-control-pilotmainthrottle or this: http://ksp-kos.github.io/KOS_DOC/commands/flight/raw.html#ship-control-mainthrottle. I'm not sure what is the difference because I never used mainthrottle
.
Note: one more cryptic error message. Could you send us your KSP_Data\output_log.txt where this error is the last one to happen?
What I intended to do was to create a HUD in putty showing me current infos about the ship. Both, Mainthrottle and Throttle seem to be problematic: https://github.com/KSP-KOS/KOS/issues/991
KSP_Data\output_log.txt:
kOS: At interpreter history, line 1
print throttle.
^
(Filename: C:/buildslave/unity/build/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 56)
System.NullReferenceException: Object reference not set to an instance of an object
at kOS.Function.FunctionPrint.Execute (kOS.SharedObjects shared) [0x00000] in <filename unknown>:0
at kOS.Function.FunctionManager.CallFunction (System.String functionName) [0x00000] in <filename unknown>:0
at kOS.Execution.CPU.CallBuiltinFunction (System.String functionName) [0x00000] in <filename unknown>:0
at kOS.Safe.Compilation.OpcodeCall.Execute (ICpu cpu) [0x00000] in <filename unknown>:0
at kOS.Execution.CPU.ExecuteInstruction (IProgramContext context) [0x00000] in <filename unknown>:0
(Filename: C:/buildslave/unity/build/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 56)
Code Fragment
File Line:Col IP opcode operand
---- ----:--- ---- ---------------------
0:0 0000 jump 1
interpreter history 1:1 0001 push $<argstart>
interpreter history 1:7 0002 push $throttle
interpreter history 1:7 0003 call print() <<--INSTRUCTION POINTER--
interpreter history 1:7 0004 pop
0:0 0005 EOF
(Filename: C:/buildslave/unity/build/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 56)
kOS: Stack dump: stackPointer = 0
000 SP-> $<argstart>
(Filename: C:/buildslave/unity/build/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 56)
lock throttle
just lock it before accessingSo this behavior is intended? Your 2. suggestion is what I'm doing at the moment.
It's not intended that you ever have to deal with a null without some safety check being available.
I don't think it actually returns a null. It probably crashes while trying to get a special variable that is not set yet.
@abenkovskii i was inarticulate before. If there is a chance that you will end up with a binding that might throw some nasty error at you. I like for there to be some way for you to ask if it is in a bad state.
This situation was something i ran into awhile ago but after squad made the baffling choice to start us out with 0.5 throttle on the pad i didnt see where we could assert a starting throttle without a more complex system then i was willing to add at the time.
closing as wontfix because @erendrake's comment makes it look like that was the intent.
kOS Operating System KerboScript v0.17.2
Proceed. print throttle. Object reference not set to an instance of an object At interpreter history, line 1 print throttle. ^