TheRaptorAlpha Posted January 21, 2017 Share Posted January 21, 2017 So I have been working on my very first character mod! I'm quite excited to see the outcome and how the little guy works out in the workshop, but of course being so new to the programming process, I have come across a few bugs and tricks I honestly have no idea how to fix, and I could really use some help otherwise this week's worth of tiresome work would all be for nothing but an incomplete and buggy character. I've almost completely finished him (half-way through his dialogue and playing around with different instruments to see what might work for a voice, but it has been pretty tricky with the limited amount of people uploading instrument sounds playing random voice-like notes rather than tunes), and thought this would be a good time to ask for help so I can fix them as I'm wrapping this project up Thankfully from a very helpful tutorial, I've been able to figure out most of it myself, but let's discuss my character a little and the bugs he's having This is my character, here, a greedy little so-and-so with lower sanity and health, which balances out with a decreased hunger drain rate, who loves gold to the point he couldn't live without it Bugs that need to be fixed -All the sample templates displayed perfectly fine before I edited them, and even though I edited all in the same manor, some of them now don't display, such as the oval portrait and name title on the customization screen, which are completely invisible, and the preview icon of the mod that shows an empty square when I replaced such preview icon with my character in it. I find it weird that some icons displayed like they were supposed to and some didn't. I saved them all in the png files like they were originally -His ghost sprite is invisible. I've noticed others have had this problem in the past and it involved some form of coding (not sure if this was before character modding was made easier with the template or not) ?? I had no idea what they were talking about. Spriter previews show that his ghost sprite should be working and displaying fine, but it's not. This is a pretty major thing and I honestly don't have a clue on fixing it Possibly the most important thing of all isn't a bug at all, but more of a perk I want to install. The perk that makes him stand out from other characters. It is very unusual which is why there's no tutorials actually specifically telling you how that I know of lol, and I know it must involve entering a script of coding somewhere in his files, but I don't know what commands to give Unless he contains gold in his inventory, he will have a constant 5%/min sanity drop, or the same drain that you receive from dusk. I found it as an interesting perk, but I have no idea how to add it to his character, which disappoints me as I thought it would be a nice addition to match his personality If you could help me with any of these problems, I would love you to no end! Hey I might even draw you something if a reward makes you more interested c: Link to comment Share on other sites More sharing options...
Lumina Posted January 22, 2017 Share Posted January 22, 2017 So, first advice is : if you have problem with a mod, it's usually better to link the mod so others players could look at the code and fix things. For example, seeing why some anim doesn't show or why some image isn't displayed is usually a lot easier with the mod linked. For the perk, you want a drain of sanity if he doesn't have gold in inventory. I guess it's possible. I found this So there is a code provided, but in olds topics there are some king of strange formating, meaning you will maybe not be able to use exactly this code, but it's probably a good way to see what you need. I hope it can help. Link to comment Share on other sites More sharing options...
Ryuushu Posted January 22, 2017 Share Posted January 22, 2017 (edited) @TheRaptorAlpha For the sanity loss when not holding gold: Look at the edit. Spoiler assert(false, "Read post next time") inst.components.sanity.custom_rate_fn = function(inst) if inst.components.inventory then return not inst.components.inventory:Has("goldnugget",1) and TUNING.SANITY_NIGHT_LIGHT or 0 end end Goes into yourcharacter.lua master_postinit. As for the ghost, maybe you forgot to include the anim in your assets, or the spriter project doesn't matches your character's ghost build. Can you upload your mod here? EDIT: Upon reading the post linked by @Lumina I started to feel guilty for eating so many cycles every time sanity ticks, so I came up with the following: inst.hasgold = false inst:ListenForEvent("itemget", function(inst, data) if data.item and data.item.prefab == "goldnugget" then inst.hasgold = true end end) inst:ListenForEvent("itemlose", function(inst, data) if inst.hasgold then inst.hasgold = inst.components.inventory:Has("goldnugget",1) end end) inst.components.sanity.custom_rate_fn = function(inst) return not inst.hasgold and TUNING.SANITY_NIGHT_LIGHT or 0 end It should have the same effect, except this one doesn't scans the inventory every time sanity ticks. Edited January 22, 2017 by Ryuushu Link to comment Share on other sites More sharing options...
TheRaptorAlpha Posted January 23, 2017 Author Share Posted January 23, 2017 11 hours ago, Lumina said: So, first advice is : if you have problem with a mod, it's usually better to link the mod so others players could look at the code and fix things. For example, seeing why some anim doesn't show or why some image isn't displayed is usually a lot easier with the mod linked. For the perk, you want a drain of sanity if he doesn't have gold in inventory. I guess it's possible. I found this So there is a code provided, but in olds topics there are some king of strange formating, meaning you will maybe not be able to use exactly this code, but it's probably a good way to see what you need. I hope it can help. Oooo, I didn't think about giving the coding my apologies! Thank you so much for your help and I will give it here, let me know if I skipped anything ---modmain.lua--- PrefabFiles = { "wentworth", "wentworth_none", } Assets = { Asset( "IMAGE", "images/saveslot_portraits/wentworth.tex" ), Asset( "ATLAS", "images/saveslot_portraits/wentworth.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/wentworth.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/wentworth.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/wentworth_silho.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/wentworth_silho.xml" ), Asset( "IMAGE", "bigportraits/wentworth.tex" ), Asset( "ATLAS", "bigportraits/wentworth.xml" ), Asset( "IMAGE", "images/map_icons/wentworth.tex" ), Asset( "ATLAS", "images/map_icons/wentworth.xml" ), Asset( "IMAGE", "images/avatars/avatar_wentworth.tex" ), Asset( "ATLAS", "images/avatars/avatar_wentworth.xml" ), Asset( "IMAGE", "images/avatars/avatar_ghost_wentworth.tex" ), Asset( "ATLAS", "images/avatars/avatar_ghost_wentworth.xml" ), Asset( "IMAGE", "images/avatars/self_inspect_wentworth.tex" ), Asset( "ATLAS", "images/avatars/self_inspect_wentworth.xml" ), Asset( "IMAGE", "images/names_wentworth.tex" ), Asset( "ATLAS", "images/names_wentworth.xml" ), Asset( "IMAGE", "bigportraits/wentworth_none.tex" ), Asset( "ATLAS", "bigportraits/wentworth_none.xml" ), } local require = GLOBAL.require local STRINGS = GLOBAL.STRINGS -- The character select screen lines STRINGS.CHARACTER_TITLES.wentworth = "The Greedy" STRINGS.CHARACTER_NAMES.wentworth = "Wentworth" STRINGS.CHARACTER_DESCRIPTIONS.wentworth = "*Scrawny\n*Well fed\n*Needs gold for sanity" STRINGS.CHARACTER_QUOTES.wentworth = "\"Money can buy gold, and I think that's close enough!\"" -- Custom speech strings STRINGS.CHARACTERS.WENTWORTH = require "speech_wentworth" -- The character's name as appears in-game STRINGS.NAMES.wentworth = "Esc" AddMinimapAtlas("images/map_icons/wentworth.xml") -- Add mod character to mod character list. Also specify a gender. Possible genders are MALE, FEMALE, ROBOT, NEUTRAL, and PLURAL. AddModCharacter("wentworth", "MALE") ---wentworth.lua--- local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), } local prefabs = {} -- Custom starting items local start_inv = { } -- When the character is revived from human local function onbecamehuman(inst) -- Set speed when reviving from ghost (optional) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "wentworth_speed_mod", 1) end local function onbecameghost(inst) -- Remove speed modifier when becoming a ghost inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "wentworth_speed_mod") end -- When loading or spawning the character local function onload(inst) inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) end end -- This initializes for both the server and client. Tags can be added here. local common_postinit = function(inst) -- Minimap icon inst.MiniMapEntity:SetIcon( "wentworth.tex" ) end -- This initializes for the server only. Components are added here. local master_postinit = function(inst) -- choose which sounds this character will play inst.soundsname = "wickerbottom" -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used --inst.talker_path_override = "dontstarve_DLC001/characters/" -- Stats inst.components.health:SetMaxHealth(120) inst.components.hunger:SetMax(150) inst.components.sanity:SetMax(150) -- Damage multiplier (optional) inst.components.combat.damagemultiplier = .80 -- Hunger rate (optional) inst.components.hunger.hungerrate = 1.25 * TUNING.WILSON_HUNGER_RATE inst.OnLoad = onload inst.OnNewSpawn = onload end return MakePlayerCharacter("wentworth", prefabs, assets, common_postinit, master_postinit, start_inv) Or if it would be easier just to make a zip file with the entire mod, let me know! Link to comment Share on other sites More sharing options...
Ryuushu Posted January 23, 2017 Share Posted January 23, 2017 @TheRaptorAlpha It'd be much better if you could put your mod in a zip file. I also want to look at the spriter projects. Link to comment Share on other sites More sharing options...
TheRaptorAlpha Posted January 23, 2017 Author Share Posted January 23, 2017 24 minutes ago, Ryuushu said: @TheRaptorAlpha It'd be much better if you could put your mod in a zip file. I also want to look at the spriter projects. Understood! Here is the zip file: https://www.mediafire.com/?n45ctcc9seh812h Link to comment Share on other sites More sharing options...
TheRaptorAlpha Posted January 23, 2017 Author Share Posted January 23, 2017 6 hours ago, Ryuushu said: @TheRaptorAlpha For the sanity loss when not holding gold: Look at the edit. Reveal hidden contents assert(false, "Read post next time") inst.components.sanity.custom_rate_fn = function(inst) if inst.components.inventory then return not inst.components.inventory:Has("goldnugget",1) and TUNING.SANITY_NIGHT_LIGHT or 0 end end Goes into yourcharacter.lua master_postinit. As for the ghost, maybe you forgot to include the anim in your assets, or the spriter project doesn't matches your character's ghost build. Can you upload your mod here? EDIT: Upon reading the post linked by @Lumina I started to feel guilty for eating so many cycles every time sanity ticks, so I came up with the following: inst.hasgold = false inst:ListenForEvent("itemget", function(inst, data) if data.item and data.item.prefab == "goldnugget" then inst.hasgold = true end end) inst:ListenForEvent("itemlose", function(inst, data) if inst.hasgold then inst.hasgold = inst.components.inventory:Has("goldnugget",1) end end) inst.components.sanity.custom_rate_fn = function(inst) return not inst.hasgold and TUNING.SANITY_NIGHT_LIGHT or 0 end It should have the same effect, except this one doesn't scans the inventory every time sanity ticks. This works beautifully! I can't thank you enough. In a reply below I have given a link to my entire mod if you'd prefer to give your insight on what could be going wrong with the ghost or the images not displaying Is there anything you'd like in return? I have an art tablet and I'd be more than happy to doodle you something. I know it isn't much, but I'd love to repay you in the best way I can Link to comment Share on other sites More sharing options...
Ryuushu Posted January 23, 2017 Share Posted January 23, 2017 (edited) @TheRaptorAlpha Found the error. Your ghost's spriter project is still called ghost_esctemplate_build. Rename it to ghost_wentworth_build, run the game to let it compile and it should produce the right build zip. Edited January 23, 2017 by Ryuushu Link to comment Share on other sites More sharing options...
TheRaptorAlpha Posted January 23, 2017 Author Share Posted January 23, 2017 4 hours ago, Ryuushu said: @TheRaptorAlpha Found the error. Your ghost's spriter project is still called ghost_esctemplate_build. Rename it to ghost_wentworth_build, run the game to let it compile and it should produce the right build zip. Ah! It was that simple, silly me. Thank you for all your help! 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