Franke004 Posted September 10, 2017 Author Share Posted September 10, 2017 Thanks ! will do ! Link to comment Share on other sites More sharing options...
Franke004 Posted September 10, 2017 Author Share Posted September 10, 2017 27 minutes ago, pickleplayer said: Hm, then it sounds like somewhere along the line, nightmare fuel has stopped giving him power ups? applyupgrades() will actually run just by logging in too, which is why he randomly says it when joining. (if you're using notepad++, you can highlight the word "applyupgrades" and scroll through the file and see all the other places it's called from) So maybe something you changed recently broke his ability to eat it. You can test how far the code gets by throwing in some random prints like print("test1") somewhere into oneat() and applyupgrades(). Press Ctrl-L and then eat a nightmare fuel and see which print messages show up. Wherever the print messages stop is wherever the problem is When i press Ctrl-L in game and then i eat nightmare fuel it doesnt like do anything , that text stays there and does not change , but i put in ''test1'''and it showed up there Link to comment Share on other sites More sharing options...
pickleplayer Posted September 10, 2017 Share Posted September 10, 2017 Where did you put it? If its somewhere in oneat(), like under "--give an upgrade" then if you see it, we know that he's still eating it properly and it's still recognized as a food. If you put a second one like print("test2") in the local function applyupgrades() somewhere, then if you see it, you know that that part of the code is being run too. But having the speech there for him to say "i am stronger" is just as good as a having print function, so you can just watch to see if he says it instead. Does he still say it when you eat it? If not, the problem must be somewhere between oneat() and the line where the speech text happens. Link to comment Share on other sites More sharing options...
Franke004 Posted September 10, 2017 Author Share Posted September 10, 2017 local master_postinit = function(inst) inst.level = 0 inst.soundsname = "maxwell" inst.components.eater:SetOnEatFn(oneat) applyupgrades(inst) print("test1") Here , no it does not say anything Link to comment Share on other sites More sharing options...
pickleplayer Posted September 10, 2017 Share Posted September 10, 2017 oh, sorry, I should have been more specific. when I said put the print lines somewhere in them, I meant inside the actual functions. like line 44 inside oneat() and something like line 20 in applyupgrades() like this local function oneat(inst, food) if food and food.components.edible and food.components.edible.foodtype == FOODTYPE.NIGHTMAREFUEL then --give an upgrade! inst.level = inst.level + 1 applyupgrades(inst) print("test1") --ANYWHERE INSIDE IT WILL WORK. LIKE THIS. JUST SO WE KNOW IF THIS PART OF THE CODE EVER GETS RUN OR NOT inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") end end And so if he doesn't say anything, then we know applyupgrades() (lines 20-39) never ran. If it did, he would have talked. So put that print test in oneat like I did up there and then eat a nightmare fuel. If test1 doesn't show up, then the nightmare fuel somehow isnt being eaten properly and something with the foodtype might be off. Link to comment Share on other sites More sharing options...
Franke004 Posted September 10, 2017 Author Share Posted September 10, 2017 ok thank you! i will try it in about 50-60 min , i took a break a lil Link to comment Share on other sites More sharing options...
Franke004 Posted September 10, 2017 Author Share Posted September 10, 2017 well idk , code: local function oneat(inst, food) if food and food.components.edible and food.components.edible.foodtype == FOODTYPE.NIGHTMAREFUEL then --give an upgrade! inst.level = inst.level + 1 applyupgrades(inst) print("test1") inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") end end and you have the pic below after i ate 1 , nothing happend... again Link to comment Share on other sites More sharing options...
Franke004 Posted September 10, 2017 Author Share Posted September 10, 2017 (edited) Ok i did it , wubdub2 and wubdub1 dont show up , so it means it does not load ? you have everything down there , a screenshot and the lua of the char... i dont have any ideas on what to do hiroki.lua Edited September 10, 2017 by Franke004 Link to comment Share on other sites More sharing options...
pickleplayer Posted September 10, 2017 Share Posted September 10, 2017 ok, So that means something is happening where he is not eating it correctly. If we look at the if-statement required for him to eat it, it needs to be edible, and its foodtype needs to = nightmarefuel or whatever that means. This will get into some more advanced troubleshooting with even more print lines. make an extra line after line 43 and put this in there and then eat a nightmare fuel print("FOOD TEST", food.components.edible, food.components.edible.foodtype == FOODTYPE.NIGHTMAREFUEL, food.components.edible.foodtype, FOODTYPE.NIGHTMAREFUEL) This will print 4 things (all at once and right next to each other with no spaces) 1. If the food is edible or not (should be true), 2.If the foodtype is the nightmarefuel food type (should be true). If either of those first two things is false, then we will know why it failed. And just for good measure, the last two things it prints are "3.the foodtype of whatever he just ate" and "4.the foodtype of nightmare fuel that you set in modmain" 3 and 4 need to be the same thing. If not, we need to make them the same thing. speaking of which.... what foodtype did you set nightmare fuel to? I'm suddenly realizing this is actually probably something wrong in the modmain.lua, not hiroki.lua. The 4th print line thing should say what it's set to. And if nothing comes out for the 4th one, it probably wasn't set Link to comment Share on other sites More sharing options...
Franke004 Posted September 10, 2017 Author Share Posted September 10, 2017 Well imma send you the modmain.lua , idk , i tried my best ;-; modmain.lua Link to comment Share on other sites More sharing options...
pickleplayer Posted September 10, 2017 Share Posted September 10, 2017 ah, it might be because it's foodtype isn't set. or heck just forget all that, I just realized we probably don't even need to set any of these food type stuff. Just replace line 44 of the character's file with if food and food.prefab == "nightmarefuel" then Link to comment Share on other sites More sharing options...
Franke004 Posted September 10, 2017 Author Share Posted September 10, 2017 so i just remove the stuff in modmain.lua ? Link to comment Share on other sites More sharing options...
Franke004 Posted September 10, 2017 Author Share Posted September 10, 2017 local function oneat(inst, food) if food and food.prefab == "nightmarefuel" then --give an upgrade! inst.level = inst.level + 1 applyupgrades(inst) print("wubdub1") inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") end end like this ? Link to comment Share on other sites More sharing options...
Franke004 Posted September 10, 2017 Author Share Posted September 10, 2017 well removed the stuff from the modmain and now its not edible Link to comment Share on other sites More sharing options...
alainmcd Posted September 10, 2017 Share Posted September 10, 2017 You didn't add inst.components.edible.foodtype = GLOBAL.FOODTYPE.NIGHTMAREFUEL to the nightmare fuel's AddPrefabPostInit in your modmain.lua. Link to comment Share on other sites More sharing options...
Franke004 Posted September 10, 2017 Author Share Posted September 10, 2017 When i did it crashed on me Link to comment Share on other sites More sharing options...
Franke004 Posted September 10, 2017 Author Share Posted September 10, 2017 welp added it , doesnt crash but cant eat the nightmare fuel Link to comment Share on other sites More sharing options...
Franke004 Posted September 10, 2017 Author Share Posted September 10, 2017 so what should i do with this mod , cause its just not working , im trying my best ... this is hard.... Link to comment Share on other sites More sharing options...
pickleplayer Posted September 10, 2017 Share Posted September 10, 2017 No no, leave the stuff you already had for the nightmare fuel in the modmain. It still has to be edible (otherwise he wont even try and eat it) And replace that line with the one I mentioned, (if food and food.prefab == "nightmarefuel" then) so it will look like this. local function oneat(inst, food) if food and food.prefab == "nightmarefuel" then --give an upgrade! inst.level = inst.level + 1 applyupgrades(inst) inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") end end So you can leave all that FOODTYPE.NIGHTMAREFUEL stuff out of it. I don't work with food items much so I don't know much about it, but you won't need it. Just leave this in the modmain. AddPrefabPostInit("nightmarefuel",function(inst) inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.sanityvalue = -15 inst.components.edible.hungervalue = 0 end) And then try it. I'm confident this will work. Link to comment Share on other sites More sharing options...
alainmcd Posted September 10, 2017 Share Posted September 10, 2017 I'm sure it doesn't help if we're giving different instructions. Either way should work. Using the FOODGROUP and FOODTYPE would be a better option if you think you might use other items as food later on (since you'd simply assign the FOODTYPE to the new item instead of changing your character file directly). Other than that, I don't think it makes any difference. -- It seems to me you're copying templates and code snippets without fully understanding what they do. Take a deep look at your mod. Try to understand what every single line of your code does. Feel free to ask if anything isn't clear. Asking is fine and a great way to learn, but you'll be more proficient if you know your code and you'll be able to fix any issue quicker if you understand why any given piece of code is there. Link to comment Share on other sites More sharing options...
Franke004 Posted September 10, 2017 Author Share Posted September 10, 2017 Thanks a lot alain ! pickleplayer made it work ! and you helped me aswell , ! im gonna credit you when im gonna post the mod Link to comment Share on other sites More sharing options...
pickleplayer Posted September 10, 2017 Share Posted September 10, 2017 1 hour ago, alainmcd said: I'm sure it doesn't help if we're giving different instructions. Either way should work. Using the FOODGROUP and FOODTYPE would be a better option if you think you might use other items as food later on (since you'd simply assign the FOODTYPE to the new item instead of changing your character file directly). Other than that, I don't think it makes any difference. Woops, I didn't mean to throw it off, my bad for not paying attention. I just thought this one would be easier to understand. Yea, in the longrun, learning to understand the code first is the most efficient way to get better. But learning such large chunks of code for a food system like that in one go is a very difficult task for someone with very little coding experience. I was like that too, and I also learned to mod by just Frankenstein-ing bits and pieces of code from other parts of the game into the mod, and I learned how they worked by just messing with it and trial and error and being forced to tweak them to fit into place. Link to comment Share on other sites More sharing options...
alainmcd Posted September 10, 2017 Share Posted September 10, 2017 No problem, we're all here to learn and to contribute with what we know. And I fully agree, it's definitely not necessary to invest a lot of time learning how the game works for simple mods or first efforts. My only nitpick on the matter is with character mods in particular, since it's common for new modders to try and add too much and underestimate the difficulty and scope of their projects. But I think we're on the same page. 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