EDCD / EDDI

Companion application for Elite Dangerous
Other
451 stars 82 forks source link

'inventory' always blank during the 'Location' event #2622

Closed Darkcyde13 closed 5 months ago

Darkcyde13 commented 5 months ago

What's Wrong (please be as specific as possible)

Expected

The 'inventory' object to always be populated when you are carrying cargo.

Observed

When used within the 'Location' event, either while playing the game, or clicking the test button, 'inventory' is empty, even when you have cargo on board.

Steps to reproduce

  1. Have some cargo in your ship.
  2. Create a blank script, and add this code:
    {for cargo in inventory:
    {cargo.name}
    }
  3. Run the code and check the inventory list is correct.
  4. Add that same code to the end of the 'Location' event script and run the script.
  5. Observe that the inventory is blank.

Configuration

My Investigation

Investigation Notes

I first noticed this when looking into adding some functionality that CMDR Yianniv provided to me regarding corrosive cargo, using v4.0.4-b1. I wanted to add a call to the code at the end of the 'Location' event script, but I was getting odd results, like I had no cargo, even though I had a few Thargoid items on board.

I narrowed it down to 'inventory' being empty during the 'Location' event (although 'cargoCarried' is correct). As 'Location' comes straight after 'Commander continued' when starting a game, I added the call to the 'Commander continued' script, and it worked as expected there, but not in 'Location'. As a workaround, I've set it to a State() variable in 'Commander continued' which I then use at the end of the 'Location' script.

I've tried going back to v4.0.3, but that is the same.

EDDI Logs

I'm not seeing any entries in the log for this.

Player journals

N/A

Tkael commented 5 months ago

I apologize but I am unable to replicate the issue by injecting

{for cargo in inventory:
    {cargo.name}
}

at either the start or end of the default Location event.

Perhaps your personality is overwriting the inventory variable the same way we saw recently with state? This might happen indirectly if you call another script which does this.

For the default personality I do see some scripts which set inventory to a new value. I'll plan to update these to prevent a conflict.

Darkcyde13 commented 5 months ago

Hmm, OK. I tried it with a copy of the default EDDI personality (yeah, I know, I should have done that first. It was late, I was tired. ๐Ÿ˜… ) and yep it worked. So I looked into my version of the Location script, adding that code snippet at the very start, and it worked.

Well, to cut a long story short as they say, I traced it to a call in 'Location' to my 'System Exploration Report' script, and from there I traced it to the 'System material report'. In that script is a line setting 'inventory' to an inline function! {set inventory(materialName) to: and it's THIS that was messing everything up for me! This is line 99 in the EDDI default, so that's another instance that needs to be changed along with the four you mentioned above.

I have gone through my personality and changed all instances of {set inventory... to {set materialInventory... as, so far, they are all used with regards to materials. I may shorten it to just matInventory, but for now materialInventory works fine.

Thank you for pointing me in the right direction! I don't think I would have traced it so easily otherwise. ๐Ÿ˜„

Tkael commented 5 months ago

Hmm, OK. I tried it with a copy of the default EDDI personality (yeah, I know, I should have done that first. It was late, I was tired. ๐Ÿ˜… ) and yep it worked. So I looked into my version of the Location script, adding that code snippet at the very start, and it worked.

Well, to cut a long story short as they say, I traced it to a call in 'Location' to my 'System Exploration Report' script, and from there I traced it to the 'System material report'. In that script is a line setting 'inventory' to an inline function! {set inventory(materialName) to: and it's THIS that was messing everything up for me! This is line 99 in the EDDI default, so that's another instance that needs to be changed along with the four you mentioned above.

I have gone through my personality and changed all instances of {set inventory... to {set materialInventory... as, so far, they are all used with regards to materials. I may shorten it to just matInventory, but for now materialInventory works fine.

Thank you for pointing me in the right direction! I don't think I would have traced it so easily otherwise. ๐Ÿ˜„

Nice sleuthing! :-)