Jump to content

How can I make my custom character start off with an equipped backpack?


Recommended Posts

i have an item that spawns every time the game is loaded. so if you want that, you can do something with an item that is LIKE a backpack, and use this in your modmain. this should work for you

GLOBAL.GetPlayer()function SpawnItem(player)--Spawn the item at the world origin.local item = GLOBAL.SpawnPrefab("backpack")--Move the item to the player's position.item.Transform:SetPosition(player.Transform:GetWorldPosition())end

:D

 

Link to comment
Share on other sites

 

i have an item that spawns every time the game is loaded. so if you want that, you can do something with an item that is LIKE a backpack, and use this in your modmain. this should work for you

GLOBAL.GetPlayer()function SpawnItem(player)--Spawn the item at the world origin.local item = GLOBAL.SpawnPrefab("backpack")--Move the item to the player's position.item.Transform:SetPosition(player.Transform:GetWorldPosition())end

:grin:

 

 

Will this spawn a backpack at my feet every single time I join the same world? Or will it only spawn in a world once and then it won't spawn at my feet again?

 

Link to comment
Share on other sites

every time the game is loaded (save and exit, and reload will load it again) it will drop another of that item at the players feet. i understand that this could be a pretty big problem, but for awhile it can be a temporary fix. you could try to write a function that acts at the start inventory that would purposely drop it. but doing this for the backpack since it isnt able to be put in the inventory would require calling this function first. you could also try to make an edit to the backpack and add it to your mod, and make it able to be in the inventory. i bet that is also something you might not want. so you could possibly do this, but make a separate item exactly identical to the backpack but named backpack2char.lua in your prefabs so that its called differently. that way the start inventory could work, and only affect that item instead of all backpacks. hope i helped :D

Link to comment
Share on other sites

every time the game is loaded (save and exit, and reload will load it again) it will drop another of that item at the players feet. i understand that this could be a pretty big problem, but for awhile it can be a temporary fix. you could try to write a function that acts at the start inventory that would purposely drop it. but doing this for the backpack since it isnt able to be put in the inventory would require calling this function first. you could also try to make an edit to the backpack and add it to your mod, and make it able to be in the inventory. i bet that is also something you might not want. so you could possibly do this, but make a separate item exactly identical to the backpack but named backpack2char.lua in your prefabs so that its called differently. that way the start inventory could work, and only affect that item instead of all backpacks. hope i helped :grin:

 

If it's identical, wouldn't it not work then? Wouldn't I have to somehow enable it to be allowed in my inventory?

Link to comment
Share on other sites

Check out these two mods:

Additionally, I think the code for Willow, Woodie, and/or Maxwell might be helpful. They all have starting items.

 

File locations:

(..\scripts\prefabs\Willow.lua)

(..\scripts\prefabs\Woodie.lua)

(..\scripts\prefabs\Waxwell.lua)

 

Unfortunately, this isn't what I'm looking for. I said I was trying to make a custom character that started off with an EQUIPPED backpack, and I don't mean another mod that does it. I mean I want me custom character to start off with a backpack equipped, and not have another one spawn at my feet whenever I start the map. That way, I won't have 10+ backpacks from just joining my world

Link to comment
Share on other sites

Unfortunately, this isn't what I'm looking for. I said I was trying to make a custom character that started off with an EQUIPPED backpack, and I don't mean another mod that does it. I mean I want me custom character to start off with a backpack equipped, and not have another one spawn at my feet whenever I start the map. That way, I won't have 10+ backpacks from just joining my world

 

Sorry, I should've been more specific, I meant the code in those mods may be of use to your own character mod.

Judging by the code and screenshots of the backpack mod, it seems you can actually put a backpack into the starting inventory of a character and it will drop the backpack near you once when you create a new world/character.

 

Have you already tried adding it to your starting inventory?

 

 

Edit:

@DegradedScroll, what they meant is look at how the mods produce the end result you are looking for and use that as a reference for creating your code. 

Yup, that. Thanks. haha

 

Link to comment
Share on other sites

Sorry, I should've been more specific, I meant the code in those mods may be of use to your own character mod.

Judging by the code and screenshots of the backpack mod, it seems you can actually put a backpack into the starting inventory of a character and it will drop the backpack near you once when you create a new world/character.

 

Have you already tried adding it to your starting inventory?

 

Yes, I have. I just realized that I'm using Don't Starve Together, and this is in the "Don't Starve" section. I strongly apologize for any confusion this may have caused.

Link to comment
Share on other sites

hey. about it being identical, it would work. its like cloning the item, and doing this makes it an entirely new item. so if i have two of the same code, but the only difference is the name of the prefab and that one is able to be put in the inventory, then there will be two seperate items that do the same thing, except the other has a slight perk, and wouldnt be craftable (custom item). so if you want to do that, look at the code for an axe for example, and copy the backpack into your character prefabs. then change the inventory item part of the backpack. also you need to do the other necessary things for a custom item too. but doing this, will in fact work for you.

Link to comment
Share on other sites

hey. about it being identical, it would work. its like cloning the item, and doing this makes it an entirely new item. so if i have two of the same code, but the only difference is the name of the prefab and that one is able to be put in the inventory, then there will be two seperate items that do the same thing, except the other has a slight perk, and wouldnt be craftable (custom item). so if you want to do that, look at the code for an axe for example, and copy the backpack into your character prefabs. then change the inventory item part of the backpack. also you need to do the other necessary things for a custom item too. but doing this, will in fact work for you.

 

Alright. I'll give it a try and get back to you. (I'm actually in the wrong thread section to begin with, I'm making a character mod for Don't Starve Together, not Don't Starve) Thanks ahead of time, though!

