Jump to content

Help with containers


Recommended Posts

local Vector3 = GLOBAL.Vector3
local modparams = {}

modparams.oneslot =  {
	widget =
	{
		slotpos = 
		{
		Vector3(525, -395, 50),
		},
		animbank = "ui_oneslot_1x1",
		animbuild = "ui_oneslot_1x1",
		pos = Vector3(525, -395, 50),
	},
	type = "oneslot",
}

table.insert(modparams.oneslot.widget.slotpos, Vector3(0, 0, 0))

local containers = require("containers")

for k, v in pairs(modparams) do
	containers.MAXITEMSLOTS = math.max(containers.MAXITEMSLOTS, v.widget.slotpos ~= nil and #v.widget.slotpos or 0)
end

local oldwidgetsetup = containers.widgetsetup
function containers.widgetsetup(container, prefab, data, ...)
	if container.inst.prefab == "trusty_shooter" or "wheeler_tracker" then
		for k, v in pairs(modparams.oneslot) do
			container[k] = v
		end
		container:SetNumSlots(container.widget.slotpos ~= nil and #container.widget.slotpos or 0)
		return
	end
end

Been having trouble with containers. My slot works but for some reason it gives it to all containers, Backpacks and chests get the same UI, Is there a way I can restrict it just to my 2 items?(The Pew matic horn aka trusty_shooter and Navigadget aka wheeler_tracker)

Link to comment
Share on other sites

Change this:

if container.inst.prefab == "trusty_shooter" or "wheeler_tracker" then

to this:

if container.inst.prefab == "trusty_shooter" or container.inst.prefab == "wheeler_tracker" then

Then see how it works out. An actual string is always considered "true" in LUA IIRC, so because you had forgotten to actually compare the second string against something, it always entered your if-statement.

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...