lua code inventory tabs

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Phakx
Inserter
Inserter
Posts: 32
Joined: Sun Sep 07, 2014 8:57 pm
Contact:

lua code inventory tabs

Post by Phakx »

Hey i'm looking for the lua code for the inventory tabs but i didn't finde anything :(
Could someone give me this code line or better: i need code to define a parameter called "tabs" which defines the count of inventory tabs in a container.
I'm not good in hard coding so i need really big help of the community.
Check out my "TrueBuildings" - Mod

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: lua code inventory tabs

Post by FreeER »

Phakx wrote:i need code to define a parameter called "tabs" which defines the count of inventory tabs in a container.
If you mean "tabs" like the item groups in the player's inventory or the recipe selection in assembler's but for another container then I'm fairly certain that you can't define that. I'd ask if you simply mean the number of slots in an inventory, but I'm fairly sure that not having the inventory_size 'node' would cause Factorio to throw an error...

User avatar
Phakx
Inserter
Inserter
Posts: 32
Joined: Sun Sep 07, 2014 8:57 pm
Contact:

Re: lua code inventory tabs

Post by Phakx »

Is there a maximum of slots defined in a container? So could i expand them to like 1000?
Check out my "TrueBuildings" - Mod

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: lua code inventory tabs

Post by FreeER »

The number of slots in an inventory is defined by the "inventory_size" property/node in the container prototype, the technical limit is probably about 32 thousand... but since I don't believe Factorio will add scroll bars to the inventory the practical limit is going to be determined by the resolution/size of the player's screen, I doubt that's more than 200, for reference the player's inventory is 60 slots.

User avatar
Phakx
Inserter
Inserter
Posts: 32
Joined: Sun Sep 07, 2014 8:57 pm
Contact:

Re: lua code inventory tabs

Post by Phakx »

Any other solution except hard coding in lua?
Because i wanted a storage building.
Check out my "TrueBuildings" - Mod

User avatar
Phakx
Inserter
Inserter
Posts: 32
Joined: Sun Sep 07, 2014 8:57 pm
Contact:

Re: lua code inventory tabs

Post by Phakx »

I coded my shelter. Works fine except the gui. Thats my big problem and which i need the tabs for.

Image
Check out my "TrueBuildings" - Mod

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: lua code inventory tabs

Post by FreeER »

yeah, well the only solution to that (other than asking the devs for scroll bars on everything lol) is to use the Lua GUIs like testmode does and simulate one. The possible Lua gui positions are either top, left, or center and are accessed with game.player.top for example (see wiki). To one of those you'd add a lua gui element, probably a frame (gives you a background and has a direction for how new elements to it are added, horizontal or vertical), to which you'd add a table, and to that you'd add buttons representing the items...when the player clicks a button (Identifier is based on the name so make it unique) you can check if the player's cursorstack is empty, if so check if the button was representing a real item or was 'empty', if the player had something in their cursorstack then place it in the button 'slot' (assuming it's empty).
edit: I did write some GUI code for DyTech's modular tool craft so you could look at that here also (and the calling/event code is in the control.lua)

User avatar
Phakx
Inserter
Inserter
Posts: 32
Joined: Sun Sep 07, 2014 8:57 pm
Contact:

Re: lua code inventory tabs

Post by Phakx »

Okay but then there could be the problem that if i drop a item inside the second page for example that it didnt save the data. So the item just vanish.
Also i have to figure out how gui code works and how i design a frame :D
Check out my "TrueBuildings" - Mod

Post Reply

Return to “Modding help”