Noise Lua API: Difference between revisions

From Off Grid Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(7 intermediate revisions by 4 users not shown)
Line 3: Line 3:
== Description ==
== Description ==
The Noise system provides a method of producing sounds that the AI can be aware of and respond to.
The Noise system provides a method of producing sounds that the AI can be aware of and respond to.
== Tables ==
=== Noise ===
Table representing a noise
'''Table definition'''
{| class="wikitable"
|-
! Name !! Type !! Default !! Optional !! Description
|-
| soundName || string ||  || No || The name of the sound event
|-
| attraction || number ||  || No || How much attraction this noise will cause (range 0-1)
|-
| volume || number || 1.0 || Yes || The volume of the sound event (range (0-1)
|-
| duration || number || 0.0 || Yes || How long does this noise last? 0 will loop the sound and require it to be explicitly ended
|-
| trusted || boolean || false || Yes || Whether this noise is trusted by AIs
|-
| offEvent || string ||  || Yes || Sound to emit when the source is silenced
|}
== Functions ==
== Functions ==
=== Emit ===
=== Emit ===
Line 21: Line 44:
'''Notes''': Attraction value is required, volume is optional (default 1.0), as is duration (defaults to 0, which loops the sound).
'''Notes''': Attraction value is required, volume is optional (default 1.0), as is duration (defaults to 0, which loops the sound).
=== Silence ===
=== Silence ===
<syntaxhighlight source lang="lua">Noise.Silence(deviceName, noiseTable)</syntaxhighlight>
<syntaxhighlight source lang="lua">Noise.Silence(deviceName)</syntaxhighlight>
'''Expected parameter types'''
'''Expected parameter types'''
{| class="wikitable"
{| class="wikitable"
Line 28: Line 51:
|-
|-
| deviceName || string
| deviceName || string
|-
| noiseTable || Lua Table
|}
|}
'''Description''': Silences the noise
'''Description''': Silences the noise
Line 40: Line 61:
This file is auto generated, please don't edit manually!
This file is auto generated, please don't edit manually!


'''Docs last hacked together on''': 06/09/2018 14:53
'''Docs last hacked together on''': 29/08/2023 16:24
[[Category:Modding]][[Category:LuaAPI]]
[[Category:Modding]][[Category:LuaAPI]]

Latest revision as of 14:19, 29 August 2023

Noise

Description

The Noise system provides a method of producing sounds that the AI can be aware of and respond to.


Tables

Noise

Table representing a noise

Table definition

Name Type Default Optional Description
soundName string No The name of the sound event
attraction number No How much attraction this noise will cause (range 0-1)
volume number 1.0 Yes The volume of the sound event (range (0-1)
duration number 0.0 Yes How long does this noise last? 0 will loop the sound and require it to be explicitly ended
trusted boolean false Yes Whether this noise is trusted by AIs
offEvent string Yes Sound to emit when the source is silenced

Functions

Emit

Noise.Emit(deviceName, noiseTable)

Expected parameter types

Name Type
deviceName string
noiseTable Lua Table

Description: Emits a noise from deviceName with attributes in noiseTable

Returns: Nothing

Notes: Attraction value is required, volume is optional (default 1.0), as is duration (defaults to 0, which loops the sound).

Silence

Noise.Silence(deviceName)

Expected parameter types

Name Type
deviceName string

Description: Silences the noise

Returns: Nothing

Notes: Silences the noise, principally from an AI perspective. Will attempt to stop the audio if this noise was set up with an end event.


This file is auto generated, please don't edit manually!

Docs last hacked together on: 29/08/2023 16:24