Initial commit: Version 1.1.1

master
Wuzzy 2016-07-02 14:24:09 +02:00
commit 88f4bcfb32
7 changed files with 75 additions and 0 deletions

20
README.txt Normal file
View File

@ -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

0
depends.txt Normal file
View File

1
description.txt Normal file
View File

@ -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.

54
init.lua Normal file
View File

@ -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)

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

BIN
textures/origin_origin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B