Jump to content

question on making chest inventory bigger or smaller


Recommended Posts

So if I were to want to make a chesters inventory larger than Shadow Chesters inventory, what would I need to do? I am at a loss on this one here. After Afe and I got Big Daddy to behave himself to the point of where he's working fully, we've been working on making the inventory of Big Daddy much larger (to match his fat stomach and how slow he walks)

 

BUT we havent been able to figure this part out. It's not as simple as we had thought, is the easiest way going to be making an all new container widget just for Big Daddy?

 

Also for Afester there is a few inventory changes we are making for when he transforms that we would like to make the inventory smaller as well.

 

Also I am extremely new to coding. I 'think' I understand the functions, but at the same time I still question a lot of it. Im mainly just the design and animator, but sometimes I need to step in for the code. So please, when you post something about the inventory slots and code, could you explain a little as well and elaborate? Im done with just poking and guessing.

Link to comment
Share on other sites

is the easiest way going to be making an all new container widget just for Big Daddy?
 Yes, although I believe there is still a bug with this on clients. You can look at containers.lua for the layouts of all of the game's existing container widgets, and you could take one of them. For example, the ice pack:
params.icepack ={    widget =    {        slotpos = {},        animbank = "ui_icepack_2x3",        animbuild = "ui_icepack_2x3",        pos = Vector3(-5, -70, 0),    },    issidewidget = true,    type = "pack",}for y = 0, 2 do    table.insert(params.icepack.widget.slotpos, Vector3(-162, -75 * y + 75, 0))    table.insert(params.icepack.widget.slotpos, Vector3(-162 + 75, -75 * y + 75, 0))end

The for loop sets the positions of the item slots in the widget. So for the ice pack it's doing 3 rows (y = 0, 1, 2), and for each row it's making two slots. Slots are spaced 75 apart in both directions. The animbank animbuild are the background/frame for the widget. If you want one that's not the same size as any existing game container, then you'll have to make the art for this. I'm not the best one to ask about that, though.

Link to comment
Share on other sites

alright, and for linking this widget to big daddy, which part in the code would be linking him to the actual file?

 

Sorry for asking so many questions, just loking and sifting through the code it all looks like it's chasing its own tail.

Link to comment
Share on other sites

@Kooky, So you can define a set of params like that in the prefab for big daddy, and then pass it to the widgetsetup function. So instead of params.icepack = { ... }, you'd do bigdaddy = { ... }, then where it says inst.components.container:WidgetSetup("chester"), you do inst.components.container:WidgetSetup("bigdaddy", bigdaddy).

 

I believe it still calls it with the prefab name on clients, however, so to get around that you need to override the widgetsetup function in your modmain. Hopefully this gets fixed at some point, but meanwhile you want something like this:

bigdaddy_params = { ... }local oldwidgetsetup = GLOBAL.containers.widgetsetupGLOBAL.containers.widgetsetup = function(container, prefab, data, ...)    if prefab == "bigdaddy" then        data = bigdaddy_params    end    oldwidgetsetup(container, prefab, data, ...)end
Link to comment
Share on other sites

So I tried this, attempted to make a widget and everything under the name containers.lua but for some reason or other it created a crash instead. Said some sort of crap about it not linking with something which I did not fully understand.

Link to comment
Share on other sites

@Kooky, Remove the GLOBALs from it, and add this line above:

GLOBAL.require('containers')

Edit: But in the future, do post that crash. The error you described is one that makes sense to me and that I would've been able to diagnose the problem from.

Edited by rezecib
Link to comment
Share on other sites

local widgetchester = {	widget = {		slotpos = {},		animbank = "ui_chest_3x3",		animbuild = "ui_chest_3x3",		pos = Vector3(0, 200, 0),		side_align_tip = 160,	},	type = "chest",}for y = 2, 0, -1 do	for x = 0, 2 do		table.insert(widgetchester.widget.slotpos, Vector3(80 * x - 80 * 2 + 80, 80 * y - 80 * 2 + 80, 0))	endend----------	if not TheWorld.ismastersim then		inst:DoTaskInTime(0, function()			inst.replica.container:WidgetSetup(nil, widgetchester)		end)		return inst	end	inst.entity:SetPristine()		inst:AddComponent("container")	inst.components.container:WidgetSetup(nil, widgetchester)

Also works for me.

When the entity replicates, you need to setup the client widget because the game won't find it in params with the current widgetsetup function.

Link to comment
Share on other sites

Loot at this mod:

http://steamcommunity.com/sharedfiles/filedetails/?id=382177939

 

I helped Afro to make it compatible with any other mod which uses proper API style. It would be better if you will use proper API style too. The main feature of that code is that it supports very big containers (does not matter how big they are). However you can use your current code if your containers are not so big. :)

 

Link to comment
Share on other sites

We ended up using a code similar to the large chest mod since Big Daddy isn't supposed to have a gigantic inventory. Thanks for the help though :)

 

Our next project is party chester, he morphs into different types of pinatas. The point of the pinatas is to kill them to drop stuff (hence the term pinata and party chester)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...