Jump to content

[Tutorial] Creating a "handslot-equippable-item" from scratch


Malacath
 Share

Recommended Posts

First and foremost, thank you for making this tutorial, I have used this as a guide over the last 6-8 months to create many items for quite a few mods I am soon going to be publishing. BUT I had a few questions. Mostly based on mistakes that have cost me months of trying to figure out. 

 

1. Which is the BANK for animations and which is the BUILD? And have you ever seen the folders switched in other item mods?

For instance, hats? The confusion for me was where in the ground folder, the tutorial states that that's where we name our build, which is different then the swap folder, which is the build....right? But I could swear some items have the ground folder as the BUILD and the swap folder as the animation BANK. 

 

2. Adding animations: can we add on top of an already completed tutorial file? or does that mess things up? reason I am asking, before I get into error troubleshooting from my other mistakes, I don't want to sit and try to problem solve something that I may have caused, because I tried to add something the game wont recognize. That includes art for the animations as well.

Or is it as simple as making sure the artwork is put in the BUILD and Bank folders?

 

I know these are pretty simple questions, But I wanted to make sure I knew the right answer.

 

Thank you again for making such a helpful tutorial. I couldn't of done half the projects I made without your help. 

Link to comment
Share on other sites

Would you be able to point me in the direction of some sort of weapon/wearable guide as a next step after this? I'm trying my hand at actually making something mod/code related and I'd loove to have some sort of resource, something besides the salvaged pieces of various mods I've downloaded to bash my head against in hopes of Frankensteining my mod into a somewhat passable something.

Link to comment
Share on other sites

My item name isn't showing up. When I pick up my item it says MISSING NAME. How can I fix this? Thanks in advance :grin:

 

Oh yea, they kinda skip over that in this tutorial, don't they?

Put this in your items lua file. (just on its own, not part of the fn function thing)

STRINGS.NAMES.YOUR_PREFAB_NAME_IN_ALL_CAPS = "Your objects name"STRINGS.CHARACTERS.GENERIC.DESCRIBE.YOUR_PREFAB_NAME_IN_ALL_CAPS = "The description of your object when examined by a character."
Link to comment
Share on other sites

Would you be able to point me in the direction of some sort of weapon/wearable guide as a next step after this? I'm trying my hand at actually making something mod/code related and I'd loove to have some sort of resource, something besides the salvaged pieces of various mods I've downloaded to bash my head against in hopes of Frankensteining my mod into a somewhat passable something.

 

"Frankensteining my mod into a somewhat passable something."

Welcome to don't starve modding

 

That's basically all we got. There really aren't many more tutorials out there. Or if there are, I haven't found any.

 

I learned most of what I know from studying the game's code itself, It's very useful to find some existing game item, copy it's code into your mod, and edit it from there. 

Though this site can be kinda helpful too 

http://dontstarveapi.com/  

^watch out for the popups though

Link to comment
Share on other sites

Would you be able to point me in the direction of some sort of weapon/wearable guide as a next step after this? I'm trying my hand at actually making something mod/code related and I'd loove to have some sort of resource, something besides the salvaged pieces of various mods I've downloaded to bash my head against in hopes of Frankensteining my mod into a somewhat passable something.

 

 

http://forums.kleientertainment.com/files/file/373-hat-example/

 

example of a hat

Link to comment
Share on other sites

No not violin.anim, its violin_anim

It's the folder in the exported folder

Well i tried what uou suggested, and the autocompiler compiled the animation and made a new zip in /anim. But, the animation does not show up in game *groans*. Do you think this is just because I haven't replaced all the images in the animation folder (so they are all currently invisible). Or is there some other issue?

Tanks.

Link to comment
Share on other sites

Well i tried what uou suggested, and the autocompiler compiled the animation and made a new zip in /anim. But, the animation does not show up in game *groans*. Do you think this is just because I haven't replaced all the images in the animation folder (so they are all currently invisible). Or is there some other issue?

Tanks.

Alright, at least that solves one problem.

Do you think you could send me another copy of your mod folder? Hopefully it won't crash when I try to play it this time d:

Link to comment
Share on other sites

Alright, at least that solves one problem.

Do you think you could send me another copy of your mod folder? Hopefully it won't crash when I try to play it this time d:

alright here it is.Wilfred the Musician.zip hope it works 

if it doesnt work then get it off the workshop http://steamcommunity.com/sharedfiles/filedetails/?id=486052508

