Remove in_doc
[minetest_origin.git] / init.lua
blob76220044c88ca3ba68cce0f21ba4fcd2d47df79c
1 --[[
2 The Origin
3 version 1.3.0
4 ]]
6 local S
7 if (minetest.get_modpath("intllib")) then
8 dofile(minetest.get_modpath("intllib").."/intllib.lua")
9 S = intllib.Getter(minetest.get_current_modname())
10 else
11 S = function ( s ) return s end
12 end
14 local origin = {}
15 origin.settings = {}
18 local filepath = minetest.get_worldpath().."/origin.mt"
19 local file = io.open(filepath, "r")
20 if file then
21 io.close(file)
22 origin.exists = true
23 else
24 origin.exists = false
25 end
27 origin.settings.force_singlenode = minetest.setting_getbool("origin_force_singlenode")
28 if origin.settings.force_singlenode == nil then
29 origin.settings.force_singlenode = true
30 end
31 end
33 minetest.register_node("origin:origin",{
34 description = S("The Origin"),
35 x_doc_items_longdesc = S("The Origin is the starting block of this world. On the Origin the earliest visitors of this world arrive and it is the first block at which all other blocks can be built to, so that builders can build their architectural masterpieces in a world which would be (usually) empty otherwise."),
36 groups = { not_in_creative_inventory = 1, immortal = 1 },
37 diggable = false,
38 tiles = {"origin_origin.png"},
39 sounds = { footstep = "origin_origin_footstep" },
40 is_ground_content = false,
41 drop = "",
44 minetest.register_on_mapgen_init(function(mgparams)
45 if origin.settings.force_singlenode == true then
46 minetest.set_mapgen_params({mgname = "singlenode"})
47 end
48 end)
50 minetest.register_on_generated(function(minp, maxp, seed)
51 local spawn = minetest.setting_get_pos("static_spawnpoint")
52 if origin.exists ~= true then
53 local blockpos
54 if spawn ~= nil then
55 blockpos = { x=spawn.x, y=spawn.y-1, z=spawn.z }
56 else
57 blockpos = { x=0, y=-1, z=0 }
58 end
59 if(minp.x <= blockpos.x and maxp.x >= blockpos.x and minp.y <= blockpos.y and maxp.y >= blockpos.y and minp.z <= blockpos.z and maxp.z >= blockpos.z) then
60 minetest.set_node(blockpos, {name = "origin:origin"})
61 minetest.log("action", "[origin] The Origin has been set at "..minetest.pos_to_string(blockpos)..".")
62 origin.exists = true
63 local filepath = minetest.get_worldpath().."/origin.mt"
64 local file = io.open(filepath, "w")
65 if file then
66 file:write(minetest.pos_to_string(blockpos))
67 else
68 minetest.log("error", "[origin] Failed to write origin data into "..filepath..". The Origin may be placed again if you change static_spawnpoint.")
69 end
70 end
71 end
72 end)