Sign in to follow this  
Malacath

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

Recommended Posts

Plz help.

 

Ok so I just started over from scratch and now it's workin'. I don't know if I can edit my post, but I'm hoping I can delete it since I posted my unfinished mod?

 

I'm not sure what the problem was in the end since I just started all over, but...

 

Don't forget to right click the pivot point in Spriter and override the default pivot!

Share this post


Link to post
Share on other sites
Corrosive    162

@AleksandrPlz,

 

I literally just typed up a big ol explanation of it and about 80% of the way through I got the dreaded '1 new message' indication.

 

 

Essentially what the problem was, was that your image was too large.  You had a huge section of transparent space on the bottom and right, which caused your atlas texture to get split into two parts.  For technical reasons, your symbol was getting named "symbol0."  You could verify that by doing OverrideSymbol("swap_object", "swap_mastersword", "symbol_0"), but unfortunately the pivot info gets lost as well, so your character would just kinda hold it from the top left corner of the image.

Share this post


Link to post
Share on other sites

@AleksandrPlz,

 

I literally just typed up a big ol explanation of it and about 80% of the way through I got the dreaded '1 new message' indication.

 

 

Essentially what the problem was, was that your image was too large.  You had a huge section of transparent space on the bottom and right, which caused your atlas texture to get split into two parts.  For technical reasons, your symbol was getting named "symbol0."  You could verify that by doing OverrideSymbol("swap_object", "swap_mastersword", "symbol_0"), but unfortunately the pivot info gets lost as well, so your character would just kinda hold it from the top left corner of the image.

Ahaha, that makes sense. I noticed the two atlas files and was confused as to why they were there. Hopefully this explanation can still serve someone else with the same problem!

Share this post


Link to post
Share on other sites
CarbonLord    1

I have done everything by the guide yet I cannot see the item in my hand, I can see it in the inventory and on the ground. Any ideas why?
Just pasting the code as this might be the cracker:

local assets={    Asset("ANIM", "anim/myitem.zip"),    Asset("ANIM", "anim/swap_myitem.zip"),     Asset("ATLAS", "images/inventoryimages/myitem.xml"),    Asset("IMAGE", "images/inventoryimages/myitem.tex"),}local prefabs = {}local function fn()     local function OnEquip(inst, owner)        --owner.AnimState:OverrideSymbol("swap_object", "swap_myitem", "swap_myitem")        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     local inst = CreateEntity()    local trans = inst.entity:AddTransform()    local anim = inst.entity:AddAnimState()    local sound = inst.entity:AddSoundEmitter()    MakeInventoryPhysics(inst)         anim:SetBank("myitem")    anim:SetBuild("myitem")    anim:PlayAnimation("idle")     inst:AddComponent("inspectable")         inst:AddComponent("inventoryitem")    inst.components.inventoryitem.imagename = "myitem"    inst.components.inventoryitem.atlasname = "images/inventoryimages/myitem.xml"         inst:AddComponent("equippable")    inst.components.equippable:SetOnEquip( OnEquip )    inst.components.equippable:SetOnUnequip( OnUnequip )     return instendreturn  Prefab("common/inventory/myitem", fn, assets, prefabs)

Share this post


Link to post
Share on other sites
Corrosive    162
--owner.AnimState:OverrideSymbol("swap_object", "swap_myitem", "swap_myitem")

 

Might have something to do with the fact that the line that swaps your item into the player character's animations is commented out ;)

Share this post


Link to post
Share on other sites

So I was just having the issue with the swap_item not showing, but I managed to fix it by messing with the directory structure - perhaps you could try that?
 

my final structure looked like:

>mod

   >exported

   >images

 

Share this post


Link to post
Share on other sites
Corrosive    162

@Notsoinsaneguy,

 

