Fancy_Fox_Pers Posted May 25, 2015 Share Posted May 25, 2015 Hello , I want a creature to -like chester- have an inventory that's made accesible to all players but with only one slot. Here's the code I have :inst:AddComponent("container")inst.components.container:WidgetSetup("chester")It works just fine but it of course gives me 9 slots. How to make it a one slot container? Link to comment https://forums.kleientertainment.com/forums/topic/54383-how-to-add-a-one-slot-container-to-a-creature/ Share on other sites More sharing options...
Fancy_Fox_Pers Posted May 26, 2015 Author Share Posted May 26, 2015 Day 2. They still pretend I'm not a topic. XD JkSo... Anyone? Link to comment https://forums.kleientertainment.com/forums/topic/54383-how-to-add-a-one-slot-container-to-a-creature/#findComment-640766 Share on other sites More sharing options...
Fancy_Fox_Pers Posted May 26, 2015 Author Share Posted May 26, 2015 Ok, so to prove you guys I'm not asking you to completely do "this thing I want", here's what I got after further investigation : -I'm now aware that I need to make a new anim file, beginning for some reason with "ui" (example: "ui_rabbitchest_1x1"-I need to make a new WidgetSetup like "chester" or apply a new sort of container in a smiliar way-Here's some code I got from the Large Chest mod :local function makeChest() local container = { widget = { slotpos = {}, animbank = "ui_largechest_5x5", animbuild = "ui_largechest_5x5", pos = GLOBAL.Vector3(0, 200, 0), side_align_tip = 160, }, type = "chest", } for y = 3, -1, -1 do for x = -1, 3 do table.insert(container.widget.slotpos, GLOBAL.Vector3(80 * x - 80 * 2 + 80, 80 * y - 80 * 2 + 80, 0)) end end return containerendI don't really understand how to setup a "pos", a "side_align_tip" (actually, I'm not even that sure of what this really is) or how to properly change an "animbank" (I do know how to change the "animbuild" name) I also don't have a clue what this is : for y = 3, -1, -1 do for x = -1, 3 do table.insert(container.widget.slotpos, GLOBAL.Vector3(80 * x - 80 * 2 + 80, 80 * y - 80 * 2 + 80, 0)) end endAnd this is an example of how to actually make the WidgetSetup, right?AddPrefabPostInit("world_network", function(inst) if containers.widgetsetup ~= containers_widgetsetup_custom then OVERRIDE_WIDGETSETUP = true local containers_widgetsetup_base2 = containers.widgetsetup function containers.widgetsetup(container, prefab) containers_widgetsetup_base2(container, prefab) if container.type == "largechest" then container.type = "chest" end end end if containers.MAXITEMSLOTS < MAXITEMSLOTS then containers.MAXITEMSLOTS = MAXITEMSLOTS endend)So here's what I know, now what to do with it to get a 1x1 container for my creature? Thanks in advance Link to comment https://forums.kleientertainment.com/forums/topic/54383-how-to-add-a-one-slot-container-to-a-creature/#findComment-640793 Share on other sites More sharing options...
Seiai Posted May 26, 2015 Share Posted May 26, 2015 (edited) @Thibooms,i have a creature with one slot in my mod too, here's the related code:in your prefab above the main functions:local containers = require("containers")local overlordslot ={ widget = { slotpos = { Vector3(0,64+32+8+4,0), --Vector3(0,32+4,0), --Vector3(0,-(32+4),0), --Vector3(0,-(64+32+8+4),0) }, animbank = "ui_cookpot_1x4", animbuild = "ui_cookpot_1x4", pos = Vector3(200,0,0) }, --issidewidget = true, type = "chest",}local widgetsetup_old = containers.widgetsetupfunction containers.widgetsetup(container, prefab, data, ...) if container.inst.prefab == "overlord" or prefab == "overlord" then for k, v in pairs(overlordslot) do container[k] = v end container:SetNumSlots(container.widget.slotpos ~= nil and #container.widget.slotpos or 0) return end return widgetsetup_old(container, prefab, data, ...)endin the mainfunction of the prefab near the other componentstuff: inst:AddComponent("container") inst.components.container:WidgetSetup("overlord", overlordslot)and u probably want to add this in it's Stategraph somewhere in the deathstate:inst.components.container:Close() inst.components.container:DropEverything()ofc replace overlord with your prefabname. Edited May 26, 2015 by Seiai Link to comment https://forums.kleientertainment.com/forums/topic/54383-how-to-add-a-one-slot-container-to-a-creature/#findComment-640825 Share on other sites More sharing options...
Seiai Posted May 26, 2015 Share Posted May 26, 2015 (edited) I also don't have a clue what this is :for y = 3, -1, -1 do for x = -1, 3 do table.insert(container.widget.slotpos, GLOBAL.Vector3(80 * x - 80 * 2 + 80, 80 * y - 80 * 2 + 80, 0)) end endthis is pretty much what i do inslotpos = { Vector3(0,64+32+8+4,0), --Vector3(0,32+4,0), --Vector3(0,-(32+4),0), --Vector3(0,-(64+32+8+4),0) }but instead of having to list all the slots and their positions yourself, u generate them with a loop and some math^^ Edited May 26, 2015 by Seiai Link to comment https://forums.kleientertainment.com/forums/topic/54383-how-to-add-a-one-slot-container-to-a-creature/#findComment-640828 Share on other sites More sharing options...
Seiai Posted May 26, 2015 Share Posted May 26, 2015 I don't really understand how to setup a "pos", a "side_align_tip" (actually, I'm not even that sure of what this really is) or how to properly change an "animbank" (I do know how to change the "animbuild" name)pos and side_align_tip are just to position the widget and the slots in relation to the widget. side_align_tip is i guess the position of backpacks on the screen, so not really needed for containers in the gameworld. animbank and animbuild are related to the custom animationfile u could make, but since u dont seem to have done anything related yet, u will probably be satisfied with my solution anyway Link to comment https://forums.kleientertainment.com/forums/topic/54383-how-to-add-a-one-slot-container-to-a-creature/#findComment-640831 Share on other sites More sharing options...
Fancy_Fox_Pers Posted May 26, 2015 Author Share Posted May 26, 2015 (edited) This is awesome, @Seiai! Thanks! I do have to ask, why did you need this for an overlord? Edited May 26, 2015 by Thibooms Link to comment https://forums.kleientertainment.com/forums/topic/54383-how-to-add-a-one-slot-container-to-a-creature/#findComment-640898 Share on other sites More sharing options...
Seiai Posted May 26, 2015 Share Posted May 26, 2015 (edited) @Thibooms, http://wiki.teamliquid.net/starcraft2/Ventral_Sacs in my mod just for items though Edited May 26, 2015 by Seiai 1 Link to comment https://forums.kleientertainment.com/forums/topic/54383-how-to-add-a-one-slot-container-to-a-creature/#findComment-640979 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now