Edited by NeddoFreddo
Link to comment
Share on other sites

alright here it is.attachicon.gifWilfred the Musician.zip hope it works 

if it doesnt work then get it off the workshop http://steamcommunity.com/sharedfiles/filedetails/?id=486052508

 

Sorry for the long wait, but It seems I can't get your mod working for me, it just crashes when I try to enable it, I'm not sure why. (still havent tried the workshop version but I will later)

But looking through the files, everything appears to be exactly as it should be. the animation files are compiling correctly and everything is there.

 

Hm. Tell me; do you get anything if you type   c_spawn("violin_anim", 1) in console?

Link to comment
Share on other sites

Sorry for the long wait, but It seems I can't get your mod working for me, it just crashes when I try to enable it, I'm not sure why. (still havent tried the workshop version but I will later)

But looking through the files, everything appears to be exactly as it should be. the animation files are compiling correctly and everything is there.

 

Hm. Tell me; do you get anything if you type   c_spawn("violin_anim", 1) in console?

Yes, it spawns in the animation. But only the upper arms, the vilin adnd the bow are showing. And yeah, the workshop version is old but i will update it soon.

EDIT: Updated the workshop version. Hope it doesn't crash :p

Edited by NeddoFreddo
Link to comment
Share on other sites

Yes, it spawns in the animation. But only the upper arms, the vilin adnd the bow are showing. And yeah, the workshop version is old but i will update it soon.

EDIT: Updated the workshop version. Hope it doesn't crash :p

Well yes its going to show only the arms and the violin because you replaced the other body parts with empty images, didn't you? That's what I saw in the folder. Replacing them with empty images was just to make sure that the problem was with the compiler, you still need put them all back in and single out which part you need to redraw to fix it. But does it at least play that half arm and violin animation when you play it?

Link to comment
Share on other sites

Well yes its going to show only the arms and the violin because you replaced the other body parts with empty images, didn't you? That's what I saw in the folder. Replacing them with empty images was just to make sure that the problem was with the compiler, you still need put them all back in and single out which part you need to redraw to fix it. But does it at least play that half arm and violin animation when you play it?

Yes, it does. Which is a releif.

But the thing is; I did replace all the images with new ones. Just theat the compiler isn't compiling them. Again.

EDIT: I replaced all the images, and it now shows all of his body parts. (phew!)

Edited by NeddoFreddo
Link to comment
Share on other sites

Yes, it does. Which is a releif.

But the thing is; I did replace all the images with new ones. Just theat the compiler isn't compiling them. Again.

EDIT: I replaced all the images, and it now shows all of his body parts. (phew!)

Whew! So it works now, right? Good to hear!

I hope they eventually fix that auto-compiler bug, it seems to happen to a fairly large number of people.

Link to comment
Share on other sites

Whew! So it works now, right? Good to hear!

I hope they eventually fix that auto-compiler bug, it seems to happen to a fairly large number of people.

Well the animation works, but it just doesn't play when the violin is, uh, played.

Can you help? Big thanks.

And that bug is so annoying, I agree. 

Edited by NeddoFreddo
Link to comment
Share on other sites

Well the animation works, but it just doesn't play when the violin is, uh, played.

Can you help? Big thanks.

And that bug is so annoying, I agree. 

 

Oh, right. that's becasue this:

inst.components.instrument:SetOnHeardFn(HearViolin)

^is still set to call the "HearViolin" function when it's played. And all your animation stuff happens in the "onheard" function that you made. You could just change it to   SetOnHeardFn(onheard)   but then all the stuff in the "HearViolin" function wouldn't happen and nothing would fall asleep.

So you can take all the code in your onheard function and just paste it into the HearViolin function. (just replace all the "inst" with "musician", because musician is what refers to the player in that function.)

Link to comment
Share on other sites

Oh, right. that's becasue this:

inst.components.instrument:SetOnHeardFn(HearViolin)

^is still set to call the "HearViolin" function when it's played. And all your animation stuff happens in the "onheard" function that you made. You could just change it to   SetOnHeardFn(onheard)   but then all the stuff in the "HearViolin" function wouldn't happen and nothing would fall asleep.

So you can take all the code in your onheard function and just paste it into the HearViolin function. (just replace all the "inst" with "musician", because musician is what refers to the player in that function.)

Which HearViolin function?

This one:

local function HearViolin(inst, musician, instrument)	if inst.components.sleeper then	    inst.components.sleeper:AddSleepiness(5, 20)	endend

