Classes

Concepts

Libraries

advertisement »

ambientSounds »

bitser »

contentPoints »

eventBoxText »

factValidity »

frameBuffer »

officeBuildingInserter »

priorityRenderer »

randomEvents »

scaling »

spritesheetParser »

statusIcons »

test3 »

util »

Objects

registerSound

Description

Register a new ambient sound template to play.

Arguments

1 table data

the ambient sound template.

Example

-- taken from game/basic_ambient_sounds.lua


local function genericTimeOfDayCheck(self)
	local time = timeOfDay:getTime()
	
	if self.timeOfDay.min > self.timeOfDay.max then
		return time > self.timeOfDay.min or time < self.timeOfDay.max
	end
	
	return time > self.timeOfDay.min and time <= self.timeOfDay.max
end

local birds = {}
birds.id = "birds"
birds.type = ambientSounds.playType.PLAYONCE
birds.timeOfDay = {min = 260, max = 1260}
birds.sound = {"ambient_birds"}
birds.frequency = {min = 15, max = 20}
birds.vol = 0.05
birds.meetsRequirements = genericTimeOfDayCheck

ambientSounds.registerSound(birds)
-- this registers the sound of birds chirping to play only during the day