]> git.lizzy.rs Git - crafter_client.git/blobdiff - init.lua
Update README.md
[crafter_client.git] / init.lua
index bb0c85bc788017da96df66f983721003c8df5960..7c22037e22af1b5302d54b8a712f6f78bd4ba498 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -1,99 +1,46 @@
-print("weather client go")
-local weather = minetest.mod_channel_join("weather_nodes")
-local weather_type = minetest.mod_channel_join("weather_type")
-local server = minetest.mod_channel_join("server")
-
-local all_nodes = {}
-local do_effects = false
-local snow = false
-local weather_update_timer = 0
-local id_table = {}
-
-local spawn_weather = function(player)
-       local pos = player:get_pos()
-       local radius = 10
-       local particle_table = {}
-       
-       local area = vector.new(10,10,10)
-       
-       local min = vector.subtract(pos, area)
-       local max = vector.add(pos, area)
-       
-       
-       local area_index = minetest.find_nodes_in_area_under_air(min, max, all_nodes)
-       
-       local spawn_table = {}
-       --find the highest y value
-       for _,index in pairs(area_index) do
-               if not spawn_table[index.x] then spawn_table[index.x] = {} end
-               if not spawn_table[index.x][index.z] then
-                       spawn_table[index.x][index.z] = index.y
-               elseif spawn_table[index.x][index.z] < index.y then
-                       spawn_table[index.x][index.z] = index.y
-               end
-       end
-       
-       for x,x_index in pairs(spawn_table) do
-               for z,y in pairs(x_index) do
-                       if minetest.get_node_or_nil(vector.new(x,y+1,z)) ~= nil then
-                               --print("got to this spointa")
-                               local pos = vector.new(x,y+1,z)
-                               local lightlevel = 14
-                               --local lightlevel = minetest.get_node_light(pos, 0.5)
-                               --print("but not here")
-                               if lightlevel >= 14 then
-                                       minetest.add_particlespawner({
-                                               amount = 1,
-                                               time = 0.5,
-                                               minpos = vector.new(x-0.5,y,z-0.5),
-                                               maxpos = vector.new(x+0.5,y+20,z+0.5),
-                                               minvel = {x=-0.2, y=-0.2, z=-0.2},
-                                               maxvel = {x=0.2, y=-0.5, z=0.2},
-                                               minacc = {x=0, y=0, z=0},
-                                               maxacc = {x=0, y=0, z=0},
-                                               minexptime = 1,
-                                               maxexptime = 1,
-                                               minsize = 1,
-                                               maxsize = 1,
-                                               collisiondetection = true,
-                                               collision_removal = true,
-                                               object_collision = false,
-                                               texture = "snowflake_"..math.random(1,2)..".png",
-                                               playername = player:get_name(),
-                                       })
-                               end
-                       end
-               end
+--don't crash if not in crafter client
+for _,r in pairs(minetest.get_csm_restrictions()) do 
+       if r == true then
+               return
        end
 end
+if not minetest.get_node_def("client_version_checker:this_is_the_signature_of_crafter00111010010001000011110000110011") then
+       return
+end
 
-minetest.register_globalstep(function(dtime)
-       if do_effects then
-               if snow then
-                       weather_update_timer = weather_update_timer + dtime
-                       if weather_update_timer >= 0.5 then
-                               weather_update_timer = 0
-                               local player = minetest.localplayer
-                               spawn_weather(minetest.localplayer)
-                       end
-               end
-       end
-end)
-
+nodes = nil
+function initialize_all()
+       --declare globals for now
 
+       --next we load everything seperately because it's easier to work on individual files than have everything jammed into one file
+       --not into seperate mods because that is unnecessary and cumbersome
+       local path = minetest.get_modpath("crafter_client")
+       dofile(path.."/player_input.lua")
+       dofile(path.."/weather_handling.lua")
+       dofile(path.."/environment_effects.lua")
+       dofile(path.."/nether.lua")
+       dofile(path.."/aether.lua")
+       dofile(path.."/waila.lua")
+       dofile(path.."/music_handling.lua")
+       dofile(path.."/version_send.lua")
+       dofile(path.."/colored_names/colored_names.lua")
+       dofile(path.."/fire_handling.lua")
+       dofile(path.."/sleeping.lua")
+end
 
-minetest.register_on_modchannel_message(function(channel_name, sender, message)
-       if channel_name == "weather_nodes" then
-               all_nodes = minetest.deserialize(message)
-               do_effects = true
-       end
-       if channel_name == "weather_type" then
-               if message == "1" then
-                       print("snowing")
-                       snow = true
-               else
-                       print("not snowing")
-                       snow = false
-               end
+--we must delay initialization until the player exists in the world
+local function recursive_startup_attempt()
+       local ready_to_go = minetest.localplayer
+       if ready_to_go and minetest.get_node_or_nil(minetest.localplayer:get_pos()) then
+               --good to begin
+               initialize_all()
+       else
+               --try again
+               minetest.after(0,function()
+                       recursive_startup_attempt()
+               end)
        end
-end)
+end
+
+--begin initial attempt
+recursive_startup_attempt()