Sign in to follow this  
Malacath

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

Recommended Posts

rons0n    124

Gosh I don't know what i'm doing wrong. And worse, at the very beginning of the tutorial. Curse my reading comprehension.

 

I believe i put the items in the right directories; the images in the corresponding folders, and all that is required to put in the prefabs and modmain. But why isn't it touching the exported folder?

 

http://www.4shared.com/zip/QMdULbokce/mymod.html

 

Also, how do you upload files into this forum? I swear it was using MyMedia but i don't know how to navigate it.

Share this post


Link to post
Share on other sites
Foxrai    12

I might have one good advice for all of you who have problem with this tutorial - worked for me.

 

1. If anything went wrong - DELETE that wrong part files and GO OVER AGAIN the step you failed

2. By doing point 1. read again SLOWLY and CAREFULLY what Malacath wrote - he is right there and if you really follow litteraly every single word he writes - you will succeed. 

 

that is mostly with swap_item part which seems to cause most of problems. Just really care about folder names - if there is swap_myitem TWICE in the line - it HAS to be twice. No mistakes. 

 

/\ /\ /\ Thats for the mod working in general -

 

Time for my stupid question tho:

 

I can't see where to set item name... Means - when I hover cursor over the item on the ground it shows MISSING NAME... 

 

Also still can't seem to find working way to add item icon in recipe tables.. -.-' 

 

Sorry for my ignorance for "beatiful-art-of-informatics" :razz:

Edited by Foxrai

Share this post


Link to post
Share on other sites
Malacath    123
Also, how do you upload files into this forum?

You can simply upload a *.zip file to a post you make by choosing "More Reply Options". I will not check out your file for now, I don't want to create an account on the website. But as Foxrai said in the post bellow, if you follow my tutorial exactly then you will succeed.

 

 

I can't see where to set item name... Means - when I hover cursor over the item on the ground it shows MISSING NAME...    Also still can't seem to find working way to add item icon in recipe tables.. -.-' 

I skipped over that part. But pretty much every other mod you can download gives an example of how to do that. The easiest route is to add directly into modmain

GLOBAL.STRINGS.NAMES.MY_ITEM = "Name Of My Item"

Note that the name of your item has to be in capital letters here.

And as for the recipe image, I know that it works like this and it is not necessary to add a second image for the silhouette. Since the image contains alpha information the engine simply blackens all the non-transparent parts. You can upload your mod if you want, but in general this thread is not really the place for that. I am alos pretty sure that you can find a topic that already settled this problem somewhere on the forums.

EDIT: In fact you find a LOT of those threads. Here's one of the first threads that explain it

Edited by Malacath

Share this post


Link to post
Share on other sites
Foxrai    12

Alot of threads made me few crashes :razz:

Also ye - i added even more:

 

modmain.lua looks like this now:

 

GLOBAL.STRINGS.NAMES.MYITEM = "Name of an item"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.MYITEM = "Examine description of my item"
 
PrefabFiles = {
    "myitem",
}
 
You are the "smart guy" here so I'm not even trying to argue about recipe picture :-)
Looks like this now:
 
my_character > images > item.png   *64x64 pixels - also tried bigger sizes but though this could be the problem..
 
also item.tex and item.xml here after compiling. But still it doesnt want to show image in the Recipe table in game.. All code according hound mound (lets call it "item" for now) looks like this:
 
local item = Recipe("item", {Ingredient("aaa", 1000)}, RECIPETABS.TOWN, TECH.NONE)
hound_recipe.atlas = "images/item.xml"
hound_recipe.sortkey = 1
STRINGS.RECIPE_DESC.ITEM = "bla bla bla blah."
 
no idea what am I missing then :/
Edited by Foxrai

Share this post


Link to post
Share on other sites
rons0n    124

You can simply upload a *.zip file to a post you make by choosing "More Reply Options". I will not check out your file for now, I don't want to create an account on the website. But as Foxrai said in the post bellow, if you follow my tutorial exactly then you will succeed.

 

 

I skipped over that part. But pretty much every other mod you can download gives an example of how to do that. The easiest route is to add directly into modmain

 

Thank you good sir!

and thanks everyone who insisted to retrying from scratch because it worked!

A big problem was because my auto-compiler refused to work so i just gave up and let my friend do that part.

 

I'll be on my way!

  • Like 1

Share this post


Link to post
Share on other sites

What makes the .zip file btw?

 

But lets take a step back, where should I be creating my Mod at? Should I house my mod anywhere (desktop) or does it have to be under the. Don't starve mod tools folder?

 

To be honest, all I have been doing is dragging myMod folder into Don't Strave Together Beta: mods folder, then running the game... which now up to this anim/xxx.zip problem gives me kill the game errors.

 

 

