Fancy_Fox_Pers Posted December 12, 2015 Share Posted December 12, 2015 (edited) Not true. Both zips are there, even in the zip I posted. Whoops, completely derped. I was distracted by all the anim files. But yeah, the log talks about banks (related to builds). What ZupaleX says is correct (as always). Edited December 12, 2015 by Thibooms Link to comment https://forums.kleientertainment.com/forums/topic/60639-need-help-customized-backpack-starting-item/page/2/#findComment-696883 Share on other sites More sharing options...
ZupaleX Posted December 12, 2015 Share Posted December 12, 2015 Because in my explanation, I was taking especially the example of a return in an entity constructor function. and these functions always return the instance you created, thus the "return inst". But it's offtopic and if you want more detailed info about this kind of stuff you should start a new one, I'll gladly answer. Link to comment https://forums.kleientertainment.com/forums/topic/60639-need-help-customized-backpack-starting-item/page/2/#findComment-696884 Share on other sites More sharing options...
Fancy_Fox_Pers Posted December 12, 2015 Share Posted December 12, 2015 Oh no it's alright, I got it now, thanks! I'll let you finish here, I'm clearly making a mess xD Link to comment https://forums.kleientertainment.com/forums/topic/60639-need-help-customized-backpack-starting-item/page/2/#findComment-696886 Share on other sites More sharing options...
naptimeshadows Posted December 12, 2015 Share Posted December 12, 2015 (edited) Your build is not correct. Line 32inst.AnimState:SetBuild("swap_rucksack")should beinst.AnimState:SetBuild("rucksack")actually, if you want to retrieve an animation stored in "rucksack.scml".Basically, the build is the name of your scml file, then bank is the name of the entity in your scml file, and the animation is the name of the animation under a certain entity in the scml file.I changed that, and got this error on load when the sack is a starting item.I still don't totally understand which portion controls slot size, if that matters.Maybe there's a small piece concerning that causing an issue?EDIT::I moved things around, and instead of getting that weird error I attached, I get that error about line 29 again, the same one I attached in a previous post.In case it helps, I'm attaching the updated mod, though I deleted the anim's for reduced size.Any idea what to do from here?I'm at wits end.nelsonxx.zip Edited December 12, 2015 by naptimeshadows Link to comment https://forums.kleientertainment.com/forums/topic/60639-need-help-customized-backpack-starting-item/page/2/#findComment-696889 Share on other sites More sharing options...
ZupaleX Posted December 13, 2015 Share Posted December 13, 2015 (edited) line 64 inst.components.container:WidgetSetup("rucksack")as far as i can see, you did not define anywhere a widget setup called "rucksack". EDIT: Ok i checked your modmain and I saw you attempted to define your params there. And this is a big NO.You do something that is awgul : overriding the original containerswidget.widgetsetup (or at least you try to do that). That's something that should never be done, and I say NEVER. You destroy the compatibility of other mods by doing so and you should just never override original game function except if you know what you're doing and have a return of the original result in case it's not executed by your mod. Remove all of this from your modmain.lua and check out the quiver.lua from "Archery Mod" or miningmachine.lua from "Mining Machine" mod to have an example of how to properly make a new container with a new setup for your container widget. I know I link stuffs to my own mods, it's not to make commercial of my work, just because I know them better After reading that if you need more detailed explanation about what's done, ask me. Edited December 13, 2015 by ZupaleX Link to comment https://forums.kleientertainment.com/forums/topic/60639-need-help-customized-backpack-starting-item/page/2/#findComment-697032 Share on other sites More sharing options...
Cuddlepuff Posted December 13, 2015 Author Share Posted December 13, 2015 I have found my problem. The picture needed to be at 128x64 and 128x128 big, but my friend made the picture slightly bigger. I told him to re-arrange it and now it works perfectly fine. Link to comment https://forums.kleientertainment.com/forums/topic/60639-need-help-customized-backpack-starting-item/page/2/#findComment-697035 Share on other sites More sharing options...
naptimeshadows Posted December 13, 2015 Share Posted December 13, 2015 (edited) line 64 inst.components.container:WidgetSetup("rucksack")as far as i can see, you did not define anywhere a widget setup called "rucksack". EDIT: Ok i checked your modmain and I saw you attempted to define your params there. And this is a big NO.You do something that is awgul : overriding the original containerswidget.widgetsetup (or at least you try to do that). That's something that should never be done, and I say NEVER. You destroy the compatibility of other mods by doing so and you should just never override original game function except if you know what you're doing and have a return of the original result in case it's not executed by your mod. Remove all of this from your modmain.lua and check out the quiver.lua from "Archery Mod" or miningmachine.lua from "Mining Machine" mod to have an example of how to properly make a new container with a new setup for your container widget. I know I link stuffs to my own mods, it's not to make commercial of my work, just because I know them better After reading that if you need more detailed explanation about what's done, ask me.Alright.So, I copied the quiver stuff as-is, replacing the name where I can.Is there any other piece I need to edit?There is a lot here, and I still don't know what pieces limit item type or number of slots.I don't want to cause more issues for myself.EDIT::I made those changes, moving all widget pieces from modmain to the rucksack lua itself.I get the following error, which I don't know how to interpret.rucksack.lua Edited December 13, 2015 by naptimeshadows Link to comment https://forums.kleientertainment.com/forums/topic/60639-need-help-customized-backpack-starting-item/page/2/#findComment-697150 Share on other sites More sharing options...
ZupaleX Posted December 13, 2015 Share Posted December 13, 2015 (edited) So yeah, the issue is that you replaced all the "quiver" entries by "rucksack" but I think you did not always understand what you replaced (no offense here). There are several people here who wanted to make their own backpack. You want to just replace the model in game as well as some stats or you also want a custom amount of slots and/or a custom background of the container widget when opening your rucksack? Do you want a custom position on screen? If the answer to all of these questions is no, then you can ignore code between line 21 and 138 and remove the lines 145 to 151. Then just put in the rucksackfn function inst.components.container:WidgetSetup("backpack")if you want to use the regular backpack layout. If you want another built-in layout, check out containers.lua for the list. If the answer to one of these question is yes, then you'll need to keep some parts of the code. I'll quickly process through the different part of the rucksack.lua code that you have right now. Lines 8 to 19This is here as a failsafe, in case some other modders, who are not as careful and caring as you and me, decide to override the containers.widgetsetup function from the original game files. To prevent a crash if somebody butchered the original function, I first recover the CURRENT copy in memory of the table returned by containers.lua withlocal containers = require "containers"then I recover a copy of the CURRENT widgetsetup function. So if nobody modified it, it will be the original one, if somebody modified it (something that should not be done, but a lot of modders did it...) then I recover the modified version and store it in a local function that I call prev_widgetsetup withlocal prev_widgetsetup=containers.widgetsetupI then declare a new function which is actually a copy paste of the original widgetsetup function as defined by Klei and call it "mywidgetsetup"local function mywidgetsetup(container, prefab, data) local t = data or params[prefab or container.inst.prefab] if t ~= nil then for k, v in pairs(t) do container[k] = v end container:SetNumSlots(container.widget.slotpos ~= nil and #container.widget.slotpos or 0) endendSo finally, when in your rucksack constructor function you add the container component and setup the widget you do the following thing.1- You add the container component2- You replace the CURRENT containers.widgetsetup function which is use to configure the widget associated to your container (background image, amount of slots, ...) with "mywidgetsetup" which is just a copy of the original Klei's function3- You setup your container's widget with this function4- You restore the function as it was before you did anything. This way, if it was modified by another modder (which did not do a really good job), it won't crash the game because the function was restored to its original state.This is done by this part in the constructor function (lines 225 to 228) inst:AddComponent("container") containers.widgetsetup = mywidgetsetup inst.components.container:WidgetSetup("backpack") containers.widgetsetup = prev_widgetsetup Then, let's say you don't like the existing widget layouts for your rucksack and want to make your own. You'll need to define new widget params to use with the widgetsetup function.That's done here (lines 21 to 33)local rucksackwidgetparams = { widget = { slotpos = {Vector3(0, -5, 0)}, animbank = "ui_rucksack_1x1", animbuild = "ui_rucksack_1x1", pos = Vector3(0, 0, 0), }, issidewidget = false, type = "rucksack", } slotpos is a table containing the position of the slots. Here you copied my quiver.lua, so the quiver just has one slot, thus slotpos is a table with just one entry. I'm quite sure you want your rucksack to have more than one slot so you should add more entries in slotpos. You can do it with some for, just take a look at the backpack parameter in containers.lua pos is the position of the widget itself. 0, 0, 0 will put it at the middle of the screen (if your container is not defined as a sidewidget, controlled by issidewidget. In the case of the quiver, I did not want it to be a sidewidget, but the backpacks are sidewidget. Then their anchor point is not at the middle of the screen but at the top right corner if I'm correct, so take this into account when changing the value of pos). animbank and animbuild are like for the AnimState of entities. And that's where I'm quite sure you did a too-quick replacement of quiver by rucksack. It requires a spriter file for that containing the png of the background you wish to use as well as the "open" and "close" animation. You can decompile with krane the anim ui_backpack_2x4 that you'll find in the anim folder of Don't Starve. Here you'll see the anim required for a spriter project related to a container widget. Concerning the open, and clientopen stuffs, try to comment out stuffs related to that for the moment and make your stuff work for the host first. When that'll be done, we can discuss about that part of the code. Good luck. Edited December 14, 2015 by ZupaleX Link to comment https://forums.kleientertainment.com/forums/topic/60639-need-help-customized-backpack-starting-item/page/2/#findComment-697262 Share on other sites More sharing options...
naptimeshadows Posted December 14, 2015 Share Posted December 14, 2015 Yes, I am trying to make a backpack that is 3x10 slots. I don't need anything fancy, I just want more storage when I'm gathering. The opening/closing features are irrelevant, since it should be mounted on the side like any other backpack. I made those changes, but I still have the same error as before, the one that doesn't list the actual line causing the issue.rucksack.lua Link to comment https://forums.kleientertainment.com/forums/topic/60639-need-help-customized-backpack-starting-item/page/2/#findComment-697541 Share on other sites More sharing options...
ZupaleX Posted December 14, 2015 Share Posted December 14, 2015 Did you create a spriter project with a background for your rucksack container widget and the opening/closing animations? Link to comment https://forums.kleientertainment.com/forums/topic/60639-need-help-customized-backpack-starting-item/page/2/#findComment-697573 Share on other sites More sharing options...
naptimeshadows Posted December 15, 2015 Share Posted December 15, 2015 (edited) I think? I took the exported backpack anims and edited them. So, if the krane tool exported it correctly, then it should be perfect. Here are the files. If the item is just a backpack, which has its slots displayed upon equip, does it really need additional animations for that?exported_rucksack.zip Edited December 15, 2015 by naptimeshadows Link to comment https://forums.kleientertainment.com/forums/topic/60639-need-help-customized-backpack-starting-item/page/2/#findComment-697631 Share on other sites More sharing options...
ZupaleX Posted December 15, 2015 Share Posted December 15, 2015 So you missed one point in my explanation.The anim and build you put in the widget parameter have nothing to do with the model of your backpack. It tells what has to be used as a background for the widget when opening the backpack (or rucksack, or whatever). And I'm talking about the widget itself.Here you use the build and bank of the rucksack to initiate the widget. It doesn't make any sense.If you do not want to use a custom texture for the widget, just reuse the one used in the "backpack" entry from containers.lua Link to comment https://forums.kleientertainment.com/forums/topic/60639-need-help-customized-backpack-starting-item/page/2/#findComment-697822 Share on other sites More sharing options...
naptimeshadows Posted December 17, 2015 Share Posted December 17, 2015 (edited) So you missed one point in my explanation. The anim and build you put in the widget parameter have nothing to do with the model of your backpack. It tells what has to be used as a background for the widget when opening the backpack (or rucksack, or whatever). And I'm talking about the widget itself. Here you use the build and bank of the rucksack to initiate the widget. It doesn't make any sense. If you do not want to use a custom texture for the widget, just reuse the one used in the "backpack" entry from containers.lua I DO want to use custom textures, which I have already created and shared. I just want it to function the same way a backpack does, with the auto-fill when picking things up, and the slots being mounted on the right of the screen. I want to be able to consciously create each piece of this and make it function, so I do want my custom animations to be called, I just want them to function in the way a traditional backpack does. I have been assuming that the export files and .scml are used in reference to the animations, since they are atlased and put in the anim folder. Is there an additional step I need to be doing? Edited December 17, 2015 by naptimeshadows Link to comment https://forums.kleientertainment.com/forums/topic/60639-need-help-customized-backpack-starting-item/page/2/#findComment-698255 Share on other sites More sharing options...
ZupaleX Posted December 17, 2015 Share Posted December 17, 2015 You are misunderstanding me. I'm tlking from the beginning about texture for the WIDGET ITSELF. Not the pack on the back of your character. And as far as I saw, you did not provide any kind of textures for the widget, just for the pack on the ground and worn by the character. Link to comment https://forums.kleientertainment.com/forums/topic/60639-need-help-customized-backpack-starting-item/page/2/#findComment-698299 Share on other sites More sharing options...
Lumina Posted December 17, 2015 Share Posted December 17, 2015 And if you don't see what the widget is exactly, here is an image. The widget is the image using to the "container" part, where the item go. So you could have custom backpack, with custom anim and custom inventory image, but still use the same widget part than the backpack (because often you don't need to have a custom image here, except some case when you have special number of slot maybe) But if you try to define a custom image for the widget, you should create one. Link to comment https://forums.kleientertainment.com/forums/topic/60639-need-help-customized-backpack-starting-item/page/2/#findComment-698311 Share on other sites More sharing options...
ZupaleX Posted December 17, 2015 Share Posted December 17, 2015 You do not "need" a custom background image. You can rescale the regular one if you change the amount of slots. You just put a custom image if you want your container widget to look different than the backpack or chest (like the storage in my Mining Machine mod for instance).But thanks for the picture, I was too lazy to do that and it was sounding clear enough my explanation but I guess that a picture will help. Link to comment https://forums.kleientertainment.com/forums/topic/60639-need-help-customized-backpack-starting-item/page/2/#findComment-698337 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