]> git.lizzy.rs Git - crafter_client.git/blob - init.lua
Add in water splash sound
[crafter_client.git] / init.lua
1 --first we join the necessary channels so the mod can "listen" to what the server says
2 weather = minetest.mod_channel_join("weather_nodes")
3 weather_type = minetest.mod_channel_join("weather_type")
4 running_send = minetest.mod_channel_join("running_send")
5 player_movement_state = minetest.mod_channel_join("player.player_movement_state")
6
7
8 --we load everything seperately because it's easier to work on individual files than have everything jammed into one file
9 --not into seperate mods because that is unnecessary and cumbersome
10 local path = minetest.get_modpath("crafter_client")
11 dofile(path.."/player_input.lua")
12 dofile(path.."/weather_handling.lua")
13
14 local old_node
15 local in_water = false
16 local old_in_water = false
17 minetest.register_globalstep(function(dtime)
18         local pos = minetest.localplayer:get_pos()
19         pos.y = pos.y - 0.1
20         local node = minetest.get_node_or_nil(pos)
21         if node then
22                 local name = node.name
23                 if name == "main:water" or name == "main:water_flowing" then
24                         in_water = true
25                         
26                         if in_water == true and old_in_water == false then
27                                 minetest.sound_play("splash", {gain = 0.4, pitch = math.random(80,100)/100})
28                         end
29                 else
30                         in_water = false
31                 end
32         end
33         
34         old_node = node
35         old_in_water = in_water
36 end)