Sign in to follow this  
Tykvesh

Issues with enabling special music and vision changing for eater

Recommended Posts

Tykvesh    682

I tried to add this function for my custom food: 

local function on_eat(inst, eater)

    TheWorld:PushEvent("enabledynamicmusic", false)
    if not TheFocalPoint.SoundEmitter:PlayingSound("beavermusic") then
        TheFocalPoint.SoundEmitter:PlaySound("dontstarve/music/music_hoedown", "beavermusic")
    end
        
    local BEAVERVISION_COLOURCUBES =
    {
        day = "images/colour_cubes/beaver_vision_cc.tex",
        dusk = "images/colour_cubes/beaver_vision_cc.tex",
        night = "images/colour_cubes/beaver_vision_cc.tex",
        full_moon = "images/colour_cubes/beaver_vision_cc.tex",
    }
        
    eater.components.playervision:SetCustomCCTable(BEAVERVISION_COLOURCUBES)
        
        eater:DoTaskInTime(30, function()
            TheWorld:PushEvent("enabledynamicmusic", true)
            TheFocalPoint.SoundEmitter:KillSound("beavermusic")
            
            eater.components.playervision:SetCustomCCTable(nil)
        end)
end

When player eat this custom food he gets beaver's vision (except of night vision) and funny music for 30 seconds. This works perfectly for no caves world, but doing nothing on dedicated (overworld+caves) server.

Share this post


Link to post
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
Sign in to follow this