Btw, I do have the correct Exported folders set up, along with the .png and .scml.   I just don't know where the .zips come into play or where its created

Share this post


Link to post
Share on other sites

Also wanted to add... this "Save that file as "myitem.scml", without the ".scml" this will be the name of our build." What the heck does that mean?

 

SO the name to save as would be "myitem" or is it "myitem.scml"  like the .scml part for "swap_myitem.scml"

Share this post


Link to post
Share on other sites
Foxrai    12
Also wanted to add... this "Save that file as "myitem.scml", without the ".scml" this will be the name of our build." What the heck does that mean?   SO the name to save as would be "myitem" or is it "myitem.scml"  like the .scml part for "swap_myitem.scml"

 

Save as:

 

item

 

>> you only type the word item

 

Save the "swap" as:

 

swap_item.scml

 

>> you type in the .scml as well in SWAP part but important part:

 

really really care WHERE do you start your project with. Make sure u choose right directory from very start of "swap" project in spriter. Tip is: while you do, read every single word Malacath wrote at the beggining and just follow it - then ur done ^^

Edited by Foxrai

Share this post


Link to post
Share on other sites

Thanks, where does one start with their Mod folder? Currently I just have a Project area on my desktop, which I copy/paste into Don't Starve Together Mod folder.

 

 

Is this ok? Or do I work on my mod folder under the Don't Starve Mod Tools, below _CommonRedist and mod_tools folders?

Share this post


Link to post
Share on other sites
Foxrai    12
Thanks, where does one start with their Mod folder? Currently I just have a Project area on my desktop, which I copy/paste into Don't Starve Together Mod folder.

 

It's ok to copy ur mod from desktop folder to "mods" in dont_starve folder. Works for me :p apart from all other "small" issues xD

 

but ye copying will work :) 

Share this post


Link to post
Share on other sites
Foxrai    12

Malacath, I'm wondering if you maybe know how it looks like with placer-items?  Like campfire, walls, science machine, chests? Anything you can place on the ground. Trying to figure it out and can't -.-'

Edited by Foxrai

Share this post


Link to post
Share on other sites
Malacath    123

Malacath, I'm wondering if you maybe know how it looks like with placer-items?  Like campfire, walls, science machine, chests? Anything you can place on the ground. Trying to figure it out and can't -.-'

It's just one line at the end of your items file, i.e.

return Prefab( "common/inventory/spelltome", fn, assets),       MakePlacer("common/spelltome_placer", "spelltome", "spelltome", "idle")

Where the strings are Bank, Build and Animation.

 

Edit: That question doesn't really fit in this thread. You can search the forums or create your own thread instead when you have a question.

Edited by Malacath

Share this post


Link to post
Share on other sites
Foxrai    12

It's just one line at the end of your items file, i.e.

return Prefab( "common/inventory/spelltome", fn, assets),       MakePlacer("common/spelltome_placer", "spelltome", "spelltome", "idle")
Where the strings are Bank, Build and Animation.

 

Edit: That question doesn't really fit in this thread. You can search the forums or create your own thread instead when you have a question.

Thank you and sorry :-)

I really searched but didn't find anything closer to what I need and thought of asking the smarter person ;)

Share this post


Link to post
Share on other sites
Sketchiverse    29

Hello Malacath, thank you for this great tutorial,

 

I'm having a problem with my swappable build though... I'm making a handslot item and it's working, except that whatever I do, the item never appears in-game in the character's hand.

 

I did everything you said, the game doesn't crash and it compiled correctly, the zip files are all correctly placed in the anim directory, I tried different folder structures to see if the double 'swap' folders was a mistake in your post or not... I did the code correctly, I moved the pivot in spriter and named all the stuff correctly and I'm pretty sure that the picture is big enough... Do you have any idea of what could be wrong with my item...?

 

Here's a version of my mod with only the item and its files in it. I hope someone can find out what's wrong...

 

Edit: Problem solved, it was the placement of my .scml file.

The right structure for a handslot item is :

exported/- item/- - ground_item/- - - ground_item.png- - - item.scml- - swap_item/- - - swap_item.scml- - - swap_item/- - - - swap_item.png

If anyone wants to see my mod, it's here.

Edited by Sketchiverse
  • Like 1

Share this post


Link to post
Share on other sites
RedRock911    36

--edited.

forget it, probably best way to learn is to start all over again, garbage in garbage out!

Finally, got it working. Would anyone consider making a video for this tutorial?

Share this post


Link to post
Share on other sites
RedRock911    36

First off cannot thank you enough for making this tutorial!

 