This is correct.  It's not obvious without dissecting the binaries that get generated from the SCML, but the directory used to contain images actually gets converted into a 'symbol', with all images in that directory turning into 'symbol frames'.  Naturally, this is important to a function called "OverrideSymbol" ;)

Share this post


Link to post
Share on other sites

Hi, I've been having a bit of trouble with a practice mod. And so far I've been successful but I've hit a wall.

 

I would appreciate it if someone could have a look over what I got here and tell me what I need to fix.

The issue at hand is that I can't seem to get the weapon to appear in the hand. I got the inventory item graphic working, and I got it showing up on the ground properly, but I can't seem to get it to appear in the hand on equip.

 

I've been going over my syntax over and over and over and have given up hope. So if someone with more experience knows whats up, I could use the help. Thanks.

 

https://dl.dropboxusercontent.com/u/42735028/sword.zip

 

I'm new enough at this to where I wish I knew how to properly attach a file like you other pros.

Share this post


Link to post
Share on other sites

I followed the tutorial and I'm pretty certain I followed it exactly. However, for some reason when I equip the item, it is invisible. I can see the item in my inventory and I can see it when it is on the ground, but equipped it just doesn't show up at all. I've read the numerous posts talking about this issue and haven't found any solution that solved my issue. I'm not certain what to do now. Can anybody help me please? Here is the code for the swap_carrerascythe item. Hopefully the problem is just that I missed something with this code and am too new at scripting to realize what the error is.

 

local assets={	Asset("ANIM", "anim/carrerascythe.zip"),	Asset("ANIM", "anim/swap_carrerascythe.zip"),    Asset("ATLAS", "images/inventoryimages/carrerascythe.xml"),    Asset("IMAGE", "images/inventoryimages/carrerascythe.tex"),}prefabs = {}local function fn()    local function OnEquip(inst, owner)        owner.AnimState:OverrideSymbol("swap_object", "swap_carrerascythe", "swap_carrerascythe")        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    local inst = CreateEntity()    local trans = inst.entity:AddTransform()    local anim = inst.entity:AddAnimState()    local sound = inst.entity:AddSoundEmitter()    MakeInventoryPhysics(inst)      anim:SetBank("carrerascythe")      anim:SetBuild("carrerascythe")      anim:PlayAnimation("idle")    inst:AddComponent("inspectable")    inst:AddComponent("inventoryitem")    inst.components.inventoryitem.imagename = "carrerascythe"    inst.components.inventoryitem.atlasname = "images/inventoryimages/carrerascythe.xml"    inst:AddComponent("equippable")    inst.components.equippable:SetOnEquip( OnEquip )    inst.components.equippable:SetOnUnequip( OnUnequip )    return instendreturn  Prefab("common/inventory/carrerascythe", fn, assets, prefabs)

 

any help would be greatly appreciated. If you need any other info like the .scml file for swap_carrerascythe or anything like that, let me know, because I would really like to know why the equipment won't show up.

Share this post


Link to post
Share on other sites

Sorry to double post but I figured out the problem (or at least I think I figured out the problem) and fixed it. Initially my folders went exported -> myitem -> swap_myitem and before I even got to the part of the tutorial where it goes into making the swappable build thing in spriter, I caught the mistake and fixed it. however, by that point, I had also already run the game with line 4 of myitem.lua commented out and an anim zip for the swap_myitem had been built based on the old folder i guess, and something about that was messing up the whole thing. I deleted the old anim and built a new one with the correct folder layout and voila, the item shows up when equipped now. hopefully this can help any of the other people who have come across this and found themselves confused over why the answers earlier in the thread weren't helping them.

Share this post


Link to post
Share on other sites
ntdi    0

Does someone can help me? I did everything so far, but I cannot get it work, without getting crashed. Also I dont know how to create Animationions.zip, cant find a guide for it in this tutorial. ibis.ell is my skypename, if anyone is willing to help, i wold be sooooo fkin thankful guys. It would be a dream becoming true for me beeing able to create weapons for dont starve.

