Jump to content

Change "Activate" to "Worship"


Recommended Posts

Basically I'm trying to make a shrine and I want the player to "worship" it rather than "activate" it. I tried using the code for making you "investigate" dirt piles, but it's not working. Here's my code.

 

Spoiler

local assets =
{
    Asset("ANIM", "anim/Shrine_Elyon.zip"),
}

local prefabs =
{
    "shrine_elyon",
}

local function Worship()
    return "WORSHIP"
end

local function onhammered(inst, worker)
    local pos = inst:GetPosition()
    local broken = SpawnPrefab("shrine_elyon")
    broken.Transform:SetPosition(pos:Get())
    TheWorld:PushEvent("ms_sendlightningstrike", pos)
    inst:Remove()
end
    
local function onhit(inst, worker)
    local pos = inst:GetPosition()
    TheWorld:PushEvent("ms_sendlightningstrike", pos)
end

local function OnWorshipped(inst, doer)
    inst.AnimState:PlayAnimation("WorshipGift", false)
    doer.components.health:DoDelta(25,false,"shrine_elyon")
    doer.entity:AddTag("elyon")
    inst:DoTaskInTime(50,
        inst.AnimState:PlayAnimation("idle_loop", true)
    )
    inst:DoTaskInTime(500, 
        function() 
            inst.components.activatable.inactive = true
        end
    )
end

    local function fn()
        local inst = CreateEntity()

        inst.entity:AddTransform()
        inst.entity:AddAnimState()
        inst.entity:AddMiniMapEntity()
        inst.entity:AddSoundEmitter()
        inst.entity:AddNetwork()
        inst.entity:AddLight()

        MakeObstaclePhysics(inst, .2)

        --inst.MiniMapEntity:SetPriority(5)
        --inst.MiniMapEntity:SetIcon(name..".png")

        inst.AnimState:SetBank("Shrine_Elyon")
        inst.AnimState:SetBuild("Shrine_Elyon")
        inst.AnimState:PlayAnimation("idle_loop", true)

        inst:AddTag("structure")
        inst:AddTag("antlion_sinkhole_blocker")
        
        inst.Light:Enable(true)
        inst.Light:SetRadius(1)
        inst.Light:SetFalloff(1)
        inst.Light:SetIntensity(.5)
        inst.Light:SetColour(1, 1, 1)
        inst.Light:EnableClientModulation(true)
        
        inst.GetActivateVerb = Worship
        
        inst.entity:SetPristine()
        
        if not TheWorld.ismastersim then
            return inst
        end
        inst:AddComponent("activatable")    
        inst.components.activatable.OnActivate = OnWorshipped

        inst:AddComponent("inspectable")

        inst:AddComponent("workable")
        inst.components.workable:SetWorkAction(ACTIONS.HAMMER)
        inst.components.workable:SetWorkLeft(999)
        inst.components.workable:SetOnFinishCallback(onhammered)
        inst.components.workable:SetOnWorkCallback(onhit)
        inst:AddComponent("hauntable")
        inst.components.hauntable:SetHauntValue(TUNING.HAUNT_INSTANT_REZ)

        return inst
    end
    return Prefab("shrine_elyon", fn, assets, prefabs)

 

Link to comment
Share on other sites

Totally not sure but maybe you need a string to define the exact result of "workship" thing. I see this in files :

 


#. STRINGS.ACTIONS.ACTIVATE.INVESTIGATE
msgctxt "STRINGS.ACTIONS.ACTIVATE.INVESTIGATE"
msgid "Investigate"
msgstr ""

So maybe you need something more than just put workship ?

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...