As far as I can tell, following the directions has helped me create quite a few hand equippable items. However, I am having 2 issues. I included screenies to help see if I can get them resolved

 

1. Placement::

  Is this something I need to artistically fix (size?) Or is there some sort of LUA script I need to use to have it be in my hand

 

2. Text:

When my character turns left, I'm assuming it just mirrors the image. Is there a way to put in a second image? I have 8 that I made, Or should I just grin and bare it, and make a symbol instead? 

 

Now in saying that, I planned to make this an item you can drink from. If anyone by any chance knows a resource page or tutorial where I can find info on how to do this, it will be very much appreciated! 

post-568384-0-81454600-1425146867_thumb.

post-568384-0-71470000-1425146874_thumb.

Share this post


Link to post
Share on other sites
Corrosive    162

@RedRock911,

 

1.  You need to set the pivot point of your item within Spriter.

 

2.  The problem is that the animation data for your item is contained in the player animations.  Using OverrideSymbol() only replaces an existing sprite with a new sprite. There are only two ways to swap out the image that I can think of at the moment.  To do more than flip the image, you would have to override all character animations that are holding the item.  Alternatively, you can do like I did in a mod of mine and create separate symbol overrides for different directions.

 

ex. from my mod

        local dir = inst.AnimState:GetCurrentFacing()                if (inst.components.inventory.equipslots.hands and inst.components.inventory.equipslots.hands.prefab == "megaplanter" and inst.components.inventory.equipslots.hands.ison) then            if ((dir == 1) or (dir == 3)) then                inst.AnimState:OverrideSymbol("swap_object", "swap_megaplanter_anim", new_anim_symbol)            else                inst.AnimState:OverrideSymbol("swap_object", "swap_megaplanter", "swap_megaplanter")            end        end

I use this to change the sprite of the held item depending on if the character is facing left/right or up/down.  Note that I only use this when the item is active and the character is running, though, and it's designed to work with any character.  For my up/down running animation, I created 9 different images and rotate through them like a flipbook by injecting them into the player's run stategraph:

   runstate = player.sg.sg.states.run   for i = 0, 15, 1 do        table.insert(runstate.timeline, TimeEvent(i*FRAMES, DoMpCheck))    end    -- Gotta re-sort the timeline by time or the animation turns into madness    local function resort_timeline(a,b)        return a.time < b.time    end        -- Tried an anonymous function here, didn't seem to work for some reason.    table.sort(runstate.timeline, resort_timeline)

This functionality is obviously a far cry from what you're looking to achieve, but it at minimum shows that what you're looking to do should be possible.  I'm unsure what the "best" approach is for you to provide consistent direction checking across all states.

Share this post


Link to post
Share on other sites
RedRock911    36

@RedRock911,

 

1.  You need to set the pivot point of your item within Spriter.

 

2.  The problem is that the animation data for your item is contained in the player animations.  Using OverrideSymbol() only replaces an existing sprite with a new sprite. There are only two ways to swap out the image that I can think of at the moment.  To do more than flip the image, you would have to override all character animations that are holding the item.  Alternatively, you can do like I did in a mod of mine and create separate symbol overrides for different directions.

 

ex. from my mod

        local dir = inst.AnimState:GetCurrentFacing()                if (inst.components.inventory.equipslots.hands and inst.components.inventory.equipslots.hands.prefab == "megaplanter" and inst.components.inventory.equipslots.hands.ison) then            if ((dir == 1) or (dir == 3)) then                inst.AnimState:OverrideSymbol("swap_object", "swap_megaplanter_anim", new_anim_symbol)            else                inst.AnimState:OverrideSymbol("swap_object", "swap_megaplanter", "swap_megaplanter")            end        end

I use this to change the sprite of the held item depending on if the character is facing left/right or up/down.  Note that I only use this when the item is active and the character is running, though, and it's designed to work with any character.  For my up/down running animation, I created 9 different images and rotate through them like a flipbook by injecting them into the player's run stategraph:

   runstate = player.sg.sg.states.run   for i = 0, 15, 1 do        table.insert(runstate.timeline, TimeEvent(i*FRAMES, DoMpCheck))    end    -- Gotta re-sort the timeline by time or the animation turns into madness    local function resort_timeline(a,b)        return a.time < b.time    end        -- Tried an anonymous function here, didn't seem to work for some reason.    table.sort(runstate.timeline, resort_timeline)

This functionality is obviously a far cry from what you're looking to achieve, but it at minimum shows that what you're looking to do should be possible.  I'm unsure what the "best" approach is for you to provide consistent direction checkingarrow-10x10.png across all states.

