Initial commit: Version 1.1.1
commit
88f4bcfb32
|
@ -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,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.
|
|
@ -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)
|
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 598 B |
Loading…
Reference in New Issue