Jump to content

A Rocky Start, Stone Golem Character Mod Help Wanted


Recommended Posts

Hi everyone! I am very new to the modding thing. I am trying to make a character mod for Don't Starve Together. He's gonna be a Rock person. Following along with the tutorial on the Klei website, it all seems fairly straightforward. However, I've run into a little snag (being that I have no coding experience, and don't want to screw up my game) I need help with a few things.
Firstly, a slightly slower sanity drain, I set his sanity to 50, but i'd like it to drain a bit slower. Found someone else's thread to help here!
Spoiler

 

Secondly, how to make it so he can mine boulder and etc, with his fists.

Spoiler

 

Thirdly, how he can give off a warmth aura exactly like a thermal stone.
Fourthly, how to drain his sanity near pickaxes.
And lastly, how to make food non edible, but minerals edible for him.

Spoiler

 

Any help would be appreciated.

Edited by Grymlahv
Link to comment
Share on other sites

So, if I added this code (taken from the Rock lobster prefab rocky.lua) to my mod
inst:AddComponent("eater")
    inst.components.eater:SetDiet({ FOODTYPE.ELEMENTAL }, { FOODTYPE.ELEMENTAL })
Would that set him to only eat minerals? Or would that conflict with anything?
And would I need to go through and give values to every mineral for health, hunger, saniy and whatnot?

Link to comment
Share on other sites

So, by using the rock lobster code
inst.components.eater:SetDiet({ FOODTYPE.ELEMENTAL }, { FOODTYPE.ELEMENTAL })
it did make him able to eat rocks AND blacklisted everything else!
however I will need to go back through and change some values on the minerals as they don't give enough hunger to actually not starve

Link to comment
Share on other sites

I've looked at Ultroman's Tutorial Fun with Food, and I was able to change mineral values to actually work. But now my code doesn't want to play nice anymore. The code crashes with an out of memory error. Here's the code I added to my modmain (however, rereading I know it needs to go in my master_posinit)

Spoiler

local food_stat_dict = {
    flint = { health = 0, hunger = 15 },
    rocks = { health = 0, hunger = 5 },
    goldnugget = { hunger = 0 },
    nitre = { health = 5, hunger = 5 },
    moonrocknugget = { health = 0, sanity = 10, hunger = 5 },
    redgem = { health = 50, sanity = 0, hunger = 0 },
    orangegem = { health = 25, sanity = 0, hunger = 25 },
    yellowgem = { health = 0, sanity = 0, hunger = 50 },
    greengem = { health = 0, sanity = 25, hunger = 25 },
    bluegem = { health = 0, sanity = 50, hunger = 0 },
    purplegem = { health = 25, sanity = 25, hunger = 0 },
    opalgem = { health = 50, sanity = 50, hunger = 50 },
    thulecite = { health = 300, sanity = 50, hunger = 100 },
}


for food_prefab, food_stats in pairs(food_stat_dict) do
    AddPrefabPostInit(food_prefab, function(inst)
        inst.components.edible.healthvalue = food_stats["health"] or 0
        inst.components.edible.hungervalue = food_stats["hunger"] or 0
        inst.components.edible.sanityvalue = food_stats["sanity"] or 0
    end)
end

When I run this I get an error in my log file.

Spoiler

[00:01:55]: error calling PrefabPostInit: flint in mod Warden the Wall: 
[string "../mods/Warden the Wall/modmain.lua"]:91: attempt to index field 'edible' (a nil value)
LUA ERROR stack traceback:
        ../mods/Warden the Wall/modmain.lua(91,1)
        =(tail call) ?
        =[C] in function 'xpcall'
        scripts/mods.lua(162,1) in function 'mod'
        scripts/mainfunctions.lua(267,1)    

 

This doesn't make sense to me. because I've tested it with things I know have an edible component, like meat. Anyone know how to fix this?

Edited by Grymlahv
Link to comment
Share on other sites

On 7/2/2020 at 1:46 AM, Grymlahv said:

This doesn't make sense to me. because I've tested it with things I know have an edible component, like meat. Anyone know how to fix this?

Flint doesn't have an edible component. If you want inedible things to become edible, you have to add an edible component to it first and set it up. But then the thing will be edible for everyone on the server, so you have to handle that. I'm pretty sure you can search an answer up for that one. It might even be in the tutorial list or in Fun With Food. I can't remember.

Edited by Ultroman
  • Thanks 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...