KSP-KOS / KOS

Fully programmable autopilot mod for KSP. Originally By Nivekk
Other
691 stars 229 forks source link

VECDRAW's setting SHOW to false when it shouldn't. #1568

Open Dunbaratu opened 8 years ago

Dunbaratu commented 8 years ago

The following code exhibits the problem. Only the second vecdraw is visible on screen, because the first one gets reset to :show = false when the second one got made:

set vlist to list().
function make_vecdraw {
  parameter vec, label.

  set temp_vecdraw to vecdraw(v(0,0,0), vec, red, label, 1, true, 1).
  vlist:add(temp_vecdraw).
}

make_vecdraw(20*ship:north:vector, "north").
wait 0.01.
make_vecdraw(20*ship:up:vector, "up").
wait 5.

The following code does not have the problem. The mere changing of temp_vecdraw to a local instead of a global makes it so that both vecdraws remain visible.

set vlist to list().
function make_vecdraw {
  parameter vec, label.

  local temp_vecdraw is vecdraw(v(0,0,0), vec, red, label, 1, true, 1).
  vlist:add(temp_vecdraw).
}

make_vecdraw(20*ship:north:vector, "north").
wait 0.01.
make_vecdraw(20*ship:up:vector, "up").
wait 5.

Possible reason:

There is a feature in kOS to detect when a VECDRAW has been fully orphaned away and can't be accessed from the kerboscript code anymore. When that happens the vecdraw is hidden so that users won't have a big arrow on screen they can't get rid of. That feature is probably misfiring here in some way.

lukfal94 commented 8 years ago

I think you mixed up your code excerpts and text. The problem occurred when I used set temp_vecdraw to ... and was resolved with local temp_vecdraw is ...

Dunbaratu commented 8 years ago

right. edited the description.