Jump to content

making already existing entities emit sounds


Recommended Posts

hey there, i am trying to add sound emitters to existing entities (specifically boulders), but i just cant seem to work. any kind of help would be appritiated, and i am pretty new to modding, so might definitely be missing something.

here's the code:


Assets = {

	Asset("SOUNDPACKAGE", "sound/rockysound.fev"),
	Asset("SOUND", "sound/rockysound_bank02.fsb"),
	
}

local prefabs =
{
    "rocks",
}

print("test if this works")
-- creates sound effects for rocks

local function rock1_sounds(inst)
	local inst = rock1_fn()

	if not TheWorld.ismastersim then --THIS IS PURELY REFERENCE on where your code needs to go.
        return inst
    end
	
	local function onnear(inst) --when you approach the structure
    	inst.SoundEmitter:PlaySound("rockysound/untitled/rockysound")
	end
	
	print("test if this also works")
	return inst
end

 

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