Has there been an FFF that discusses the software architecture for the player inventory?

Post all other topics which do not belong to any other category.
Post Reply
sniderthanyou
Inserter
Inserter
Posts: 22
Joined: Tue Jul 05, 2016 11:43 am
Contact:

Has there been an FFF that discusses the software architecture for the player inventory?

Post by sniderthanyou »

Hey team! I'm an experienced software engineer, and starting to learn game development as a hobby. I love how Wube is happy to share so many technical details about the Factorio engine.

The Factorio inventory seems to handle many special cases:
- some items stack
- some can be consumed to affect the player (fish)
- some can be consumed to affect the environment (cliff grenades)
- some can be consumed to affect enemies (grenades)
- some are consumed by other actions (ammo)
- some can be placed in the world (assemblers)
- some have durability (pretty much any structure, like turrets)
- some are used but not consumed (spidertron remote)

And there are probably other cases that I'm forgetting. I have reached the point in my learning where I understand how to add/read/remove items in an inventory, render then with an optional stack counter or durability, etc. But when the player wants to use the items, I'm a bit stuck. Most tutorials do one of two things:

1. The Player knows what each item does (this is not very extensible)
2. Each item knows what it does, and how to affect the player / world (more extensible)

And in some online discussions, I've seen that some people will separate the Effect from the Item, so that Items just have a list of Effects, and the Effects know how to affect the player / world.

Have there been any FFFs to discuss how this is handled in Factorio? I would be very interested to hear how the great minds at Wube have decided to solve this.

Erik

Bilka
Factorio Staff
Factorio Staff
Posts: 3150
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Has there been an FFF that discusses the software architecture for the player inventory?

Post by Bilka »

If you have entirely no idea how we handle items, here is an FFF on ItemStacks which has some info on items themselves: https://factorio.com/blog/post/fff-198

As you can see, in our case we have the information on the item (things that are modified runtime, e.g. current durability) and item prototype (behaviour defined at startup) and its subtypes. Though something like "some can be placed in the world (assemblers)" is just defined as an item that places an entity, which is a completely separate class. I would suggest you give the Lua api documentation a bit of a browse to get a general concept of the class structure. Of course the Lua API isn't the same as what we do in the C++, but it gives an overview for general concepts like "where does this info live".
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

sniderthanyou
Inserter
Inserter
Posts: 22
Joined: Tue Jul 05, 2016 11:43 am
Contact:

Re: Has there been an FFF that discusses the software architecture for the player inventory?

Post by sniderthanyou »

You're the best, Bilka! I'm ready to dig in.

Post Reply

Return to “General discussion”