Thank you for the response! It's worth the shot! The toon I'm making is turning out to be a bit more advanced then expected, little items like this keep popping up. You know, I was starting to wonder if anyone even reads this thread anymore.  Alot of my issues are very user knowledge based. Essentially I'm running into problems because I haven't learned it yet. 

So thank you for responding, I'll try the override system. 

Since I'm essentially working on 4 projects, my worse case scenerio is that i just go back to do something easy (working on a presentation to help with either the existing water project, or making stuff for my own if they don't like my art style) 

Edited by RedRock911

Share this post


Link to post
Share on other sites
bigpak    31

The reason it is below his hand as you didn't set the pivot point, to do that you right click on the red dot, and hit overwrite default pivot point, move it, do it again just to be safe, and save and whatnot. It took me a while to figure it out, you only do that in the swap animation however.

Share this post


Link to post
Share on other sites
RedRock911    36

The reason it is below his hand as you didn't set the pivot point, to do that you right click on the red dot, and hit overwrite default pivot point, move it, do it again just to be safe, and savearrow-10x10.png and whatnot. It took me a while to figure it out, you only do that in the swap animation however.

Ahhhh... I may have moved it in the ground_item as well, Thats what it must be, the pivot point. 

 

Also, as far as ading a modinfo.lua all i need to put in there is something like this? (courtesy of the boys from the api documentation team)

 

name = "Mod Name"
version = "1"
author = "Author Name"
 
description = [[Mod Description
Second line of desc]]
 
forumthread = "/files/file/"
 
 
api_version = 6
dont_starve_compatible = true
reign_of_giants_compatible = true
 
 
 
return
Edited by RedRock911

Share this post


Link to post
Share on other sites
RedRock911    36

Ran into some trouble today with the tutorial. I am positive it's on my end. I can't seem to get the item to show up in my hand no matter what I do. I'm also sure it has something to do with Spriter, it moved my files at one point, and at another didn't updatearrow-10x10.png my save when I switched the name "swap_myitem" to "swap_shiplantern".

 

However, being new, I am sure there is a step i've forgetten to take, or a name in the BUILD, I haven't done. At least I am hoping it's something that simple. The file is attached. 

 

 

shiplantern.zip

Edited by RedRock911

Share this post


Link to post
Share on other sites
bigpak    31

If it doesn't show up in your hand, its either you made the item completely transparent, or something is wrong with the animation, most likely the file structure in spriter. Let me take a look

Share this post


Link to post
Share on other sites
bigpak    31

I figured out why, go into shiplantern.lua and change --Asset("ANIM", "anim/swap_shiplantern.zip"),

 

to     Asset("ANIM", "anim/swap_shiplantern.zip"),

 

You had it commented out.

 

However, once I uncommented it the pivot point still wasn't correct, let me take a look at it and see if I can get it working

 

Whoops, acidentally double posted.

 

Alright, I fixed the pivot point, you didn't hit right click and overwrite default pivot point, so it wasn't using the correct pivot point. To set the new pivot point, right click on the dot, overwrite default pivot point, then save the project.

 

Let me go ahead and upload the fixed files, one moment.

 

Well, this makes me feel less useless at least, enjoy!

 

if worse comes to worse I suppose I could upload a spriter tutorial if I can figure out how to get fraps to record the desktop, I believe it is possible.

shiplanternfixed.zip

Edited by bigpak

Share this post


Link to post
Share on other sites
RedRock911    36

I figured out why, go into shiplantern.lua and change --Asset("ANIM", "anim/swap_shiplantern.zip"),

 

to     Asset("ANIM", "anim/swap_shiplantern.zip"),

 

You had it commented out.

 

However, once I uncommented it the pivot point still wasn't correct, let me take a look at it and see if I can get it working

 

Whoops, acidentally double posted.

 

Alright, I fixed the pivot point, you didn't hit right click and overwrite default pivot point, so it wasn't using the correct pivot point. To set the new pivot point, right click on the dot, overwrite default pivot point, then save the project.

 

Let me go ahead and upload the fixed files, one moment.

 

Well, this makes me feel less useless at least, enjoy!

 

if worse comes to worse I suppose I could upload a spriter tutorial if I can figure out how to get fraps to record the desktop, I believe it is possible.

Thank you so much! Seems like that's been a huge problem for newer modders, almost every problem I have seen is either been the Spriter issue with the save "swap_myitem.scml" or not knowing to right click on the pivot point. I also fixed that bottle I was working on. One thing that helped was I went back to my artwork and changed the size of the layer. I don't know if that helped. But as soon as I did that, and redid the pivot point, the art in game finally aligned correctly. I can't believe I've spent a day and a half on a tutorial that generally takes 35-40 minutes to create. And now to sacrifice a small bird in your honor! 

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