Jump to content

Recommended Posts

I'm making my own like worse version of a meat effigy that's character specific, the character works and all that, I have another recipe that does work, but that's an item.
So here's the symptoms:
1. Without this code:

{
        placer = "slime_bulb_placer",
        min_spacing = 2,
        atlas = "images/inventoryimages/slime_bulb.xml",
        image = "slime_bulb.tex"
    }

It shows up in the crafting menu, under the character tab, but with that code, it doesn't.
2. When removing that code (so it shows up in crafting), the player just does the "busy" animation for a normal amount of time and goes "I can't do that" or whatever the fallback quote is, as if they're trying to craft and item.
3. I can't spawn it in with commands (It isn't listed in c_spawn(""))

Btw if anyone looks through the code and finds some other issues feel free to let me know
(Like the code for Glommer's Goop or Royal Jelly as an ingredient for jelly beans.)

modmain.lua slime_bulb.lua

20 minutes ago, NotLuzeria said:

It now appears in the crafting menu (great!) But, it still can't be spawned with commands, and so it also crashes the game trying to craft it...

The prefab needs to be added to the PrefabFiles at the top of your modmain too. The "resurrector" component also doesn't exist, unless that's a custom component you've made.

6 hours ago, Merkyrrie said:

The prefab needs to be added to the PrefabFiles at the top of your modmain too.

Ah. I can't believe I missed that...
 

6 hours ago, Merkyrrie said:

The "resurrector" component also doesn't exist, unless that's a custom component you've made.

How do I make it so the structure can be used to respawn (like a meat effigy) then?

8 minutes ago, NotLuzeria said:

How do I make it so the structure can be used to respawn (like a meat effigy) then?

You can look at the meat effigy's prefab, 'resurrectionstatue', to see how it does it. It uses the "attunable" component with these lines in its prefab fn:

inst:AddTag("resurrector")    
----------------------------
inst:AddComponent("attunable")
inst.components.attunable:SetAttunableTag("remoteresurrector")
inst.components.attunable:SetOnAttuneCostFn(onattunecost)
inst.components.attunable:SetOnLinkFn(onlink)
inst.components.attunable:SetOnUnlinkFn(onunlink)

inst:ListenForEvent("activateresurrection", inst.Remove)

and these functions

local function onattunecost(inst, player)
    --round up health to match UI display
    local amount_required = player:HasTag("health_as_oldage") and math.ceil(TUNING.EFFIGY_HEALTH_PENALTY * TUNING.OLDAGE_HEALTH_SCALE) or TUNING.EFFIGY_HEALTH_PENALTY

    if player.components.health == nil or math.ceil(player.components.health.currenthealth) <= amount_required then
        --Don't die from attunement!
        return false, "NOHEALTH"
    end

    player:PushEvent("consumehealthcost")
    player.components.health:DoDelta(-TUNING.EFFIGY_HEALTH_PENALTY, false, "statue_attune", true, inst, true)
    return true
end

local function onlink(inst, player, isloading)
    if not isloading then
        inst.SoundEmitter:PlaySound("dontstarve/common/together/meat_effigy_attune/on")
        inst.AnimState:PlayAnimation("attune_on")
        inst.AnimState:PushAnimation("idle", false)
    end
end

local function onunlink(inst, player, isloading)
    if not (isloading or inst.AnimState:IsCurrentAnimation("attune_on")) then
        inst.SoundEmitter:PlaySound("dontstarve/common/together/meat_effigy_attune/off")
        inst.AnimState:PlayAnimation("attune_off")
        inst.AnimState:PushAnimation("idle", false)
    end
end

local function PlayAttuneSound(inst)
    if inst.AnimState:IsCurrentAnimation("place") or inst.AnimState:IsCurrentAnimation("attune_on") then
        inst.SoundEmitter:PlaySound("dontstarve/common/together/meat_effigy_attune/on")
    end
end

as well as some extra stuff in the onbuilt function

local function onbuilt(inst, data)
    --Hack to auto-link without triggering fx or paying the cost again
    inst.components.attunable:SetOnAttuneCostFn(nil)
    inst.components.attunable:SetOnLinkFn(nil)
    inst.components.attunable:SetOnUnlinkFn(nil)

    inst.AnimState:PlayAnimation("place")
    if inst.components.attunable:LinkToPlayer(data.builder) then
        inst:DoTaskInTime(inst.AnimState:GetCurrentAnimationLength(), PlayAttuneSound)
        inst.AnimState:PushAnimation("attune_on")
    end
    inst.AnimState:PushAnimation("idle", false)

    --End hack
    inst.components.attunable:SetOnAttuneCostFn(onattunecost)
    inst.components.attunable:SetOnLinkFn(onlink)
    inst.components.attunable:SetOnUnlinkFn(onunlink)
end

 

18 hours ago, Merkyrrie said:

steamapps/common/Don't Starve Together/data/databundles/scripts.zip/prefabs

scripts.zip/ doesn't have a prefabs/ folder, it only has a scripts/ folder, I assume you mean scripts.zip/scripts/prefabs/ then?
And okay yeah I found it, I could've sworn I looked in here before...
Thanks anyway!

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
×
  • Create New...