mirror of
				https://github.com/mt-mods/xcompat.git
				synced 2025-11-04 02:05:27 +01:00 
			
		
		
		
	refactor mod (#22)
This commit is contained in:
		
							
								
								
									
										35
									
								
								doc/sounds.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								doc/sounds.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
			
		||||
# Sound API
 | 
			
		||||
 | 
			
		||||
## Option 1: Agnostically depend
 | 
			
		||||
 | 
			
		||||
You can do this by using a custom field in your node def instead of the `sounds` key.
 | 
			
		||||
 | 
			
		||||
```lua
 | 
			
		||||
minetest.register_node(nodename, {
 | 
			
		||||
    ...
 | 
			
		||||
    _sound_def = {
 | 
			
		||||
        key = "",
 | 
			
		||||
        input = {},
 | 
			
		||||
    },
 | 
			
		||||
    ...
 | 
			
		||||
})
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
where:
 | 
			
		||||
 | 
			
		||||
* key: string name of the field from the sound api you want to use, for example `node_sound_stone_defaults`
 | 
			
		||||
* input: table input of fields you want passed to the key field, used to override specific sounds.
 | 
			
		||||
 | 
			
		||||
## Option 2: Hard depend
 | 
			
		||||
 | 
			
		||||
add this mod to your mod.confs depends and directly call the sound_api as follows
 | 
			
		||||
 | 
			
		||||
```lua
 | 
			
		||||
minetest.register_node(nodename, {
 | 
			
		||||
    ...
 | 
			
		||||
    sounds = xcompat.sounds.node_sound_stone_defaults(input)
 | 
			
		||||
    ...
 | 
			
		||||
})
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
* input: optional table to override some or all of returned values
 | 
			
		||||
		Reference in New Issue
	
	Block a user