lukasek Posted October 3, 2017 Share Posted October 3, 2017 Hello there everyone... I'm trying to make a character mod for DS, and DSSW, with abilitie to kevek up by reading books... I got most of it done, but i cant figure out how to write script that would allow my character to level up by reading a specific book. I'm basing my script on wx78 character, and everything works fine when i used original (gear eating) abilitie... But i just cant find a proper combination of functions to make exchange gear eating abilitie/specific food type (gears) to book reading abilitie and reading a book XYZ to work properly... Does someone got an idea, what should i put in? -ill only mention that this is my first attempt on modding DS. regards, lucas Link to comment https://forums.kleientertainment.com/forums/topic/82629-adding-abilitie-leveling-up-by-reading-books/ Share on other sites More sharing options...
Parusoid Posted October 6, 2017 Share Posted October 6, 2017 If you are using 'book' component then you could use 'OnRead' function as the trigger to levelup Link to comment https://forums.kleientertainment.com/forums/topic/82629-adding-abilitie-leveling-up-by-reading-books/#findComment-961309 Share on other sites More sharing options...
lukasek Posted October 6, 2017 Author Share Posted October 6, 2017 Parusoid thanks for responding... Yes i get that. thats exactly what i was trying to do... its putting it itno words... im good at understanding code, and coping and pasteing lines of code, and tweeking values... but writhing my own lines of the code is more tricky and i usually make mistakes which crashes my game... Could you write an actual line of code that i should put in my lua file... ill take care of the rest... Thanks in advance Link to comment https://forums.kleientertainment.com/forums/topic/82629-adding-abilitie-leveling-up-by-reading-books/#findComment-961395 Share on other sites More sharing options...
Parusoid Posted October 6, 2017 Share Posted October 6, 2017 It would be easier if you post here what have you already managed to write. post the part of code you have issues with Link to comment https://forums.kleientertainment.com/forums/topic/82629-adding-abilitie-leveling-up-by-reading-books/#findComment-961594 Share on other sites More sharing options...
lukasek Posted October 7, 2017 Author Share Posted October 7, 2017 (edited) As I mentioned, im using wx78 oneat script. bold lines are the ones needed to be changed. I get that all of gear eating stuff from leveling up paragraph will be removed, since i already have a reader abilitie on. now you mentioned i need to change oneat function to onread so it'll probably look like this Quote local function onread (inst, book) and what then? if book and inst.components.book == "survivalguide" then ?? because i recall putting something like that in, and it resulted with game crashing when i was turning the mod on... local function oneat(inst, food) if food and food.components.edible and food.components.edible.foodtype == "GEARS" then --give an upgrade! inst.level = inst.level + 1 applyupgrades(inst) inst.SoundEmitter:PlaySound("dontstarve/HUD/get_gold") inst.HUD.controls.status.heart:PulseGreen() inst.HUD.controls.status.stomach:PulseGreen() inst.HUD.controls.status.brain:PulseGreen() inst.HUD.controls.status.brain:ScaleTo(1.3,1,.7) inst.HUD.controls.status.heart:ScaleTo(1.3,1,.7) inst.HUD.controls.status.stomach:ScaleTo(1.3,1,.7) end end local function onpreload(inst, data) if data then if data.level then inst.level = data.level applyupgrades(inst) --re-set these from the save data, because of load-order clipping issues if data.health and data.health.health then inst.components.health.currenthealth = data.health.health end if data.hunger and data.hunger.hunger then inst.components.hunger.current = data.hunger.hunger end if data.sanity and data.sanity.current then inst.components.sanity.current = data.sanity.current end inst.components.health:DoDelta(0) inst.components.hunger:DoDelta(0) inst.components.sanity:DoDelta(0) end end end local function onsave(inst, data) data.level = inst.level end local fn = function(inst) -- BASIC STUFF -- inst.level = 0 inst.soundsname = "woodie" inst.MiniMapEntity:SetIcon( "woodie.png" ) -- LEVELING UP ABILITIE -- table.insert(inst.components.eater.foodprefs, "GEARS") table.insert(inst.components.eater.ablefoods, "GEARS") inst.components.eater:SetOnEatFn(oneat) applyupgrades(inst) inst.OnSave = onsave inst.OnPreLoad = onpreload -- SURVIVAL GUIDE CRAFTING -- inst:AddComponent("reader") local booktab = {str = STRINGS.TABS.BOOKS, sort=999, icon = "tab_book.tex"} inst.components.builder:AddRecipeTab(booktab) Recipe("survivalguide", {Ingredient("twigs", 1)}, booktab, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0}) Edited October 7, 2017 by lukasek Link to comment https://forums.kleientertainment.com/forums/topic/82629-adding-abilitie-leveling-up-by-reading-books/#findComment-961778 Share on other sites More sharing options...
Parusoid Posted October 7, 2017 Share Posted October 7, 2017 (edited) So reading your book has another effect tha leveling i assume, right? And the effect are in the "onread" section. So add your leveling code there. If you are using the same effect for leveling up as wx does, then just replace local function oneat(inst, food) if food and food.components.edible and food.components.edible.foodtype == "GEARS" then with local function onread (inst, book) You dont need to put "if book and inst.components.book == "survivalguide" then" Edited October 7, 2017 by Parusoid Link to comment https://forums.kleientertainment.com/forums/topic/82629-adding-abilitie-leveling-up-by-reading-books/#findComment-961844 Share on other sites More sharing options...
lukasek Posted October 8, 2017 Author Share Posted October 8, 2017 (edited) No... my book has no effect, i was planning to do that (so books had different effects, and just crafting book gives an upgrade), but now im just trying to make this work with just reading... Quote local function oneat(inst, food) if food and food.components.edible and food.components.edible.foodtype == "GEARS" then with local function onread (inst, book) You dont need to put "if book and inst.components.book == "survivalguide" then" but if i do that, wont it give me an upgrade with any other book read? I would like to make this item specific, and perhaps allow my character to make different books later on that wont rise my level... (mostly because leveling up causes a hell of a difference with this character and rises every single statistic, damage multipliers, speed multipliers, resistance (cold, fire, sanity, etc.) gives additional abilities... and its supposed to be difficult to actually write those survivalguides... PS. I tried to change just that line you suggest... unfortunately its not enough code to make it work... mod crashes on start... Edited October 8, 2017 by lukasek Link to comment https://forums.kleientertainment.com/forums/topic/82629-adding-abilitie-leveling-up-by-reading-books/#findComment-961992 Share on other sites More sharing options...
Parusoid Posted October 8, 2017 Share Posted October 8, 2017 12 hours ago, lukasek said: I tried to change just that line you suggest... unfortunately its not enough code to make it work... mod crashes on start... What does the error log say? C:\Users\username\Documents\Klei\DoNotStarve\log.txt Link to comment https://forums.kleientertainment.com/forums/topic/82629-adding-abilitie-leveling-up-by-reading-books/#findComment-962173 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