-
Notifications
You must be signed in to change notification settings - Fork 241
Description
This is a write-up of an issue reported by Pand5461 in the kOS discord server. This script gives an error when run from boot that it does not give when run manually from the command line:
Take the following two scripts and use them on a simple craft (bare minimum craft to launch from VAB works fine - probe core, kOS computer part, launch clamp for power and comms):
File /boot/pand5461_bug.ks : Make this the craft's boot script.
@lazyglobal off.
wait until ship:loaded and ship:unpacked.
if homeconnection:isconnected and homeconnection:delay <= 2 {
compile "0:/pand5461_test.ks" to "1:/pand5461_test.ksm".
}
runpath("pand5461_test.ksm").
lock steering to up.
unlock steering.
File pand5461_test.ks : Will be loaded by the above bootfile, and compiled to KSM:
@lazyglobal off.
function testfunc {
lock steering to up.
lock throttle to 0.
wait 1.
unlock steering.
unlock throttle.
}
If you run that from a boot on launchpad you get this error thrown from OpcodeReturn:
throw new KOSArgumentMismatchException(
string.Format("Something is wrong with the stack - no arg bottom mark when doing a return. This is an internal problem with kOS")
);
(Note that the script never actually calls the function testfunc. Just having it present in the compiled file, without running it, causes the problem.)
The error seems to be getting thrown from the automated "lock steering" trigger, when it hits its "return".
But if you run that from the interactive command line by doing runpath("boot/pand5461_bug.ks"). it works just fine.
The script requires all the the following to be true to cause the bug (don't know why yet). If you change any one of these, the bug won't happen:
- It MUST run the KSM compiled file
"pand5461_test.ksm". If you run the text script"pand5461_test.ks", then that works fine. "pand5461_test.ks"must have BOTH the lock steering and lock throttle statements to cause the bug. If one is removed, it doesn't happen."boot/pand5461_bug.ks"must have the lock steering statement inside it as well to cause the bug. If that's removed it doesn't happen.