Sign in to follow this  
Malacath

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

Recommended Posts

Corrosive    162

@MrKowa,

 

The compatibility warning doesn't matter, it's not an actual error.  The 'no prefab found' error is an error that occurs when a different error prevents your prefab from loading-- that initial error is the one we need to troubleshoot.  Attach or post your full log file inside a spoiler tag if you are unsure where to find it.

 

edit: like I said before, there were additional errors that I saw, but I was hoping you'd be able to catch those by reading the error log after you fixed the first few problems I listed.

Edited by Corrosive

Share this post


Link to post
Share on other sites
chupicabra    0

Hey yall! Seems to be a lot of smart cookies in here.

 

So i've literally put about 8 hours into just making a custom weapon.... and i'm still stuck at making it show up in my hand. The pivot point is overwritten and the scml file is correctly placed in the first swap folder. The inventory icon works and the ground image works but not in hand.... I checked the atlas txt in the .zip and the image is there and everything compiled correctly. I make sure to zoom in every time I try just in case it's too small. All i'm doing is taking the razor from in-game, changing the look and trying to make it a weapon.

 

Anyways, I will continue to work on it but in the meantime, if anyone wants to take a gander i'll leave it here.

 

Thanks,

 

Vince

sweeney razor.zip

Share this post


Link to post
Share on other sites
Fredson    3

Hey yall! Seems to be a lot of smart cookies in here.

 

So i've literally put about 8 hours into just making a custom weapon.... and i'm still stuck at making it show up in my hand. The pivot point is overwritten and the scml file is correctly placed in the first swap folder. The inventory icon works and the ground image works but not in hand.... I checked the atlas txt in the .zip and the image is there and everything compiled correctly. I make sure to zoom in every time I try just in case it's too small. All i'm doing is taking the razor from in-game, changing the look and trying to make it a weapon.

 

Anyways, I will continue to work on it but in the meantime, if anyone wants to take a gander i'll leave it here.

 

Thanks,

 

Vince

 

 This Should Fix It

 

You Mixed

local function fn()     local function OnEquip(inst, owner)        owner.AnimState:OverrideSymbol("swap_object", "swap_sweeneyrazor", "swap_sweeneyrazor")        owner.AnimState:Show("ARM_carry")        owner.AnimState:Hide("ARM_normal")    end     local function OnUnequip(inst, owner)        owner.AnimState:Hide("ARM_carry")        owner.AnimState:Show("ARM_normal")    end

where it should be

local function OnEquip(inst, owner)        owner.AnimState:OverrideSymbol("swap_object", "swap_sweeneyrazor", "swap_sweeneyrazor")        owner.AnimState:Show("ARM_carry")        owner.AnimState:Hide("ARM_normal")    end     local function OnUnequip(inst, owner)        owner.AnimState:Hide("ARM_carry")        owner.AnimState:Show("ARM_normal")    end

Fixed.zip

Share this post


Link to post
Share on other sites
chupicabra    0

 

 This Should Fix It

 

You Mixed

local function fn()     local function OnEquip(inst, owner)        owner.AnimState:OverrideSymbol("swap_object", "swap_sweeneyrazor", "swap_sweeneyrazor")        owner.AnimState:Show("ARM_carry")        owner.AnimState:Hide("ARM_normal")    end     local function OnUnequip(inst, owner)        owner.AnimState:Hide("ARM_carry")        owner.AnimState:Show("ARM_normal")    end

where it should be

local function OnEquip(inst, owner)        owner.AnimState:OverrideSymbol("swap_object", "swap_sweeneyrazor", "swap_sweeneyrazor")        owner.AnimState:Show("ARM_carry")        owner.AnimState:Hide("ARM_normal")    end     local function OnUnequip(inst, owner)        owner.AnimState:Hide("ARM_carry")        owner.AnimState:Show("ARM_normal")    end

I made the edit and it didn't work, I even copied the sweeneyrazor.lua from what you sent back and it still doesn't show up.... i'm going to keep looking at it though... i've managed to do a bunch of complicated coding for the character but this darn custom item is stumping me.

 

Issue fixed, was the .png location among the swap folders.... Great tutorial! I had to really read it over and over to catch that.

Edited by chupicabra

Share this post


Link to post
Share on other sites
Volgera    3

just one quick question... I want to upscale my swap_myitem. I adjusted the scale in spriter and the scml file states that the size is bigger than the original image, though in-game the size of the image doesn't change at all :S how can I fix this?

