Jump to content

Help! HOW make a gardener character?


Recommended Posts

Hi, I'm a beginner of mode maker, First of all, I apologize for my poor English.

 

I'm making a gardener character of one game. he is human and love plant and flower

so I wanna give ability of farming work.

about here

1. Restores sanity when planting.

2. Can talk to crops without any tools

3. Can farming without any tools

4. Can check to crops feeling without any tools

 

It's similar to wormwood, right? so, I have pasted from wormwood code to my code

local WATCH_WORLD_PLANTS_DIST_SQ = 20 * 20
local SANITY_DRAIN_TIME = 5

local function SanityRateFn(inst, dt)
    local amt = 0
    for i = #inst.plantbonuses, 1, -1 do
        local v = inst.plantbonuses[i]
        if v.t > dt then
            v.t = v.t - dt
        else
            table.remove(inst.plantbonuses, i)
        end
        amt = amt + v.amt
    end
 return amt
end

local function DoPlantBonus(inst, bonus, overtime)
    if overtime then
        table.insert(inst.plantbonuses, { amt = bonus / SANITY_DRAIN_TIME, t = SANITY_DRAIN_TIME })
    else
        while #inst.plantpenalties > 0 do
            table.remove(inst.plantpenalties)
        end
        inst.components.sanity:DoDelta(bonus)
        inst.components.talker:Say(GetString(inst, "ANNOUNCE_GROWPLANT"))
    end
end

local function CalcSanityMult(distsq)
    distsq = 1 - math.sqrt(distsq / WATCH_WORLD_PLANTS_DIST_SQ)
    return distsq * distsq
end

local function WatchWorldPlants(inst)
    if inst._onitemplanted == nil then
        inst._onitemplanted = function(src, data)
            if data == nil then
                --shouldn't happen
            elseif data.doer == inst then
                DoPlantBonus(inst, TUNING.SANITY_TINY * 2)
            elseif data.pos ~= nil then
                local distsq = inst:GetDistanceSqToPoint(data.pos)
                if distsq < WATCH_WORLD_PLANTS_DIST_SQ then
                    DoPlantBonus(inst, CalcSanityMult(distsq) * TUNING.SANITY_SUPERTINY * 2, true)
                end
            end
        end
        inst:ListenForEvent("itemplanted", inst._onitemplanted, TheWorld)
    end
   end
   
  local function StopWatchingWorldPlants(inst)
    if inst._onitemplanted ~= nil then
        inst:RemoveEventCallback("itemplanted", inst._onitemplanted, TheWorld)
        inst._onitemplanted = nil
    end
  end

But, it doesn't work!!!

 

So I'd like to ask for your help by attaching my code screenshot.

Where, how, and what should I put in? X( Help me!! plz...

image (1).png

image.png

Link to comment
Share on other sites

On 7/29/2021 at 8:18 PM, ARINGARING1234 said:

1. Restores sanity when planting.

2. Can talk to crops without any tools

3. Can farming without any tools

4. Can check to crops feeling without any tools

1. Yeah that's a wormwood perk

2. look into the Gardeneer Hat and see how that works

3. you mean be able to plant seeds without using a Garden Digamajig?

4. look at number 2

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...