commit 88f4bcfb32cb27b85c489a537c8b7a1bc93888da Author: Wuzzy Date: Sat Jul 2 14:24:09 2016 +0200 Initial commit: Version 1.1.1 diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..1f05d12 --- /dev/null +++ b/README.txt @@ -0,0 +1,20 @@ += The Origin = +Version 1.1.1 + +== Description == +This mod adds a single indestructible block, called “The Origin” once at +(0,-1,0) when the singlenode map generator is used, so players spawn on a +solid block instead of falling down immediately. From this block onwards, +players can build stuff to it just like with any other block. + +If static_spawnpoint is set, the Origin will be set one node length below +that point instead. + +== Technical notes == +The mod tries to ensure that the Origin will only be set once per world. +If the Origin has been set, a file called “origin.mt” will be placed in the +world's folder. It contains the position of the Origin. As long as this file +is present, this mod will not place the Origin again. + +== License == +License of everything in this mod: WTFPL diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..e69de29 diff --git a/description.txt b/description.txt new file mode 100644 index 0000000..2a127ae --- /dev/null +++ b/description.txt @@ -0,0 +1 @@ +Adds a single starter block, called “The Origin”, below the first spawn position, when the map generator “singlenode” is used. Useful for creative players who want to build their world from scratch. diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..f39bdce --- /dev/null +++ b/init.lua @@ -0,0 +1,54 @@ +--[[ +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) diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..fbf859d Binary files /dev/null and b/screenshot.png differ diff --git a/sounds/origin_origin_footstep.ogg b/sounds/origin_origin_footstep.ogg new file mode 100644 index 0000000..7befe6d Binary files /dev/null and b/sounds/origin_origin_footstep.ogg differ diff --git a/textures/origin_origin.png b/textures/origin_origin.png new file mode 100644 index 0000000..6108b27 Binary files /dev/null and b/textures/origin_origin.png differ