Jump to content

Probabaly a side effect of Unpack like behavior?


Recommended Posts

Context: Question is Regarding KOS code development.

 

So I have a new weird difficulty.

Ive been trying to write some code that looked at what parts ships have that are a long way away from the CPU SHip.

Indeed i wanted to do that for all 50 ships in the game at the time so I could decide which ones actually had relay parts.

This code snippet prints out (and logs see below) that the Variable is indeed a  >> Hop AS VESSEL("Hop")<<

With or without the wait the LOC      local MyParts is AShip:Parts.  go bang (but only on new chip each time) and says
 

Code snippet:

Spoiler
 
 
 
1
Spoiler

    Print AShip:Name + " AS " + AShip.
    Log AShip:Name + " AS " + AShip to "MyLog.txt".
  wait 0.2.
    local MyParts is AShip:Parts.
    Print " No Bug ".
    Log " No Bug " + AShip to "MyLog.txt".

 

Spoiler
 
 
 
1
Spoiler

Actual Log File

2G Malaya OneTreeHill AS VESSEL("2G Malaya OneTreeHill")
 No Bug VESSEL("2G Malaya OneTreeHill")
Boab Tree Plain AS VESSEL("Boab Tree Plain")
 No Bug VESSEL("Boab Tree Plain")
Jump AS VESSEL("Jump")
 No Bug VESSEL("Jump")
Tag AS VESSEL("Tag")
 No Bug VESSEL("Tag")
Hop AS VESSEL("Hop")


after running the program a few times all the other vessels up to there now have parts... Each time one extra vessel agree it has parts too.

Error Text:  object reference not set to an instance of an object.

But it just Printed out that it was a  "Vessel("Hop")" .

Conclusion?

Ok so I'm not allowed to inspect parts of vessels that long way away. (I was pleasantly surprised when i found i could rename them)
but the weird bit is if I run the program second time it works for "Hop", then barfs at the next new ship (as I am looping through all of them).

Huh?

Does anyone know what will happen if I ran the program enough times to get all 50 ships loaded and unpacked or whatever it is that is causing it?

I could make another CPU power cycle this CPU 50  times.... : but hat seems way too kerbal to be sane.

=============

I have one or more work arounds.... I write save file parser in C++ and do the task I was doing in game outside the fourth wall.

Also currently all 50+ ships (except the one running the code) are all landed relays. So I don't reallly need to check.

What worries me is just how big a kraken i might summon if I kept unpacking or whatever it is I am doing by rerunning the program.

Questions:

Am I right in thinking that when I get a Ship via list targets in AllShips thats its parts are expected not to be available?

I cant currently as too many ships have the same name. But I if I create a

local AShip Vessel("a unique Ship name").

Will that improve accessibility to its parts list?

======

Addendum: I also discovered something else today. if your code goes boom and terminates the entire KSP game,really unceremoniously. As in poof its gone.

Its plausible one of your collection objects has reference to itself containing itself and thus forms a DCG not a DAG. That makes things like PRINT Object_that_recusively_contains_reference_to_itself go boom.

 

================

reading

================

 

Edited by AxleGreaser
addendum context
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...