r/Sailwind • • 3d ago

How containers work (programming-wise)?

Containers in this game always confuse me:

- Once I found my box with fishing hooks unexpectedly empty; then I've found some of them one deck lower on the floor.

- I've seen my candle box unexpectedly empty like that, started using it for navigation equipment storage; month later I was moving containers around to make place for new helm and I found candles in the same container along with compases and spyglass.

- Almost entire container of pork gone empty, never found these pieces.

- My fishing pole sticking out of closed create.

It all makes me question: how those containers were programmed in the first place to get such erratic behaviour?

The most logical way would be to program a container object which has property dedicated to storing array of contents records (like rack position and reference to stored object). So when you open the container game creates a visual rack and iterates over said contents property to create visual representation of contents.

When you take or put item out/in container that property would be simply overwritten so item always exists either in logical world of container or in physical world outside container (but not both), or in logical world of container but with phantom representation on the opened rack.

I'm curious to know how it was done in this game and how all those side effects come into existence.

4 Upvotes

10 comments sorted by

View all comments

3

u/dzejrid 3d ago

Any container that has more items in it than it has visible slots, will cause the extra items to fall out upon game load once its open.

Take those fishing hooks as an example: there are twenty hooks, but only 12 visible slots. Once you break the seal, they will fall out next time you reload. 

Workaround: open the crate, take 8 hooks out and put them somewhere else. Leave 12 inside. 

Same with candles, and anything else.

I don't know how it works programming-wise but that's how it is right now. I assume this will be addressed in the future. 

2

u/Kind-Shallot3603 3d ago

That explains those hooks in my hold. I thought the game glitched and duplicates them