]> git.lizzy.rs Git - crafter_client.git/blob - init.lua
Stop client from crashing if there are restrictions on the server
[crafter_client.git] / init.lua
1 --don't crash if not in crafter client
2 for _,r in pairs(minetest.get_csm_restrictions()) do 
3         if r == true then
4                 return
5         end
6 end
7
8 --declare globals
9 weather_intake = nil
10 weather = nil
11 weather_type = nil
12 player_movement_state = nil
13 nether = nil
14 aether = nil
15 name = nil
16 version_channel = nil
17 fire_handling_channel = nil
18
19 function initialize_all()
20         --declare globals for now
21         weather_intake = minetest.mod_channel_join("weather_intake")
22         weather = minetest.mod_channel_join("weather_nodes")
23         weather_type = minetest.mod_channel_join("weather_type")
24         player_movement_state = minetest.mod_channel_join(name..":player_movement_state")
25         nether = minetest.mod_channel_join(name..":nether_teleporters")
26         aether = minetest.mod_channel_join(name..":aether_teleporters")
27         version_channel = minetest.mod_channel_join(name..":client_version_channel")
28         fire_handling_channel = minetest.mod_channel_join(name..":fire_state")
29
30         --next we load everything seperately because it's easier to work on individual files than have everything jammed into one file
31         --not into seperate mods because that is unnecessary and cumbersome
32         local path = minetest.get_modpath("crafter_client")
33         dofile(path.."/player_input.lua")
34         dofile(path.."/weather_handling.lua")
35         dofile(path.."/environment_effects.lua")
36         dofile(path.."/nether.lua")
37         dofile(path.."/aether.lua")
38         dofile(path.."/waila.lua")
39         dofile(path.."/music_handling.lua")
40         dofile(path.."/version_send.lua")
41         dofile(path.."/colored_names/colored_names.lua")
42         dofile(path.."/fire_handling.lua")
43 end
44
45 --we must delay initialization until the player exists in the world
46 local function recursive_startup_attempt()
47         local ready_to_go = minetest.localplayer
48         if ready_to_go and minetest.get_node_or_nil(minetest.localplayer:get_pos()) then
49                 name = minetest.localplayer:get_name()
50                 --good to begin
51                 initialize_all()
52         else
53                 --try again
54                 minetest.after(0,function()
55                         recursive_startup_attempt()
56                 end)
57         end
58 end
59
60 --begin initial attempt
61 recursive_startup_attempt()