Jump to content

Recommended Posts

So I'm working on a pack of mods for my friends and myself. One of my friends wanted a customized backpack as a starting item. It seemed simple to create it as I can just copy all the codes in the backpack.lua file and change every "backpack" to "custombackpack" and "swap_backpack" to "swap_custombackpack." The problem is, my game crashes whenever I load this mod. There is no more informations I can share because I can't find where the logs are located.

 

So there. I need help finding where's the problem and how I can fix it.

I am also interested in making my own backpack and have the game crashing.

I did all the renaming, and turned my edited .png into .tex properly and put them back in the .zip as "atlas-0".

Or will I need to really make my own spriter files?

 

 

I also have an issue with the lack of slot assignment?

I assume it has to do with this: 
 

inst:AddComponent("container")inst.components.container:WidgetSetup("backpack")
 
How do I assign my own number of slots? I am fine with using mods to alter normal bag size, but I'd much prefer to have all my own stuff built directly into my own personal mod.
I left this as "backpack" in my build.
 
EDIT::
Log attached. 
I'm not really sure how to read it in a way that tells me what to fix.

rucksack.lua

log.txt

Edited by naptimeshadows

@naptimeshadows, you need to change the build name with BuildRenamer.

 

1) Download BuildRenamer

2) Go to your "rucksack" (that's your custom backpack, right?) anim folder, open it.

3) You'll find a file named "build". Put it in a file somewhere on your desktop.

4) With build renamer, rename the build to "rucksack" (because it is currently named "backpack", that's the cause of the crash)

5) Don't forget to save it as "build.bin" (and the ".bin" part is absolutely crucial, I have pulled my hair out many times trying to figure that one out)

6) Replace the old build file with the new build file in the rucksack anim folder. Old and new should be saved as "build.bin" (just checking). I recommend right clicking and selecting "delete" to remove the old build file, and then adding the new build file; instead of just copy and replacing (has lead to some issues for me, because of whacky winrarness).

 

Hope this helps!

Check out the containerswidget for the list of built in configs for the containers (backpack is one of them). You can also define your own widget config to tune the amount of slots or positions on screen using the same way they are defined in this containerswidget.lua

Put then in the widgetsetup what you just defined.

If you need more info, ask :-)

@naptimeshadows, you need to change the build name with BuildRenamer.

 

1) Download BuildRenamer

2) Go to your "rucksack" (that's your custom backpack, right?) anim folder, open it.

3) You'll find a file named "build". Put it in a file somewhere on your desktop.

4) With build renamer, rename the build to "rucksack" (because it is currently named "backpack", that's the cause of the crash)

5) Don't forget to save it as "build.bin" (and the ".bin" part is absolutely crucial, I have pulled my hair out many times trying to figure that one out)

6) Replace the old build file with the new build file in the rucksack anim folder. Old and new should be saved as "build.bin" (just checking). I recommend right clicking and selecting "delete" to remove the old build file, and then adding the new build file; instead of just copy and replacing (has lead to some issues for me, because of whacky winrarness).

 

Hope this helps!

 

I can't find a link to download BuildRenamer. 

The ones I keep finding are too old to work.

Is there a certain developer I should look for?

I can't find a link to download BuildRenamer. 

The ones I keep finding are too old to work.

Is there a certain developer I should look for?

 

http://forums.kleientertainment.com/topic/25740-help-i-need-build-renamer/

 

Try this. I googled "Build Renamer Don't Starve Together" and found this.

I now have another problem. Now that the build is renamed and all, I just tested it. And this item doesn't appear in my inventory.

local assets ={    Asset("ANIM", "anim/custombackpack.zip"),    Asset("ANIM", "anim/swap_custombackpack.zip"),}local function onequip(inst, owner)    owner.AnimState:OverrideSymbol("swap_body", "swap_custombackpack", "custombackpack")    owner.AnimState:OverrideSymbol("swap_body", "swap_custombackpack", "swap_body")    if inst.components.container ~= nil then        inst.components.container:Open(owner)    endendlocal function onunequip(inst, owner)    owner.AnimState:ClearOverrideSymbol("swap_body")    owner.AnimState:ClearOverrideSymbol("custombackpack")    if inst.components.container ~= nil then        inst.components.container:Close(owner)    endendlocal function fn()    local inst = CreateEntity()    inst.entity:AddTransform()    inst.entity:AddAnimState()    inst.entity:AddSoundEmitter()    inst.entity:AddMiniMapEntity()    inst.entity:AddNetwork()    MakeInventoryPhysics(inst)    inst.AnimState:SetBank("backpack1")    inst.AnimState:SetBuild("swap_custombackpack")    inst.AnimState:PlayAnimation("anim")    inst:AddTag("custombackpack")    inst.MiniMapEntity:SetIcon("backpack.png")    inst.foleysound = "dontstarve/movement/foley/backpack"    inst.entity:SetPristine()    if not TheWorld.ismastersim then        return inst    end    inst:AddComponent("inspectable")    inst:AddComponent("inventoryitem")    inst.components.inventoryitem.cangoincontainer = false    inst:AddComponent("equippable")    inst.components.equippable.equipslot = EQUIPSLOTS.BODY    inst.components.equippable:SetOnEquip(onequip)    inst.components.equippable:SetOnUnequip(onunequip)    inst:AddComponent("container")    inst.components.container:WidgetSetup("backpack")    MakeHauntableLaunchAndDropFirstItem(inst)    return instend-- Add some strings for this itemSTRINGS.NAMES.custombackpack = "Custom Backpack"STRINGS.CHARACTERS.GENERIC.DESCRIBE.custombackpack = "Looks better than the standard one."return Prefab("common/inventory/custombackpack", fn, assets)