Link to comment
Share on other sites

oh. well dst sets things up differently for the prefab. but gutting it this way might work. it could also totally tank if you arent experienced making items for dst. ive made a few with the help of dryicefox. order is important, and you may want to make this for the base game first, to see if it can work this way. replicas arent very forgiving to what i hear.

Link to comment
Share on other sites

oh. well dst sets things up differently for the prefab. but gutting it this way might work. it could also totally tank if you arent experienced making items for dst. ive made a few with the help of dryicefox. order is important, and you may want to make this for the base game first, to see if it can work this way. replicas arent very forgiving to what i hear.

 

Yeah, I'm complete trash at coding. I really don't understand anything at most, and I feel that I'm still too young to fully grasp the meaning of it. It's truly a shame because I absolutely love the idea of being able to make mods and understand coding language more. I feel that making a storage mod would be too far out of grasp for me, even making a simple item that just takes up space in the inventory would be a hassle on my end as well.

 

Link to comment
Share on other sites

its not that hard really. there are great people on the forum that could help. there are also alot of topics in the DST mod section. there is a post about a storage bunker thing that deals with unique replica stuff. (replica is for things that hold inventory slots in dst). search replica there, and that could help you with this.

Link to comment
Share on other sites

Yeah, I'm complete trash at coding. I really don't understand anything at most, and I feel that I'm still too young to fully grasp the meaning of it. It's truly a shame because I absolutely love the idea of being able to make mods and understand coding language more. I feel that making a storage mod would be too far out of grasp for me, even making a simple item that just takes up space in the inventory would be a hassle on my end as well.

 

You can never be too young to start programming! Making mods (especially for such a mod-able game) is a great way to start, because you'll see results quicker and won't need to worry too much (or at all) about the game engine and such.

 

Using @WitchDoctEr16's idea, I've put together this little mod which replicates the bag, changes it's prefab name, and is store-able in your inventory. Try putting it together with your character mod and see if you can add it to the starting inventory. I haven't tested it myself, though.
 
Inside the prefab file, modded lines are labeled with:
-- Modded line

The name of the prefab is backpack_storable. Use that instead of "backpack".

 

storebag.zip

Link to comment
Share on other sites

 

You can never be too young to start programming! Making mods (especially for such a mod-able game) is a great way to start, because you'll see results quicker and won't need to worry too much (or at all) about the game engine and such.

 

Using @WitchDoctEr16's idea, I've put together this little mod which replicates the bag, changes it's prefab name, and is store-able in your inventory. Try putting it together with your character mod and see if you can add it to the starting inventory. I haven't tested it myself, though.
 
Inside the prefab file, modded lines are labeled with:
-- Modded line

The name of the prefab is backpack_storable. Use that instead of "backpack".

 

attachicon.gifstorebag.zip

 

 

Where do I put this? Because I don't want to have to make people download two mods, because the character will make their game crash if they don't have the correct mods installed....

 

*EDIT*: What I mean by this is where do I put the contents of the .zip?

Link to comment
Share on other sites

Where do I put this? Because I don't want to have to make people download two mods or else the character will make their game crash...

 

Combine the content of the modmain.lua from here and your own mod. Put the scripts/prefabs folders inside your mod folder as they are. You should then be able to use the new prefab just as you use backpack's prefab.

(I'm not sure if the content of this modmain is required, but I figure it probably is to be able to use the prefab correctly. I copied it from the mod examples by Ipsquiggle)

Link to comment
Share on other sites

Combine the content of the modmain.lua from here and your own mod. Put the scripts/prefabs folders inside your mod folder as they are. You should then be able to use the new prefab just as you use backpack's prefab.

(I'm not sure if the content of this modmain is required, but I figure it probably is to be able to use the prefab correctly. I copied it from the mod examples by Ipsquiggle)

 

Alright, When I did that, started my game, and went to my mod it said "Crashed!" and when I click on it, it goes to "To be Enabled", then when I click Apply my game completely crashes without explanation.

Link to comment
Share on other sites

Alright, When I did that, started my game, and went to my mod it said "Crashed!" and when I click on it, it goes to "To be Enabled", then when I click Apply my game completely crashes without explanation.

 

Did it provide an error screen at all? Would be helpful to post that, along with your log.txt file (should be in ..\Documents\Klei\DoNotStarve)

Link to comment
Share on other sites

Did it provide an error screen at all? Would be helpful to post that, along with your log.txt file (should be in ..\Documents\Klei\DoNotStarve)

It did not. It just crashed. I'm actually using Don't Starve Together, so Don't Starve mods will not be compatible with Don't Starve Together since their prefabs are different.

log.txt

Link to comment
Share on other sites

well yes, they just dont have parts that are required like networking, function order, and replicas.

 

alright. ive looked at the coding and it doesnt seem to use replicas or networking. im going to attach a semi complete file that will show the proper structure of a dst custom item. it doesnt have a replica, since it doesnt use inventory slots like a backpack. so you are gonna have to look at the backpack from the games code to figure that out.

ab_crab.lua

Link to comment
Share on other sites

well yes, they just dont have parts that are required like networking, function order, and replicas.

 

alright. ive looked at the coding and it doesnt seem to use replicas or networking. im going to attach a semi complete file that will show the proper structure of a dst custom item. it doesnt have a replica, since it doesnt use inventory slots like a backpack. so you are gonna have to look at the backpack from the games code to figure that out.

 

So, how do I make a backpack that I can carry in my inventory? Would I just copy the backpack.lua and just put it in my custom character's scripts/prefabs folder?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
×
  • Create New...