Share this post


Link to post
Share on other sites
nenere1    0

Hi ,

 

I realy enjoyed your tutorial, thanks, but i got 2 problems, please give me a solution:

 

- my item in-game is named "missing name"

 

- my item doenst appear in my hand in-game

 

(i'm using DST)

 

Hope you help me,

Thanks

Share this post


Link to post
Share on other sites
AfrostLord    2

Actually let me elaborate. The myitem.lua says that the myitem build is in anim/myitem.zip by default, but the guide never mentions anything about creating this .zip. I assumed I should just replace this to the path to the .scml (exported/myitem/ground_myitem/myitem.scml), and the game accepted that (i.e. it ran without crashing) but the item does not show up on the ground. Am I supposed to make a .zip? What am I supposed to put in this .zip? What am I doing wrong?

Share this post


Link to post
Share on other sites
AfrostLord    2

Okay, apparently the cmd compiler thing automatically makes the .zip, copied the rest from the wand example. However, the item is still invisible when I equip it. Is copying the animation and build from the swap_wand.zip to my swap_myitem not the thing to do? Because otherwise my stuff matches the stuff in the wand mod replaced with my own. Copying the animation and build from wand.zip to myitem.zip did work for the ground animation, but I'm assuming the swap animation is different.

Share this post


Link to post
Share on other sites
BaconAndRibs    10

Hello, I seem to have a similar issue to others but can't seem to find the solution. I am trying to create a mod for the chester eyebone by making it equipable but when i load the game and spawn the eyebone, it just shows the eyebone floating under the characters hand. I have tried to follow the insructions as close as possible and have done almost everything proper. Can someone please help me with fixing this?

 

This is what I have so far.

 

Attack of the Chester.zip

Share this post


Link to post
Share on other sites
BaconAndRibs    10

Does anyone know how to change the image when the character faces a different direction?

 

EDIT:

 

Also, is it possible to play an animation while an item is in the players hand? I am trying to get the eyebone to blink and look around like when it's on the ground but while equipped.

 

What I have so far that is working.

 

Attack of the Chester.zip

Edited by BaconAndRibs

Share this post


Link to post
Share on other sites
Malacath    123

@Corrosive, Thanks for helping many many people in my abandoned tutorials! You're awesome  :)

 

@BaconAndRibs,unfortunately: No and no.

Both could in theory be achieved by completely recreating the animations and using different symbols. But the amount of work to do for both of these is immense and I am not even going to attempt it.

The second can also be achieved by swaping the symbol in the code, using some PeriodicTask and swaping every now and then. But that is tedious as well and needs to be hardcoded, an artist is not going to enjoy that.

Both options are not really optimal, I would not do either (at least not a second time  xD)

  • Like 1

Share this post


Link to post
Share on other sites
BaconAndRibs    10

@Corrosive, Thanks for helping many many people in my abandoned tutorials! You're awesome   :-)

 

@BaconAndRibs,unfortunately: No and no.

Both could in theory be achieved by completely recreating the animations and using different symbols. But the amount of work to do for both of these is immense and I am not even going to attempt it.

The second can also be achieved by swaping the symbol in the code, using some PeriodicTask and swaping every now and then. But that is tedious as well and needs to be hardcoded, an artist is not going to enjoy that.

Both options are not really optimal, I would not do either (at least not a second time  xD)

 

Thanks for the info. I would still like to atempt making different images show when facing a different direction but I might just skip the animations. I was reading a previous post here and attepted to use the code but I am unable to get the symbols to replace each other when the player turns. Do I have to create two seperate .scml files in order for them to switch or can I just create a seperate animation in the one .scml file and call the two symbols in the code?

Share this post


Link to post
Share on other sites
Malacath    123

@BaconAndRibs, from my understanding you would need multiple files since the scml-compiler will create only one swappable anim file from one scml. If you manage with one file let me know though  ;)

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