]> git.lizzy.rs Git - skycraft.git/blobdiff - init.lua
New file Structure
[skycraft.git] / init.lua
index 4b0d0070f8a9fce59c859027a3d561c6ade8e3c8..842cab82decddd1fb67bcc345594ce40101e2cca 100755 (executable)
--- a/init.lua
+++ b/init.lua
@@ -10,43 +10,28 @@ do
        end
 end
 
-function skycraft.get_far_node(pos)
-       local node = minetest.get_node(pos)
-       if node.name ~= "ignore" then
-               return node
-       end
-       minetest.get_voxel_manip():read_from_map(pos, pos)
-       return minetest.get_node(pos)
-end
-
-function skycraft.find_free_position_near(pos)
-       local tries = {
-               {x =  1, y =  0, z =  0},
-               {x = -1, y =  0, z =  0},
-               {x =  0, y =  0, z =  1},
-               {x =  0, y =  0, z = -1},
-       }
-       for _, d in pairs(tries) do
-               local p = vector.add(pos, d)
-               if not minetest.registered_nodes[minetest.get_node(p).name].walkable then
-                       return p, true
-               end
-       end
-       return pos, false
-end
-
-minetest.register_privilege("skycraft", "Use Skycraft commands")
-
 minetest.register_on_shutdown(function()
        local file = io.open(minetest.get_worldpath() .. "/skycraft", "w")
        file:write(minetest.serialize(skycraft.savedata))
        file:close()
 end)
 
-do
-       local modpath = minetest.get_modpath("skycraft")
-       local modules = {"random", "commands", "ranks", "plots", "spawns", "mapgen", "request", "tpa", "trade", "lobby", "money", "lucky_block", "nether_portal", "lava_cooling", "flower_spread", "shop"}
-       for _, m in pairs(modules) do
-               dofile(modpath .. "/" .. m .. ".lua")
+minetest.register_privilege("skycraft", "Use Skycraft commands")
+
+local modules = {
+       common = {"common", "random" , "request"},
+       main = {"commands", "flower_spread", "lobby", "lucky_block", "mapgen", "money", "plots", "ranks", "spawns", "tpa", "trade"},
+       onload = {"lava_cooling", "lobby_load", "nether_portal", "sapling_mutation", "shop", "spawn", "void"}
+}
+local modpath = minetest.get_modpath("skycraft")
+local function load_module(m)
+       for _, f in pairs(modules[m]) do
+               dofile(modpath .. "/src/" .. m .. "/" .. f .. ".lua")
        end
 end
+load_module("common")
+load_module("main")
+minetest.register_on_mods_loaded(function()
+       load_module("onload")
+end)
+