MegaNerdX Posted April 10, 2019 Share Posted April 10, 2019 Hi there! So i wanted to make a character that can gain stats like WX-78 but instead of eating gears, they eat nightmare fuel. So i tried using WX's code but instead of local function oneat(inst, food) if food and food.components.edible and food.components.edible.foodtype == FOODTYPE.GEARS then inst.level = inst.level + 1 applyupgrades(inst) inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") i put local function oneat(inst, food) if food and food.components.edible and food.components.edible.foodtype == FOODTYPE.NIGHTMAREFUEL then inst.level = inst.level + 1 applyupgrades(inst) inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") I opened the game up and i didn't get a crash but it just didn't let me eat nightmare fuel or gears. I also put in the tuning stats code from WX's files local function applyupgrades(inst) local max_upgrades = 15 inst.level = 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(TUNING.WX78_MIN_HUNGER + inst.level * (TUNING.WX78_MAX_HUNGER - TUNING.WX78_MIN_HUNGER) / max_upgrades) inst.components.health.maxhealth = math.ceil(TUNING.WX78_MIN_HEALTH + inst.level * (TUNING.WX78_MAX_HEALTH - TUNING.WX78_MIN_HEALTH) / max_upgrades) inst.components.sanity.max = math.ceil(TUNING.WX78_MIN_SANITY + inst.level * (TUNING.WX78_MAX_SANITY - TUNING.WX78_MIN_SANITY) / max_upgrades) inst.components.hunger:SetPercent(hunger_percent) inst.components.health:SetPercent(health_percent) local ignoresanity = inst.components.sanity.ignore inst.components.sanity.ignore = false inst.components.sanity:SetPercent(sanity_percent) inst.components.sanity.ignore = ignoresanity end I am a novice mod maker so I knew it wouldn't work. Can you guys help me? Link to comment Share on other sites More sharing options...
Hornete Posted April 10, 2019 Share Posted April 10, 2019 Well of course you need to add an edible component to the nightmarefuel prefab Quote inst:AddComponent("edible") inst.components.edible.foodtype = FOODTYPE.GEARS --Change this into FOODTYPE.NIGHTMAREFUEL inst.components.edible.healthvalue = TUNING.HEALING_HUGE -- Do whatever you wish with these 3 inst.components.edible.hungervalue = TUNING.CALORIES_HUGE inst.components.edible.sanityvalue = TUNING.SANITY_HUGE Link to comment Share on other sites More sharing options...
MegaNerdX Posted April 10, 2019 Author Share Posted April 10, 2019 THANK YOU!!! Link to comment Share on other sites More sharing options...
MegaNerdX Posted April 11, 2019 Author Share Posted April 11, 2019 16 hours ago, Omaremad74 said: Well of course you need to add an edible component to the nightmarefuel prefab wait the code doesn't work, where do i add this? Link to comment Share on other sites More sharing options...
Hornete Posted April 11, 2019 Share Posted April 11, 2019 Quote AddPrefabPostInit("nightmarefuel", function(inst) inst:AddComponent("edible") inst.components.edible.foodtype = FOODTYPE.GEARS --Change this into FOODTYPE.NIGHTMAREFUEL inst.components.edible.healthvalue = TUNING.HEALING_HUGE -- Do whatever you wish with these 3 inst.components.edible.hungervalue = TUNING.CALORIES_HUGE inst.components.edible.sanityvalue = TUNING.SANITY_HUGE end) Something like that. Link to comment Share on other sites More sharing options...
MegaNerdX Posted April 11, 2019 Author Share Posted April 11, 2019 (edited) but where? also the code crashes my game Edited April 11, 2019 by Massimell Link to comment Share on other sites More sharing options...
Well-met Posted April 11, 2019 Share Posted April 11, 2019 1 hour ago, Massimell said: but where? also the code crashes my game Omaremad74's block goes into your character's modmain.lua Link to comment Share on other sites More sharing options...
Well-met Posted April 18, 2019 Share Posted April 18, 2019 How would this be doable for an item that already has an edible component? Say, eating a moonrock. It's already "edible" for rock lobsters but obviously not for players. Link to comment Share on other sites More sharing options...
MidrealmDM Posted May 23, 2019 Share Posted May 23, 2019 On 4/18/2019 at 6:37 PM, Hell-met said: How would this be doable for an item that already has an edible component? Say, eating a moonrock. It's already "edible" for rock lobsters but obviously not for players. Change the characters diet to include rocks... not sure what diet that would be but rocklobstars or moleworms probably have it. Link to comment Share on other sites More sharing options...
Well-met Posted May 23, 2019 Share Posted May 23, 2019 7 minutes ago, MidrealmDM said: Change the characters diet to include rocks... not sure what diet that would be but rocklobstars or moleworms probably have it. thanks but I've figured it out. It's been more than a month after all. Link to comment Share on other sites More sharing options...
MidrealmDM Posted May 24, 2019 Share Posted May 24, 2019 Oh, sorry... the issue was not marked as resolved. 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