Batmanwarrior Posted January 3, 2015 Share Posted January 3, 2015 Hi, I just made a custom prefab and it works as intended, I can eat it, craft it, it stacks and shows in the inventory. BUT when i drop it, it is invisible. This is the third day of trial and error, I really need some help.I used the spriter program in Dont starve mod tools to make a new project and compile it into anim folder, but I think that i've missed something along the way. Here's my code for the prefab:local Assets ={Asset("ANIM", "anim/monsterheart_build.zip"),Asset("ATLAS", "images/inventoryimages/monsterheart.xml"),}-- Write a local function that creats, customizes, and returns an instance of the prefab.local function fn(Sim)local inst = CreateEntity()inst.entity:AddTransform()inst.entity:AddAnimState()MakeInventoryPhysics(inst)inst.AnimState:SetBank("cutstone")inst.AnimState:SetBuild("monsterheart_build")inst.AnimState:PlayAnimation("idle")inst:AddComponent("inventoryitem")inst.components.inventoryitem.atlasname = "images/inventoryimages/monsterheart.xml"inst:AddComponent("edible")inst.components.edible.ismeat = trueinst.components.edible.foodtype = "MEAT"inst:AddComponent("stackable")inst.components.stackable.maxsize = 10return instend-- Add some strings for this itemSTRINGS.NAMES.MONSTERHEART = "Monsterheart"-- Finally, return a new prefab with the construction function and assets.return Prefab( "common/inventory/monsterheart", fn, Assets) Here's the modmain if that helps:PrefabFiles = {"thana","monsterheart",}Assets = {Asset( "IMAGE", "images/saveslot_portraits/thana.tex" ),Asset( "ATLAS", "images/saveslot_portraits/thana.xml" ),Asset( "IMAGE", "images/selectscreen_portraits/thana.tex" ),Asset( "ATLAS", "images/selectscreen_portraits/thana.xml" ),Asset( "IMAGE", "bigportraits/thana.tex" ),Asset( "ATLAS", "bigportraits/thana.xml" ),Asset( "IMAGE", "images/map_icons/thana.tex" ),Asset( "ATLAS", "images/map_icons/thana.xml" ),Asset( "IMAGE", "images/avatars/avatar_thana.tex" ),Asset( "ATLAS", "images/avatars/avatar_thana.xml" ),Asset( "IMAGE", "images/avatars/avatar_ghost_thana.tex" ),Asset( "ATLAS", "images/avatars/avatar_ghost_thana.xml" ),Asset("ATLAS", "images/inventoryimages/monsterheart.xml"),Asset("IMAGE", "images/inventoryimages/monsterheart.tex"),}local require = GLOBAL.requirelocal STRINGS = GLOBAL.STRINGSRECIPETABS = GLOBAL.RECIPETABSRecipe = GLOBAL.RecipeIngredient = GLOBAL.IngredientTECH = GLOBAL.TECHlocal monsterheartrecipe = GLOBAL.Recipe("monsterheart",{Ingredient("monstermeat", 3),Ingredient("meat", 3),Ingredient("rabbit", 1),},RECIPETABS.FARM, TECH.NONE )STRINGS.RECIPE_DESC.MONSTERHEART = "Thu thump thu thump\nThe rhytm of life."monsterheartrecipe.atlas = "images/inventoryimages/monsterheart.xml"-- The character select screen linesSTRINGS.CHARACTER_TITLES.thana = "Thana"STRINGS.CHARACTER_NAMES.thana = "Thana"STRINGS.CHARACTER_DESCRIPTIONS.thana = "*LVL 1-10\n*Stronger at night + nightvision\n*Small healthregen"STRINGS.CHARACTER_QUOTES.thana = "\"The nightstalker\""-- Custom speech stringsSTRINGS.CHARACTERS.THANA = require "speech_thana"-- The character's name as appears in-gameSTRINGS.NAMES.THANA = "thana"-- The default responses of examining the characterSTRINGS.CHARACTERS.GENERIC.DESCRIBE.THANA ={GENERIC = "It's Thana!",ATTACKER = "That Thana looks shifty...",MURDERER = "Murderer!",REVIVER = "Thana, friend of ghosts.",GHOST = "Thana could use a heart.",}-- Let the game know character is male, female, or robottable.insert(GLOBAL.CHARACTER_GENDERS.FEMALE, "thana")AddMinimapAtlas("images/map_icons/thana.xml")AddModCharacter("thana") I just want the item to be visible when dropped on the ground, that's the "only" part left. I've looked in the log.txt but i can't see what the problem is (if it's supposed to show there). If needed, I can attach other files so you can have a look at it. I appreciate your help, thanks in advance! Best regardsBatmanwarrior Link to comment Share on other sites More sharing options...
Kzisor Posted January 3, 2015 Share Posted January 3, 2015 (edited) @Batmanwarrior, the problem is most likely got to do with your animations. This is the root cause to 90% of items not showing up correctly. I'd suggest experimenting with using a different animation build and bank to see if it shows up properly. If it does then you have narrowed it down to the root cause, your animation files. You'll also need to add a new line of code for it to show on the clients machine. inst.entity:AddNetwork()Without that line no matter the amount of debugging you do it will not show up on the clients machine. Edited January 3, 2015 by Kzisor Link to comment Share on other sites More sharing options...
rezecib Posted January 3, 2015 Share Posted January 3, 2015 inst.AnimState:SetBank("cutstone") Are you sure that's what you want? You said you went through Spriter, so you may have your own anim.bin to use instead of the cutstone anim. One thing that's also potentially confusing when compiling the Spriter project is that it will create one zip next to the Spriter project file, and one in the anim folder. Use the anim folder one, the other one won't work Link to comment Share on other sites More sharing options...
Batmanwarrior Posted January 3, 2015 Author Share Posted January 3, 2015 @Batmanwarrior, the problem is most likely got to do with your animations. You'll also need to add a new line of code for it to show on the clients machine. inst:AddNetwork()Without that line no matter the amount of debugging you do it will not show up on the clients machine. Are you sure that's what you want? You said you went through Spriter, so you may have your own anim.bin to use instead of the cutstone anim. One thing that's also potentially confusing when compiling the Spriter project is that it will create one zip next to the Spriter project file, and one in the anim folder. Use the anim folder one, the other one won't work @Kzisor, @rezecibYou are both right, it was something with the animations. I was looking through some other codes to get an idea which animations I can use, and I tried with the cutstone as a last resort. This is what i changed: inst.AnimState:SetBank("theheart")inst.AnimState:SetBuild("monsterheart_build")inst.AnimState:PlayAnimation("monsterheart") Where "theheart" is the template in spriter, and "monsterheart" is the animation name in spriter. Now it works like intended and it also shows when i drop it, thank you very much!! However, is inst:AddNetwork() needed for other clients to see the item? I tried to insert this code into both modmain and monsterheart lua, but the game crashed both times. Where should addnetwork be inserted? Link to comment Share on other sites More sharing options...
Batmanwarrior Posted January 3, 2015 Author Share Posted January 3, 2015 Nevermind, I just figured it out! It should be inst.entity:AddNetwork(), and it's inserted within the function in the prefab.lua if anyone else is reading this topic in hope for some guidance. Thank you very much guys, I really appreciate it!Have a great day! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now