Share this post


Link to post
Share on other sites
Mobbstar    13994

just one quick question... I want to upscale my swap_myitem. I adjusted the scale in spriter and the scml file states that the size is bigger than the original image, though in-game the size of the image doesn't change at all :S how can I fix this?

 

Don't scale in spriter, change the image itself

Share this post


Link to post
Share on other sites
Volgera    3

Don't scale in spriter, change the image itself

 

I had hoped that changing the scale in spiter would've worked... as the original image I'm using seems bigger than how it's shown in-game

Share this post


Link to post
Share on other sites
Volgera    3

correction: my image is as big as a gold vein in-game. so it's impossible that the image isn't auto-resized by something... I just can't figure out where it happens exactly....

Share this post


Link to post
Share on other sites
Corrosive    162

@Volgera,
 
 
 


All swap items (such as hats and weapons and armor actually literally get swapped into your character's build when equipped. It's not shown in Spriter due to technical limitations, but in addition to all of the layers in the extended character template, there are additional layers called "swap_object" (and swap_hat, etc.) in the actual animation files. When you equip an item the game replaces the blank image in that layer with the one from your swap_ build. So if you apply a transform to the character's animation, equipped items inherit that transform as well, since at that point they're part of the animation.

 

 

 

you need to change the actual dimensions of the sprite image files, not the size within spriter-- since you are literally just swapping your sprites into the existing player animations, literally nothing done to the sprites within the spriter project will affect the in-game look the of character. (Or rather, no transforms that you apply in Spriter will make it-- the only thing that matters is the layer names in spriter, and the actual image used in that layer on the first keyframe) The x/y position, x/y scale, rotation, and any other animation-related attribute of each symbol is already baked into the player animations. What you are doing is swapping the sprites in the default symbols with your own sprites.

 
 
If your swap_object is displaying larger than it actually is, then all items you equip should be equally embiggened.  If you want to attach your mod though, I can take a look.

Edited by Corrosive

Share this post


Link to post
Share on other sites
Corrosive    162

@Volgera,
 
Those images are gigantic =o
 
Is your image editor's zoom level below 100%?
 
Right click on swap_pan.png and go to "Properties." it's 170 x 170 pixels.  Swap objects are significantly smaller.

Share this post


Link to post
Share on other sites
Volgera    3

I enlargened the image after upscaling the image in spriter didn't work... that's why it's so big :p

 

but I'm somewhat wondering. The image is as big as the example wand is. Whenever I equip a pickaxe I get a bigger image attached to the character. Is there anything in code that sets the size of the images for the character build?

Share this post


Link to post
Share on other sites
Corrosive    162

@Volgera,

 

I enlargened the image after upscaling the image in spriter didn't work... that's why it's so big :razz:

 

Ahh, I see.  I take it that you didn't actually recompile it in that size because I loaded up your mod and it's the size it's supposed to be.

 

FWIW though, the example wand doesn't actually have correct dimensions ;)

 

Whenever I equip a pickaxe I get a bigger image attached to the character. Is there anything in code that sets the size of the images for the character build?

 

That's.... strange O.o  AFAIK there's no way to do that.  If there was, it would be a function of AnimState.  Although AnimState is of the Userdata type, you can see which C++ functions are exposed by doing this:

for k,v in pairs(getmetatable(GetPlayer().AnimState).__index) do print(k,v) end

The only relavant function is SetScale, but that's a function which has two parameters, and scales the entire animation along the x and y axis, respectively.

 

There is also a SetScale function on the Transform object attached to entities, which is similar but has some differences. It accepts an x, y, and z argument, although you won't see any effect on animation's size with the z argument(since everything is 2d).

 

Oddly though, Transform:SetScale() also adjusts the entity's base speed on each individual axis based on the scale.  (Only it doesn't adjust the axes based on the sprite's facing.  Setting Transform:SetScale(1,1,0) on the player effectively disables your ability to move along the world's z-axis, locking you into moving only due north or south.)  But now I'm just rambling.

 

In any case, if you want I can attach a lua script I made that is able to parse anim.bin and build.bin files into lua tables and you can look at the internal structures of the files.

Share this post


Link to post
Share on other sites
Volgera    3
Ahh, I see. I take it that you didn't actually recompile it in that size because I loaded up your mod and it's the size it's supposed to be.

 