Did I do something wrong?

Edited by Cuddlepuff

I found it. 

I was misreading the original upload from "Matt Tools".

 

So, new issue!

I have made my rucksack item identical to the Krampus Sack as far as the scripting goes, and for the first time the game is actually telling me to check my log for errors.

I see that there is an issue with line 276, but since I copied it verbatim, I don't know what to change.

log.txt

modmain.lua

Edited by naptimeshadows

I now have another problem. Now that the build is renamed and all, I just tested it. And this item doesn't appear in my inventory.

local assets ={    Asset("ANIM", "anim/custombackpack.zip"),    Asset("ANIM", "anim/swap_custombackpack.zip"),}local function onequip(inst, owner)    owner.AnimState:OverrideSymbol("swap_body", "swap_custombackpack", "custombackpack")    owner.AnimState:OverrideSymbol("swap_body", "swap_custombackpack", "swap_body")    if inst.components.container ~= nil then        inst.components.container:Open(owner)    endendlocal function onunequip(inst, owner)    owner.AnimState:ClearOverrideSymbol("swap_body")    owner.AnimState:ClearOverrideSymbol("custombackpack")    if inst.components.container ~= nil then        inst.components.container:Close(owner)    endendlocal function fn()    local inst = CreateEntity()    inst.entity:AddTransform()    inst.entity:AddAnimState()    inst.entity:AddSoundEmitter()    inst.entity:AddMiniMapEntity()    inst.entity:AddNetwork()    MakeInventoryPhysics(inst)    inst.AnimState:SetBank("backpack1")    inst.AnimState:SetBuild("swap_custombackpack")    inst.AnimState:PlayAnimation("anim")    inst:AddTag("custombackpack")    inst.MiniMapEntity:SetIcon("backpack.png")    inst.foleysound = "dontstarve/movement/foley/backpack"    inst.entity:SetPristine()    if not TheWorld.ismastersim then        return inst    end    inst:AddComponent("inspectable")    inst:AddComponent("inventoryitem")    inst.components.inventoryitem.cangoincontainer = false    inst:AddComponent("equippable")    inst.components.equippable.equipslot = EQUIPSLOTS.BODY    inst.components.equippable:SetOnEquip(onequip)    inst.components.equippable:SetOnUnequip(onunequip)    inst:AddComponent("container")    inst.components.container:WidgetSetup("backpack")    MakeHauntableLaunchAndDropFirstItem(inst)    return instend-- Add some strings for this itemSTRINGS.NAMES.custombackpack = "Custom Backpack"STRINGS.CHARACTERS.GENERIC.DESCRIBE.custombackpack = "Looks better than the standard one."return Prefab("common/inventory/custombackpack", fn, assets)

 

Did I do something wrong?

 

Did you add it to your starting inventory?

You should be able to spawn it with c_spawn("item", 1) and it will appear on the ground. 

If it is loaded properly, it will work.

Edited by naptimeshadows

Did you add it to your starting inventory?

You should be able to spawn it with c_spawn("item", 1) and it will appear on the ground. 

If it is loaded properly, it will work.

 

No, in my character's lua code.

-- Custom starting itemslocal starting_inv = { "custombackpack" }

I want everything to be automatic as if it was legitimately in the game. I want the mod to stay pure to the game. Some characters starts with an item in their inventory and so I want my mod character to start with my custom backpack.

No, in my character's lua code.

-- Custom starting itemslocal starting_inv = { "custombackpack" }
I want everything to be automatic as if it was legitimately in the game. I want the mod to stay pure to the game. Some characters starts with an item in their inventory and so I want my mod character to start with my custom backpack.
 

Right, but if you try to spawn it in the console and it fails, the console will tell you why it can't create the object.

A lot of times, backpacks can't be in the inventory slots, so it won't give it to you on load.

I fixed mine with this in my character lua, under master_postinit:

inst.OnNewSpawn = function(inst)    local sack = SpawnPrefab("krampus_sack")    inst.components.inventory:Equip(sack)end
If you want bags to be able to be in your inventory add this into your modmain:

 