Or this one?

local function HearViolin(inst) --or whatever you want to call it    inst.AnimState:SetBank("violin_anim")    inst.AnimState:SetBuild("violin_anim")    inst:SetStateGraph("SGviolin_anim")    --THIS WILL CHANGE HIM BACK AFTER THE 2 SECONDS OF THE ANIMATION    inst:DoTaskInTime(2, function(inst) inst.AnimState:SetBank("wilson") end)  --DON'T CHANGE WILSON    inst:DoTaskInTime(2, function(inst) inst.AnimState:SetBuild("wilfred") end)    inst:DoTaskInTime(2, function(inst) inst:SetStateGraph("SGwilson") end) --or that wilsonend

And in which .lua file would I find the onheard function? I searched onheard in all the .luas, and oulnd't find any. Thanks.

EDIT: I tried it with the first Hearviolin finction, and i got this:post-655693-0-19123000-1440837041_thumb.

So, is there something wrong with line 29? this is line 29:

inst.AnimState:SetBank("violin_anim")

Does that mean the animation isn't working or its corrupt, or what?

EDIT2: Ok, ive looked back on all the errors ive had, and they all seem to be about the same thing. Line 29. (ok the line number has changed but its still the same line.) SO there must be something wrong with the bank, i.e. the spriter file in violin_anim (exported folder.)