could you show me a picture of it then? I'm intending the pan to be almost as big as Wilson's head (just like a pickaxe).

 

and as far as I was mentioning the "bigger image", the image of the pan is significantly smaller than the image of the pickaxe when Wilson is holding bot the items :p

 

and I hope by recompiling you just mean saving the swap_pan anew?

Share this post


Link to post
Share on other sites
Corrosive    162
I'm intending the pan to be almost as big as Wilson's head (just like a pickaxe).

 

Ah, it's too small then-- I assumed you wanted it the size of an actual frying pan <.< Can't say I've ever seen a pickaxe sized pan before.  Maybe a wok...

 

Anyhoo, If the "last modified" timestamp of an .scml file located within the /exported folder is ever changed, the next time you open Don't Starve, the autocompiler (via scml.exe and a handful of python scripts) compiles the scml files and associated images into Klei's animation/build binary formats, zips them up, and sticks them in the /anim folder of your mod.

 

If you change your images and want those changes to be reflected in-game, you need to either get spriter to save over the current scml, or manually run it through the compiler(which is what I do personally, I made a little batch script that I use to generate a batch script for each mod project, and then when I want to compile those scml files, I can just double click the script.)

 

If you want a copy of that script, you can find it here: http://forums.kleientertainment.com/topic/53787-extended-character-sample-issue/#entry636387

 

It's very, very easy to use.  It only has one set up step, which only involves dropping a file on the script.  There's a really short video inside (under a minute, and most the time is used by the compiler itself) demonstrating setting it up and creating a batch file that compiles two different scml files.  The only thing I would mention is you see me dropping the file "scml2.exe" onto the batch.  scml2 is a modified version of scml.exe that I haven't released yet.  You can just drag scml.exe over instead.

Share this post


Link to post
Share on other sites
Volgera    3
If you change your images and want those changes to be reflected in-game, you need to either get spriter to save over the current scml, or manually run it through the compiler(which is what I do personally, I made a little batch script that I use to generate a batch script for each mod project, and then when I want to compile those scml files, I can just double click the script.)

 

I have tried that... I even deleted the entire swap_pan and remade it with the new image to see if it worked, but then still it stays the same size as last time. I'll try out the method you described and see if that works

Share this post


Link to post
Share on other sites
ajlaj25    1

Hello!

 

Im stuck at making the ground_myitem animation. I think ive made everything correctly but the autocompiler wont make the anim/myitem.zip file ( it should make it automatically, right? ). So i get this error:

 

 

anyone, any idea?

_1mod.zip

post-649403-0-60480600-1432056412_thumb.

Share this post


Link to post
Share on other sites
Corrosive    162

@ajlaj25,

 

You've downloaded the mod tools on steam, yes?  If so, there is a good chance that the autocompiler is throwing an error while trying to compile an .scml file from another mod before it gets to yours.  You can try one of two fixes:

 

  1. Temporarily move all your mods-- except the one you want to compile the animations for-- out of the mods folder and then attempt to load the game.
  2. Use the tool I linked to in the post directly above yours to force the scml compiler to build your animation.

Share this post


Link to post
Share on other sites
Corrosive    162

@Volgera,

 

Make sure that your .scml reflects the new dimensions before you recompile.  For example, the first image below is

<file id="0" name="swap_pan/swap_pan.png" width="256" height="256" pivot_x="0.491719" pivot_y="0.185459"/>

while the second is:

<file id="0" name="swap_pan/swap_pan.png" width="728" height="728" pivot_x="0.491719" pivot_y="0.185459"/>

vqbtKsSt.png

fbSA9C9m.png

  • Like 1

Share this post


Link to post
Share on other sites
RedRock911    36

Ok, so I'm making an edible food type, as far as making the build, its relatively the same steps, except instead of a swap_item file, we just essentially have one file for the ground? (this item isnt going to be on a drying rack or a crockpot recipe) 

Share this post


Link to post
Share on other sites

Ok, for the LIFE of me, I cannot figure out my issue. I am having the same problem as many others - works until you equip it in the hand and suddenly poof! It's gone.

 

I have scoured this thread, tried everything I could find, and used the wand example from the OP as a guide.

 

Nothing has worked! ;_; So here's my mod, it's a character + a weapon (you should be able to just select the character and he will spawn with it). I would like to make an important note that this is a mod for DST and I don't know if it will work for regular DS.

 

Plz help.

link_mod.zip

Share this post


Link to post
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
Sign in to follow this