Crestonia Posted January 19, 2015 Share Posted January 19, 2015 I'm making another new character and was wondering how to make her level up (+sanity,+HP+Hunger) by eating petals. Link to comment https://forums.kleientertainment.com/forums/topic/49404-how-to-make-a-character-level-up/ Share on other sites More sharing options...
Ryuushu Posted January 19, 2015 Share Posted January 19, 2015 @CrestoniaCheck out wx78's prefab. (...Steam\steamapps\common\Don't Starve Together Beta\data\scripts\prefabs\wx78.lua)To detect if the eaten food is petals you can do something like this:local function oneat(inst, food) if food and food.prefab == "petals" then inst.level = inst.level + 1 applyupgrades(inst) endend Link to comment https://forums.kleientertainment.com/forums/topic/49404-how-to-make-a-character-level-up/#findComment-603824 Share on other sites More sharing options...
Crestonia Posted January 19, 2015 Author Share Posted January 19, 2015 @Ryuushu How do I adjust how much the character gains every level and where do I put in in the prefab folder? Link to comment https://forums.kleientertainment.com/forums/topic/49404-how-to-make-a-character-level-up/#findComment-603832 Share on other sites More sharing options...
Crestonia Posted January 20, 2015 Author Share Posted January 20, 2015 Any one else have any suggestions? I can't figure it out... Link to comment https://forums.kleientertainment.com/forums/topic/49404-how-to-make-a-character-level-up/#findComment-604194 Share on other sites More sharing options...
SenL Posted January 20, 2015 Share Posted January 20, 2015 There are plenty of character mods in the workshop."Haruz" is one that I've studied. Download (subscribe) and look at how the creator did it. Link to comment https://forums.kleientertainment.com/forums/topic/49404-how-to-make-a-character-level-up/#findComment-604200 Share on other sites More sharing options...
Crestonia Posted January 20, 2015 Author Share Posted January 20, 2015 @SenL I downloaded Faroz and tried to look at hers a little while ago...I tried pasting the code into my character, the game did not crash, but it did not work either...e.e Link to comment https://forums.kleientertainment.com/forums/topic/49404-how-to-make-a-character-level-up/#findComment-604201 Share on other sites More sharing options...
SenL Posted January 20, 2015 Share Posted January 20, 2015 Maybe post your prefab and we'll take a look? Link to comment https://forums.kleientertainment.com/forums/topic/49404-how-to-make-a-character-level-up/#findComment-604202 Share on other sites More sharing options...
Crestonia Posted January 20, 2015 Author Share Posted January 20, 2015 (edited) @SenLNvm it does crash. e.eHere is the prefablocal assets = { Asset( "ANIM", "anim/player_basic.zip" ), Asset( "ANIM", "anim/player_idles_shiver.zip" ), Asset( "ANIM", "anim/player_actions.zip" ), Asset( "ANIM", "anim/player_actions_axe.zip" ), Asset( "ANIM", "anim/player_actions_pickaxe.zip" ), Asset( "ANIM", "anim/player_actions_shovel.zip" ), Asset( "ANIM", "anim/player_actions_blowdart.zip" ), Asset( "ANIM", "anim/player_actions_eat.zip" ), Asset( "ANIM", "anim/player_actions_item.zip" ), Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ), Asset( "ANIM", "anim/player_actions_bugnet.zip" ), Asset( "ANIM", "anim/player_actions_fishing.zip" ), Asset( "ANIM", "anim/player_actions_boomerang.zip" ), Asset( "ANIM", "anim/player_bush_hat.zip" ), Asset( "ANIM", "anim/player_attacks.zip" ), Asset( "ANIM", "anim/player_idles.zip" ), Asset( "ANIM", "anim/player_rebirth.zip" ), Asset( "ANIM", "anim/player_jump.zip" ), Asset( "ANIM", "anim/player_amulet_resurrect.zip" ), Asset( "ANIM", "anim/player_teleport.zip" ), Asset( "ANIM", "anim/wilson_fx.zip" ), Asset( "ANIM", "anim/player_one_man_band.zip" ), Asset( "ANIM", "anim/shadow_hands.zip" ), Asset( "SOUND", "sound/sfx.fsb" ), Asset( "SOUND", "sound/wilson.fsb" ), Asset( "ANIM", "anim/beard.zip" ), Asset( "ANIM", "anim/esctemplate.zip" ), Asset( "ANIM", "anim/ghost_esctemplate_build.zip" ),}local prefabs = {}local start_inv = {-- Custom starting items}local function applyupgrades(inst) local max_upgrades = 30local upgrades = math.min(inst.level, max_upgrades) local hunger_percent = inst.components.hunger:GetPercent()local health_percent = inst.components.health:GetPercent()local sanity_percent = inst.components.sanity:GetPercent() inst.components.hunger.max = math.ceil (70 + upgrades * 1) --100inst.components.health.maxhealth = math.ceil (70 + upgrades * 1) --100inst.components.sanity.max = math.ceil (70 + upgrades * 3) --160 inst.components.talker:Say("Level : ".. (inst.level)) if inst.level >29 theninst.components.talker:Say("Level : Max!")end inst.components.hunger:SetPercent(hunger_percent)inst.components.health:SetPercent(health_percent)inst.components.sanity:SetPercent(sanity_percent) end local function oneat(inst, food) --if food and food.components.edible and food.components.edible.foodtype == "HELLO" thenif food and food.components.edible and food.prefab == "corn" or food.prefab == "carrot" then--give an upgrade!inst.level = inst.level + 1applyupgrades(inst) inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") end-- This initializes for both clients and the hostlocal common_postinit = function(inst) -- Minimap iconinst.MiniMapEntity:SetIcon( "esctemplate.tex" )end -- This initializes for the host onlylocal master_postinit = function(inst)-- choose which sounds this character will playinst.soundsname = "willow"-- Stats inst.components.health:SetMaxHealth(70)inst.components.hunger:SetMax(70)inst.components.sanity:SetMax(70)end return MakePlayerCharacter("esctemplate", prefabs, assets, common_postinit, master_postinit, start_inv) Edited January 20, 2015 by Crestonia Link to comment https://forums.kleientertainment.com/forums/topic/49404-how-to-make-a-character-level-up/#findComment-604211 Share on other sites More sharing options...
SenL Posted January 21, 2015 Share Posted January 21, 2015 It seems that you are missing onpreload and onsave functions which should be called from master_postinit Link to comment https://forums.kleientertainment.com/forums/topic/49404-how-to-make-a-character-level-up/#findComment-604306 Share on other sites More sharing options...
Crestonia Posted January 21, 2015 Author Share Posted January 21, 2015 (edited) @SenL Thanks I'll try to fix it. Edited January 21, 2015 by Crestonia Link to comment https://forums.kleientertainment.com/forums/topic/49404-how-to-make-a-character-level-up/#findComment-604415 Share on other sites More sharing options...
Crestonia Posted January 22, 2015 Author Share Posted January 22, 2015 @SenL do you know how to set the food that my character eats to level up? I got haruz's script and got it to work, and then I changed "MEAT" to "petals" and my game crashed. Link to comment https://forums.kleientertainment.com/forums/topic/49404-how-to-make-a-character-level-up/#findComment-604640 Share on other sites More sharing options...
SenL Posted January 22, 2015 Share Posted January 22, 2015 That's because there is no foodtype of "PETALS"If you open petals.lua (inside SteamApps\common\Don't Starve Together Beta\data\scripts\prefabs\) you'll see that petals is foodtype of "VEGGIE"So you could set it to foodtype="VEGGIE" or you could do below (inside mycharacter.lua)local function oneat(inst, food) if food and food.components.edible then if food.prefab == "petals" then inst.level = inst.level + 1 applyupgrades(inst) elseif food.prefab == "mandrake" then inst.level = inst.level + 10 applyupgrades(inst) end endendI don't know how to get full list of foodtypes (anyone help?) Link to comment https://forums.kleientertainment.com/forums/topic/49404-how-to-make-a-character-level-up/#findComment-604696 Share on other sites More sharing options...
Crestonia Posted January 22, 2015 Author Share Posted January 22, 2015 @SenLThank you very much! Link to comment https://forums.kleientertainment.com/forums/topic/49404-how-to-make-a-character-level-up/#findComment-604719 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