Use new doc_items field names
[minetest_origin.git] / init.lua
blob011a08c4789990d6589f1e6b0b6ed47eae865582
1 --[[
2 The Origin
3 version 1.3.0
4 ]]
6 local S
7 if (minetest.get_modpath("intllib")) then
8 S = intllib.Getter()
9 else
10 S = function ( s ) return s end
11 end
13 local origin = {}
14 origin.settings = {}
17 local filepath = minetest.get_worldpath().."/origin.mt"
18 local file = io.open(filepath, "r")
19 if file then
20 io.close(file)
21 origin.exists = true
22 else
23 origin.exists = false
24 end
26 origin.settings.force_singlenode = minetest.setting_getbool("origin_force_singlenode")
27 if origin.settings.force_singlenode == nil then
28 origin.settings.force_singlenode = true
29 end
30 end
32 minetest.register_node("origin:origin",{
33 description = S("The Origin"),
34 _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."),
35 groups = { not_in_creative_inventory = 1, immortal = 1 },
36 diggable = false,
37 tiles = {"origin_origin.png"},
38 sounds = { footstep = "origin_origin_footstep" },
39 is_ground_content = false,
40 drop = "",
43 minetest.register_on_mapgen_init(function(mgparams)
44 if origin.settings.force_singlenode == true then
45 minetest.set_mapgen_params({mgname = "singlenode"})
46 end
47 end)
49 minetest.register_on_generated(function(minp, maxp, seed)
50 local spawn = minetest.setting_get_pos("static_spawnpoint")
51 if origin.exists ~= true then
52 local blockpos
53 if spawn ~= nil then
54 blockpos = { x=spawn.x, y=spawn.y-1, z=spawn.z }
55 else
56 blockpos = { x=0, y=-1, z=0 }
57 end
58 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
59 minetest.set_node(blockpos, {name = "origin:origin"})
60 minetest.log("action", "[origin] The Origin has been set at "..minetest.pos_to_string(blockpos)..".")
61 origin.exists = true
62 local filepath = minetest.get_worldpath().."/origin.mt"
63 local file = io.open(filepath, "w")
64 if file then
65 file:write(minetest.pos_to_string(blockpos))
66 else
67 minetest.log("error", "[origin] Failed to write origin data into "..filepath..". The Origin may be placed again if you change static_spawnpoint.")
68 end
69 end
70 end
71 end)