--BAG IN BAGAddPrefabPostInit("krampus_sack", function(inst)    if not GLOBAL.TheWorld.ismastersim then return end    inst.components.inventoryitem.cangoincontainer = trueend)AddPrefabPostInit("piggyback", function(inst)    if not GLOBAL.TheWorld.ismastersim then return end    inst.components.inventoryitem.cangoincontainer = trueend)AddPrefabPostInit("backpack", function(inst)    if not GLOBAL.TheWorld.ismastersim then return end    inst.components.inventoryitem.cangoincontainer = trueend)
Edited by naptimeshadows

I found it. 

I was misreading the original upload from "Matt Tools".

 

So, new issue!

I have made my rucksack item identical to the Krampus Sack as far as the scripting goes, and for the first time the game is actually telling me to check my log for errors.

I see that there is an issue with line 276, but since I copied it verbatim, I don't know what to change.

I fixed that core issue, I had to add this into my modmain to allow my params to be identified:

 

local params = {}local containers = { MAXITEMSLOTS = 0 }function containers.widgetsetup(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)    endend
HOWEVER.

I now have this issue in the core game files, and I don't know what to fix.

EDIT::

The last line of the first error is where I have the item spawned on load.

The game loads fine without it, but when I try to check the recipe for this item, it also crashes.

The new error says it's missing files that are there, so there has to be some other situation I am unaware of.

post-733465-0-34073600-1449942371_thumb.

post-733465-0-24738300-1449943675_thumb.

Edited by naptimeshadows

I have tried everything I could. I even spawned it with c_spawn("custombackpack", 1) command in the console, all it did was crashing the game. The console didn't even give much informations. Not even the log file.

Edited by Cuddlepuff
The console didn't even give much informations. Not even the log file.

You should still provide it.

 

If you want bags to be able to be in your inventory add this into your modmain:

Just out of curiosity, what is this line for exactly?

  if not GLOBAL.TheWorld.ismastersim then return end
The new error says it's missing files that are there, so there has to be some other situation I am unaware of.

Are you sure you have this inventory image in its ".xml" form as well? Maybe you need to provide the mod. I remember I once had such a problem, but I forgot how it got fixed. Sorry xD

 

Just out of curiosity, what is this line for exactly?

  if not GLOBAL.TheWorld.ismastersim then return end
 

 

Are you sure you have this inventory image in its ".xml" form as well? Maybe you need to provide the mod. I remember I once had such a problem, but I forgot how it got fixed. Sorry xD

The item part, it's a code I got from someone else that works. It gives me the impression that with that piece included in the modmain, it doesn't pull that value from the item itself.

You can't put bags in your inventory, but with that included I can, even if the item lua value is false.

Here is the mod.

The .xml is absolutely there.

I'm looking through older posts regarding similar issues, and I'm not seeing anything that makes my issue obvious.

I will say, minus my custom bag, the mod works perfectly.

Once this is all done, I want to make an inventory bag that is refrigerated (see magicpouch mod), so if there are any obvious changes I need to make to that end as well, please let me know.

nelsonxx.zip

Edited by naptimeshadows

The line 

if not TheWorld.ismastersim then   returnend

Just tell the game to stop here if this function is not executed by the server (in other words, the clients should stop the execution of the code here). It placement is really important and it can mess up everything if not used properly.

Oh I see, because that's how "return" works. And by using an "end" after it you can just continue the code right? Otherwise the rest of it wouldn't get read. #YayForLearning

 

The log says this at some point :

Could not find anim bank [rucksack]

 

And that's because you don't have an anim called "rucksack", you only have "swap_rucksack". You only made the held item.

 

@ZupaleX, I'm a newb at coding. I just posted what I think I understood, right after you posted (I didn't see your post). However, I didn't understand anything of what you've just said (remember, newbie here). Could you please translate that for me? :DD

Edited by Thibooms

Hello,

I posted a detailed explanation about this kind of stuff a few days ago on this thread

http://forums.kleientertainment.com/topic/60514-dropping-my-item-crashes-my-friend-game/

 

(post #7)

 

Tell me if something is still unclear

The log says this at some point :

Could not find anim bank [rucksack]

 

And that's because you don't have an anim called "rucksack", you only have "swap_rucksack". You only made the held item.

Not true.

Both zips are there, even in the zip I posted.

I even changed the build name.

Is there something else I need to do?

Your build is not correct.

 

Line 32

inst.AnimState:SetBuild("swap_rucksack")

should be

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

@ZupaleX, Hi!

 

Great explanation! Thank you! But why, in your explanation, there's this "inst"?

if not TheWorld.ismastersim then     return instend

I know that "inst" is "instance", and it's used for calling stuff like components, anim states, entities, locomoter, pretty much anything in the game.

 

So if you are the host, the game reads after the then, but then what? I don't understand what it returns.

 

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
×
  • Create New...