]> git.lizzy.rs Git - crafter_client.git/blob - init.lua
ef4653dfaf9b1e683e52ecb3b874a1576c4d62d5
[crafter_client.git] / init.lua
1 --first we join the necessary channels so the mod can "listen"  to what the server says and "talk" to it
2 weather_intake = minetest.mod_channel_join("weather_intake")
3 weather = minetest.mod_channel_join("weather_nodes")
4 weather_type = minetest.mod_channel_join("weather_type")
5 running_send = minetest.mod_channel_join("running_send")
6 player_movement_state = minetest.mod_channel_join("player.player_movement_state")
7
8
9 function initialize_all()
10         --first we tell the server we're ready
11         weather_intake:send_all("READY")
12         weather_intake:leave()
13         weather_intake = nil --leave the channel
14         
15         --next we load everything seperately because it's easier to work on individual files than have everything jammed into one file
16         --not into seperate mods because that is unnecessary and cumbersome
17         local path = minetest.get_modpath("crafter_client")
18         dofile(path.."/player_input.lua")
19         dofile(path.."/weather_handling.lua")
20         dofile(path.."/environment_effects.lua")
21 end
22
23 --we must delay initialization until the player's camera exists in the world
24 --since there does not seem to be any client_loaded function
25 local initialize = false
26 minetest.register_globalstep(function(dtime)
27         if not initialize and minetest.camera and not vector.equals(minetest.camera:get_pos(),vector.new(0,0,0)) then
28                 minetest.after(2, function()
29                         if weather_intake then
30                                 initialize = true
31                                 initialize_all()
32                         end
33                 end)
34         end
35 end)