--[[ The Origin version 1.1.1 ]] origin = {} do local filepath = minetest.get_worldpath().."/origin.mt" local file = io.open(filepath, "r") if file then io.close(file) origin.exists = true else origin.exists = false end end minetest.register_node("origin:origin",{ description = "The Origin", is_ground_content = true, groups = { not_in_creative_inventory = 1, immortal = 1 }, tiles = {"origin_origin.png"}, sounds = { footstep = "origin_origin_footstep" }, is_ground_content = false, }) minetest.register_on_mapgen_init(function(mgparams) origin.mgparams = mgparams end) minetest.register_on_generated(function(minp, maxp, seed) local spawn = minetest.setting_get_pos("static_spawnpoint") if origin.exists ~= true and origin.mgparams.mgname == "singlenode" then local blockpos if spawn ~= nil then blockpos = { x=spawn.x, y=spawn.y-1, z=spawn.z } else blockpos = { x=0, y=-1, z=0 } end 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 minetest.set_node(blockpos, {name = "origin:origin"}) minetest.log("action", "[origin] The Origin has been set at "..minetest.pos_to_string(blockpos)..".") origin.exists = true local filepath = minetest.get_worldpath().."/origin.mt" local file = io.open(filepath, "w") if file then file:write(minetest.pos_to_string(blockpos)) else minetest.log("error", "[origin] Failed to write origin data into "..filepath..". The Origin may be placed again if you change static_spawnpoint.") end end end end)