EDIT3: And the funny thing is, I swapped line 29 and 30 around and made 30 the bank and 29 the build instead of vice versa. But when the game crashed it still said there was something wrong with line 29. Is line 29, like, bugged or something? Or does Kevin just not like the number 29? (that was a bad joke, I'm sorry.)

Edited by NeddoFreddo
Link to comment
Share on other sites

Which HearViolin function?

This one:

 

ohh, so you changed the name of that other function. When there's two functions with the same name, it only calls the one closest to the bottom of the screen.

I meant you combine them like this;

local function HearViolin(inst, musician, instrument)	if inst.components.sleeper then	    inst.components.sleeper:AddSleepiness(5, 20)	end	musician.AnimState:SetBank("violin_anim")    musician.AnimState:SetBuild("violin_anim")    musician:SetStateGraph("SGviolin_anim")    --THIS WILL CHANGE HIM BACK AFTER THE 2 SECONDS OF THE ANIMATION    musician:DoTaskInTime(2, function(musician) musician.AnimState:SetBank("wilson") end)      musician:DoTaskInTime(2, function(musician) musician.AnimState:SetBuild("wilfred") end)    musician:DoTaskInTime(2, function(musician) musician:SetStateGraph("SGwilson") end) end

It was probably crashing because you didn't change inst to musician, so it was trying to make the affected creatures play wilfred's animation

Link to comment
Share on other sites

So, I carefully analysed every word of this tutorial and done all the steps. Everything works fine, however, my swap animation is not working (holding the equippable ) despite having done everything possible. My ground animation works. My inventory animation works. But the swap animation is just invisible. Trust me, I've closely followed everything and spent, I kid you not, hours going over the code to spot the error. But no, every "myitem" is changed to my weapon name, the comments are removed from the assets, and from my point of view, it has no reason to be invisible... Please help :indecisiveness:

Link to comment
Share on other sites

ohh, so you changed the name of that other function. When there's two functions with the same name, it only calls the one closest to the bottom of the screen.

I meant you combine them like this;

local function HearViolin(inst, musician, instrument)	if inst.components.sleeper then	    inst.components.sleeper:AddSleepiness(5, 20)	end	musician.AnimState:SetBank("violin_anim")    musician.AnimState:SetBuild("violin_anim")    musician:SetStateGraph("SGviolin_anim")    --THIS WILL CHANGE HIM BACK AFTER THE 2 SECONDS OF THE ANIMATION    musician:DoTaskInTime(2, function(musician) musician.AnimState:SetBank("wilson") end)      musician:DoTaskInTime(2, function(musician) musician.AnimState:SetBuild("wilfred") end)    musician:DoTaskInTime(2, function(musician) musician:SetStateGraph("SGwilson") end) end

It was probably crashing because you didn't change inst to musician, so it was trying to make the affected creatures play wilfred's animation

WOOT! It's working, but its a bit messed up. Ill see if I can get a gif going of the animation.post-655693-0-62854000-1440883818_thumb.

It's a bit hard to tell from the gif, but, it shows the first half of the panflute animation, all eqipped items disappear, (including the violin lol), and wilfreds body jumps around a bit. If you can't help it doesn'nt matter that much, just the panflute bit at the start i'd like to see that removed.

EDIT: and allso, is there a way to make it sound like a violin, not a panflute?

Edited by NeddoFreddo
  • Like 1
Link to comment
Share on other sites

So, I carefully analysed every word of this tutorial and done all the steps. Everything works fine, however, my swap animation is not working (holding the equippable ) despite having done everything possible. My ground animation works. My inventory animation works. But the swap animation is just invisible. Trust me, I've closely followed everything and spent, I kid you not, hours going over the code to spot the error. But no, every "myitem" is changed to my weapon name, the comments are removed from the assets, and from my point of view, it has no reason to be invisible... Please help :indecisiveness:

Can you zip and upload your file so i can take a look at it? i might be able to help...

Edited by NeddoFreddo
Link to comment
Share on other sites

WOOT! It's working, but its a bit messed up. Ill see if I can get a gif going of the animation.attachicon.gifdont_starve_violin_animation.gif

It's a bit hard to tell from the gif, but, it shows the first half of the panflute animation, all eqipped items disappear, (including the violin lol), and wilfreds body jumps around a bit. If you can't help it doesn'nt matter that much, just the panflute bit at the start i'd like to see that removed.

EDIT: and allso, is there a way to make it sound like a violin, not a panflute?

 

Oh dam, I have no idea why this never occurred to me, but yea, I guess all the clothing items would disappear because he doesn't wear any in the animation. I guess I never noticed in my animations because my character takes a different form in the animation. Well, I got nothing.

 

 

But I think the weird sudden movements is from the pivot points on the body parts being in very different places in different frames in spriter. you should be able to fix those easy in spriter. 

 

to remove the custom sound, I think you can put "inst.SoundEmitter:KillAllSounds()" into your HearViolin function, just replace inst with instrument. or musician if that doesn't work. or try adding it into a DoTaskInTime() thing if neither of those work.

But Adding custom sound gets REAL complicated, you're on your own for that one d: but if you want to try, this should get you started http://forums.kleientertainment.com/topic/27803-tutorial-adding-custom-sound-to-your-custom-character/

OH WAIT couldn't you use someones voicelines? Doesnt Wendy have a violin voice? Haha, that would probably work!

 

you could put musician.SoundEmitter:PlaySound("dontstarve/creatures/deerclops/taunt_howl")  

(well, that would play the deerclops roar. you'd have to find the name of the voice sound clip theres a huge list of all the sound clips in the game somewhere in the games files, but i forgot where)

Link to comment
Share on other sites

Oh dam, I have no idea why this never occurred to me, but yea, I guess all the clothing items would disappear because he doesn't wear any in the animation. I guess I never noticed in my animations because my character takes a different form in the animation. Well, I got nothing.

 

 

But I think the weird sudden movements is from the pivot points on the body parts being in very different places in different frames in spriter. you should be able to fix those easy in spriter. 

 

to remove the custom sound, I think you can put "inst.SoundEmitter:KillAllSounds()" into your HearViolin function, just replace inst with instrument. or musician if that doesn't work. or try adding it into a DoTaskInTime() thing if neither of those work.

But Adding custom sound gets REAL complicated, you're on your own for that one d: but if you want to try, this should get you started http://forums.kleientertainment.com/topic/27803-tutorial-adding-custom-sound-to-your-custom-character/

OH WAIT couldn't you use someones voicelines? Doesnt Wendy have a violin voice? Haha, that would probably work!

 

you could put musician.SoundEmitter:PlaySound("dontstarve/creatures/deerclops/taunt_howl")  

(well, that would play the deerclops roar. you'd have to find the name of the voice sound clip theres a huge list of all the sound clips in the game somewhere in the games files, but i forgot where)

No, Wendy is voiced by an alto flute. Woodie is voiced by a cello, which is sorta close to a violin but not really. The unimplemented character wallace would use a violin, but he isn't actually implemented.

About wallace, I found a .fsb file in the games files called 'wallace'. how could i use this in my mod? (it was in dont starve> data> sound)

EDIT: So do you know how to rid of the panflute animation at the start? could i make my own custom one for moving the violin on his shoulder or not?

EDIT2: Well ive got the sound working its just that it plays the panflute sound aswell. (I used wallace's voice for the sound) And the wallace sound never stops, even though the kill all sounds thing is there. (the panflute sound still stops)

 

Edited by NeddoFreddo
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...