added drowning and ultra-minimal
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1,62 @@
|
|||
drowning = {} -- Exported functions
|
||||
|
||||
local players_under_water = {}
|
||||
|
||||
local START_DROWNING_SECONDS = 60
|
||||
local DROWNING_SECONDS = 5
|
||||
local DROWNING_DAMAGE = 1
|
||||
|
||||
local timer = 0
|
||||
if minetest.setting_getbool("enable_damage") == true then
|
||||
minetest.register_globalstep(function(dtime)
|
||||
timer = timer + dtime
|
||||
if timer >= .5 then
|
||||
timer = timer - .5
|
||||
else
|
||||
return
|
||||
end
|
||||
for k, v in pairs(minetest.object_refs) do
|
||||
if v:get_player_name() ~= nil then
|
||||
name = v:get_player_name()
|
||||
if players_under_water[name] == nil then
|
||||
players_under_water[name] = {count=0, drowning=false}
|
||||
end
|
||||
if IsPlayerInAir(v) == false then
|
||||
players_under_water[name].count = players_under_water[name].count + .5
|
||||
|
||||
if players_under_water[name].drowning and players_under_water[name].count >= DROWNING_SECONDS then
|
||||
v:set_hp(v:get_hp() - DROWNING_DAMAGE)
|
||||
pos = v:getpos()
|
||||
pos.y=pos.y+1
|
||||
minetest.sound_play({name="drowning_gurp"}, {pos = pos, gain = 1.0, max_hear_distance = 16})
|
||||
players_under_water[name].count = players_under_water[name].count - DROWNING_SECONDS
|
||||
elseif not players_under_water[name].drowning and players_under_water[name].count >= START_DROWNING_SECONDS then
|
||||
players_under_water[name] = {count=0, drowning=true}
|
||||
v:set_hp(v:get_hp() - DROWNING_DAMAGE)
|
||||
pos = v:getpos()
|
||||
pos.y=pos.y+1
|
||||
minetest.sound_play({name="drowning_gurp"}, {pos = pos, gain = 1.0, max_hear_distance = 16})
|
||||
end
|
||||
elseif players_under_water[name].count > 0 then
|
||||
pos = v:getpos()
|
||||
pos.y=pos.y+1
|
||||
minetest.sound_play({name="drowning_gasp"}, {pos = pos, gain = 1.0, max_hear_distance = 32})
|
||||
players_under_water[name] = {count=0, drowning=false}
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function IsPlayerInAir(player)
|
||||
-- player:getpos() is at the feet (I think) so add 1 to y to get where the head is?
|
||||
pos = player:getpos()
|
||||
pos.x = math.floor(pos.x+0.5)
|
||||
pos.y = math.floor(pos.y+1.5)
|
||||
pos.z = math.floor(pos.z+0.5)
|
||||
|
||||
if minetest.env:get_node(pos).name == "air" then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
|
@ -0,0 +1,50 @@
|
|||
The main game for the Minetest game engine [minetest_game]
|
||||
==========================================================
|
||||
|
||||
To build the wholeness of the Minetest project, insert this repository as
|
||||
/games/minetest_game
|
||||
in the Minetest Engine.
|
||||
|
||||
The Minetest Engine can be found in:
|
||||
https://github.com/celeron55/minetest/
|
||||
|
||||
Compatibility
|
||||
--------------
|
||||
The minetest_game github master HEAD is generally compatible with the github
|
||||
master HEAD of minetest.
|
||||
|
||||
Additionally, when the minetest engine is tagged to be a certain version (eg.
|
||||
0.4.dev-20120326), minetest_game is tagged with the version too.
|
||||
|
||||
When stable releases are made, minetest_game is packaged and made available in
|
||||
https://github.com/celeron55/minetest_game/downloads
|
||||
and in case the repository has grown too much, it may be reset. In that sense,
|
||||
this is not a "real" git repository. (Package maintainers please note!)
|
||||
|
||||
License of source code
|
||||
----------------------
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
See README.txt in each mod directory for information about other authors.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
License of media (textures and sounds)
|
||||
--------------------------------------
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
See README.txt in each mod directory for information about other authors.
|
||||
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
name = Null Space
|
||||
|
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1,481 @@
|
|||
-- ***********************************************************************************
|
||||
-- ***********************************************
|
||||
-- 4SEASONS **************************************************
|
||||
-- ***********************************************
|
||||
-- ***********************************************************************************
|
||||
|
||||
|
||||
|
||||
PLANTLIKE = function(nodeid, nodename,type,option)
|
||||
if option == nil then option = false end
|
||||
|
||||
local params ={ description = nodename, drawtype = "plantlike", tile_images = {"4seasons_"..nodeid..'.png'},
|
||||
inventory_image = "4seasons_"..nodeid..'.png', wield_image = "4seasons_"..nodeid..'.png', paramtype = "light", }
|
||||
|
||||
if type == 'veg' then
|
||||
params.groups = {snappy=2,dig_immediate=3,flammable=2}
|
||||
params.sounds = default.node_sound_leaves_defaults()
|
||||
if option == false then params.walkable = false end
|
||||
elseif type == 'met' then -- metallic
|
||||
params.groups = {cracky=3}
|
||||
params.sounds = default.node_sound_stone_defaults()
|
||||
elseif type == 'cri' then -- craft items
|
||||
params.groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3}
|
||||
params.sounds = default.node_sound_wood_defaults()
|
||||
if option == false then params.walkable = false end
|
||||
elseif type == 'eat' then -- edible
|
||||
params.groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3}
|
||||
params.sounds = default.node_sound_wood_defaults()
|
||||
params.walkable = false
|
||||
params.on_use = minetest.item_eat(option)
|
||||
end
|
||||
minetest.register_node("4seasons:"..nodeid, params)
|
||||
end
|
||||
|
||||
--[[
|
||||
SEASON_LENGTH = 1500 -- max tested 1500
|
||||
WEATHER_CHANGE_INTERVAL = 60
|
||||
BIRDS = true
|
||||
-- ***********************************************************************************
|
||||
-- SEASONAL CHANGES **************************************************
|
||||
-- ***********************************************************************************
|
||||
SEASON_FILE = minetest.get_worldpath()..'/4seasons.season'
|
||||
|
||||
local function set_season(t)
|
||||
CURRENT_SEASON = t
|
||||
-- write to file
|
||||
local f = io.open(SEASON_FILE, "w")
|
||||
f:write(CURRENT_SEASON)
|
||||
io.close(f)
|
||||
end
|
||||
|
||||
local f = io.open(SEASON_FILE, "r")
|
||||
if f ~= nil then
|
||||
CURRENT_SEASON = f:read("*n")
|
||||
io.close(f)
|
||||
else
|
||||
print('could not find season file, creating one (setting summer).')
|
||||
set_season(3)
|
||||
|
||||
end
|
||||
|
||||
switch_seasons = function()
|
||||
if CURRENT_SEASON == 1 then
|
||||
set_season(2) -- set to spring
|
||||
print('changing to spring')
|
||||
minetest.after(SEASON_LENGTH,switch_seasons)
|
||||
elseif CURRENT_SEASON == 2 then
|
||||
set_season(3) -- set to summer
|
||||
print('changing to summer')
|
||||
minetest.after(SEASON_LENGTH,switch_seasons)
|
||||
elseif CURRENT_SEASON == 3 then
|
||||
set_season(4) -- set to autumn
|
||||
print('changing to autumn')
|
||||
minetest.after(SEASON_LENGTH,switch_seasons)
|
||||
elseif CURRENT_SEASON == 4 then
|
||||
set_season(1) -- set to winter
|
||||
print('changing to winter')
|
||||
minetest.after(SEASON_LENGTH,switch_seasons)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
minetest.after(SEASON_LENGTH,switch_seasons)
|
||||
|
||||
minetest.register_chatcommand("season", {
|
||||
params = "<season>",
|
||||
description = "set the season",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
if param == 'winter' or param == 'Winter' then set_season(1)
|
||||
elseif param == 'spring' or param == 'Spring' then set_season(2)
|
||||
elseif param == 'summer' or param == 'Summer' then set_season(3)
|
||||
elseif param == 'fall' or param == 'Fall' then set_season(4)
|
||||
elseif param == 'pause' or param == 'Pause' then set_season(0)
|
||||
minetest.chat_send_player(name, "Season paused.")
|
||||
return
|
||||
else
|
||||
minetest.chat_send_player(name, "Invalid paramater '"..param.."', try 'winter','spring','summer' or 'fall'.")
|
||||
return
|
||||
end
|
||||
minetest.chat_send_player(name, "Season changed.")
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = { "default:dirt_with_grass","4seasons:grass_autumn",'4seasons:grass_winter',"4seasons:grass_spring",
|
||||
'default:leaves','4seasons:leaves_autumn','4seasons:leaves_winter','4seasons:leaves_spring',
|
||||
"default:water_source","default:water_flowing", "default:cactus","default:desert_sand","default:sand","4seasons:desertsand_winter", "4seasons:sand_winter","4seasons:cactus_winter",'4seasons:ice_source','4seasons:ice_flowing' },
|
||||
interval = WEATHER_CHANGE_INTERVAL,
|
||||
chance = 6,
|
||||
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if CURRENT_SEASON == 1 then
|
||||
if node.name == '4seasons:grass_autumn' or node.name == 'default:dirt_with_grass' or node.name == '4seasons:grass_spring' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:grass_winter'})
|
||||
elseif node.name == '4seasons:leaves_autumn' or node.name == 'default:leaves' or node.name == '4seasons:leaves_spring' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:leaves_winter'})
|
||||
|
||||
elseif node.name == 'default:desert_sand' then
|
||||
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
if above ~= nil and above.name == 'air' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:desertsand_winter'})
|
||||
end
|
||||
elseif node.name == 'default:sand' then
|
||||
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
if above ~= nil and above.name == 'air' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:sand_winter'})
|
||||
end
|
||||
elseif node.name == 'default:cactus' then
|
||||
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
if above ~= nil and above.name == 'air' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:cactus_winter'})
|
||||
end
|
||||
elseif node.name == 'default:water_source' then
|
||||
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
if above ~= nil and above.name == 'air' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:ice_source'})
|
||||
end
|
||||
elseif node.name == 'default:water_flowing' then
|
||||
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
if above ~= nil and above.name == 'air' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:ice_flowing'})
|
||||
end
|
||||
end
|
||||
elseif CURRENT_SEASON == 2 then
|
||||
if node.name == '4seasons:grass_winter' or node.name == '4seasons:grass_autumn' or node.name == 'default:dirt_with_grass' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:grass_spring'})
|
||||
elseif node.name == '4seasons:leaves_winter' or node.name == '4seasons:leaves_autumn' or node.name == 'default:leaves' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:leaves_spring'})
|
||||
elseif node.name == '4seasons:desertsand_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:desert_sand'})
|
||||
elseif node.name == '4seasons:sand_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:sand'})
|
||||
elseif node.name == '4seasons:cactus_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:cactus'})
|
||||
elseif node.name == '4seasons:ice_source' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:water_source'})
|
||||
elseif node.name == '4seasons:ice_flowing' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:water_flowing'})
|
||||
end
|
||||
elseif CURRENT_SEASON == 3 then
|
||||
if node.name == '4seasons:leaves_spring' or node.name == '4seasons:leaves_winter' or node.name == '4seasons:leaves_autumn' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:leaves'})
|
||||
elseif node.name == '4seasons:grass_spring' or node.name == '4seasons:grass_winter' or node.name == '4seasons:grass_autumn' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:dirt_with_grass'})
|
||||
elseif node.name == '4seasons:desertsand_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:desert_sand'})
|
||||
elseif node.name == '4seasons:sand_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:sand'})
|
||||
elseif node.name == '4seasons:cactus_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:cactus'})
|
||||
elseif node.name == '4seasons:ice_source' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:water_source'})
|
||||
elseif node.name == '4seasons:ice_flowing' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:water_flowing'})
|
||||
end
|
||||
elseif CURRENT_SEASON == 4 then
|
||||
if node.name == 'default:leaves' or node.name == '4seasons:leaves_spring' or node.name == '4seasons:leaves_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:leaves_autumn'})
|
||||
elseif node.name == 'default:dirt_with_grass' or node.name == '4seasons:grass_spring' or node.name == '4seasons:grass_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:grass_autumn'})
|
||||
elseif node.name == '4seasons:desertsand_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:desert_sand'})
|
||||
elseif node.name == '4seasons:sand_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:sand'})
|
||||
elseif node.name == '4seasons:cactus_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:cactus'})
|
||||
elseif node.name == '4seasons:ice_source' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:water_source'})
|
||||
elseif node.name == '4seasons:ice_flowing' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:water_flowing'})
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
-- ***********************************************************************************
|
||||
-- BIRDS SPRING/SUMMER **************************************************
|
||||
-- ***********************************************************************************
|
||||
if BIRDS == true then
|
||||
local bird = {}
|
||||
bird.sounds = {}
|
||||
bird_sound = function(p)
|
||||
local wanted_sound = {name="bird", gain=0.6}
|
||||
bird.sounds[minetest.hash_node_position(p)] = {
|
||||
handle = minetest.sound_play(wanted_sound, {pos=p, loop=true}),
|
||||
name = wanted_sound.name, }
|
||||
end
|
||||
|
||||
bird_stop = function(p)
|
||||
local sound = bird.sounds[minetest.hash_node_position(p)]
|
||||
if sound ~= nil then
|
||||
minetest.sound_stop(sound.handle)
|
||||
bird.sounds[minetest.hash_node_position(p)] = nil
|
||||
end
|
||||
end
|
||||
minetest.register_on_dignode(function(p, node)
|
||||
if node.name == "4seasons:bird" then
|
||||
bird_stop(p)
|
||||
|
||||
end
|
||||
end)
|
||||
minetest.register_abm({
|
||||
nodenames = { "4seasons:leaves_spring",'default:leaves' },
|
||||
interval = NATURE_GROW_INTERVAL,
|
||||
chance = 200,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local air = { x=pos.x, y=pos.y+1,z=pos.z }
|
||||
local is_air = minetest.env:get_node_or_nil(air)
|
||||
if is_air ~= nil and is_air.name == 'air' then
|
||||
minetest.env:add_node(air,{type="node",name='4seasons:bird'})
|
||||
bird_sound(air)
|
||||
end
|
||||
end
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {'4seasons:bird' },
|
||||
interval = NATURE_GROW_INTERVAL,
|
||||
chance = 2,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
minetest.env:remove_node(pos)
|
||||
bird_stop(pos)
|
||||
end
|
||||
})
|
||||
end
|
||||
]]--
|
||||
-- ***********************************************************************************
|
||||
-- SLIMTREES **************************************************
|
||||
-- ***********************************************************************************
|
||||
minetest.register_abm({
|
||||
nodenames = { "4seasons:slimtree" },
|
||||
interval = 120,
|
||||
chance = 1,
|
||||
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+1,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+2,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+3,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x+1,y=pos.y+3,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x-1,y=pos.y+3,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+3,z=pos.z+1},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+3,z=pos.z-1},{type="node",name="default:leaves"})
|
||||
|
||||
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+4,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x+1,y=pos.y+4,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x-1,y=pos.y+4,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+4,z=pos.z+1},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+4,z=pos.z-1},{type="node",name="default:leaves"})
|
||||
|
||||
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+5,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x+1,y=pos.y+5,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x-1,y=pos.y+5,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+5,z=pos.z+1},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+5,z=pos.z-1},{type="node",name="default:leaves"})
|
||||
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+6,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x+1,y=pos.y+6,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x-1,y=pos.y+6,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+6,z=pos.z+1},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+6,z=pos.z-1},{type="node",name="default:leaves"})
|
||||
end
|
||||
})
|
||||
-- ***********************************************************************************
|
||||
-- PALM TREES **************************************************
|
||||
-- ***********************************************************************************
|
||||
minetest.register_abm({
|
||||
nodenames = { "4seasons:palmtree" },
|
||||
interval = 120,
|
||||
chance = 1,
|
||||
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+1,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+2,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+3,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+4,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+5,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+6,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+7,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+8,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x+2,y=pos.y+8,z=pos.z},{type="node",name="4seasons:palmleaves"})
|
||||
minetest.env:add_node({x=pos.x-2,y=pos.y+8,z=pos.z},{type="node",name="4seasons:palmleaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+8,z=pos.z+2},{type="node",name="4seasons:palmleaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+8,z=pos.z-2},{type="node",name="4seasons:palmleaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+9,z=pos.z},{type="node",name="4seasons:palmleaves"})
|
||||
minetest.env:add_node({x=pos.x+1,y=pos.y+9,z=pos.z},{type="node",name="4seasons:palmleaves"})
|
||||
minetest.env:add_node({x=pos.x-1,y=pos.y+9,z=pos.z},{type="node",name="4seasons:palmleaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+9,z=pos.z+1},{type="node",name="4seasons:palmleaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+9,z=pos.z-1},{type="node",name="4seasons:palmleaves"})
|
||||
end
|
||||
})
|
||||
|
||||
-- ***********************************************************************************
|
||||
-- NODES **************************************************
|
||||
-- ***********************************************************************************
|
||||
|
||||
PLANTLIKE('palmtree','Palmtree Sapling','veg')
|
||||
PLANTLIKE('slimtree','Slimtree Sapling','veg')
|
||||
PLANTLIKE('bird','Bird','veg')
|
||||
minetest.register_node("4seasons:palmleaves", {
|
||||
description = "Rail",
|
||||
drawtype = "raillike",
|
||||
tile_images = {"4seasons_palmleaves.png", "4seasons_palmleaves_top.png", "4seasons_palmleaves_top.png", "4seasons_palmleaves_top.png"},
|
||||
inventory_image = "4seasons_palmleaves.png",
|
||||
wield_image = "4seasons_palmleaves.png",
|
||||
paramtype = "light",
|
||||
is_ground_content = true,
|
||||
walkable = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
--fixed = <default>
|
||||
},
|
||||
groups = {bendy=2,snappy=1,dig_immediate=2},
|
||||
})
|
||||
minetest.register_node("4seasons:slimtree_wood", {
|
||||
description = "Slimtree",
|
||||
drawtype = "fencelike",
|
||||
tile_images = {"default_tree.png"},
|
||||
-- inventory_image = "default_tree.png",
|
||||
-- wield_image = "default_tree.png",
|
||||
paramtype = "light",
|
||||
is_ground_content = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
|
||||
},
|
||||
groups = {tree=1,snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = 'default:fence_wood',
|
||||
})
|
||||
|
||||
--[[
|
||||
minetest.register_node("4seasons:ice_source", {
|
||||
description = "Ice",
|
||||
tile_images = {"4seasons_ice.png"},
|
||||
is_ground_content = true,
|
||||
groups = {snappy=2,choppy=3},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
minetest.register_node("4seasons:ice_flowing", {
|
||||
description = "Ice",
|
||||
tile_images = {"4seasons_ice.png"},
|
||||
is_ground_content = true,
|
||||
groups = {snappy=2,choppy=3},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
minetest.register_node("4seasons:leaves_autumn", {
|
||||
description = "Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
visual_scale = 1.3,
|
||||
tile_images = {"4seasons_leaves_autumn.png"},
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, leafdecay=3, flammable=2},
|
||||
drop = {
|
||||
max_items = 1, items = {
|
||||
{items = {'default:sapling'}, rarity = 20,},
|
||||
{items = {'4seasons:leaves_autumn'},}
|
||||
}},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
minetest.register_node("4seasons:leaves_spring", {
|
||||
description = "Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
visual_scale = 1.3,
|
||||
tile_images = {"4seasons_leaves_spring.png"},
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, leafdecay=3, flammable=2},
|
||||
drop = {
|
||||
max_items = 1, items = {
|
||||
{items = {'default:sapling'}, rarity = 20,},
|
||||
{items = {'4seasons:leaves_spring'},}
|
||||
}},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
minetest.register_node("4seasons:grass_spring", {
|
||||
description = "Dirt with snow",
|
||||
tile_images = {"4seasons_grass_spring.png", "default_dirt.png", "default_dirt.png^4seasons_grass_spring_side.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
drop = 'default:dirt',
|
||||
sounds = default.node_sound_dirt_defaults({
|
||||
footstep = {name="default_grass_footstep", gain=0.4},
|
||||
}),
|
||||
})
|
||||
minetest.register_node("4seasons:grass_autumn", {
|
||||
description = "Dirt with snow",
|
||||
tile_images = {"4seasons_grass_autumn.png", "default_dirt.png", "default_dirt.png^4seasons_grass_autumn_side.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
drop = 'default:dirt',
|
||||
sounds = default.node_sound_dirt_defaults({
|
||||
footstep = {name="default_grass_footstep", gain=0.4},
|
||||
}),
|
||||
})
|
||||
minetest.register_node("4seasons:grass_winter", {
|
||||
description = "Dirt with snow",
|
||||
tile_images = {"4seasons_snow.png", "default_dirt.png", "default_dirt.png^4seasons_grass_w_snow_side.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
drop = 'default:dirt',
|
||||
sounds = default.node_sound_dirt_defaults({
|
||||
footstep = {name="default_grass_footstep", gain=0.4},
|
||||
}),
|
||||
})
|
||||
minetest.register_node("4seasons:leaves_winter", {
|
||||
description = "Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
visual_scale = 1.3,
|
||||
tile_images = {"4seasons_leaves_with_snow.png"},
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, leafdecay=3, flammable=2},
|
||||
drop = {
|
||||
max_items = 1, items = {
|
||||
{items = {'default:sapling'}, rarity = 20,},
|
||||
{items = {'4seasons:leaves_winter'},}
|
||||
}},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
minetest.register_node("4seasons:cactus_winter", {
|
||||
description = "Cactus",
|
||||
tile_images = {"4seasons_cactus_wsnow_top.png", "4seasons_cactus_wsnow_top.png", "4seasons_cactus_wsnow_side.png"},
|
||||
is_ground_content = true,
|
||||
groups = {snappy=2,choppy=3,flammable=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
minetest.register_node("4seasons:sand_winter", {
|
||||
description = "Sand with snow",
|
||||
tile_images = {"4seasons_snow.png", "default_sand.png", "default_sand.png^4seasons_sand_w_snow_side.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
drop = 'default:sand',
|
||||
sounds = default.node_sound_dirt_defaults({
|
||||
footstep = {name="default_grass_footstep", gain=0.4},
|
||||
}),
|
||||
})
|
||||
minetest.register_node("4seasons:desertsand_winter", {
|
||||
description = "Desert Sand with snow",
|
||||
tile_images = {"4seasons_snow.png", "default_desert_sand.png", "default_desert_sand.png^4seasons_desertsand_w_snow_side.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
drop = 'default:desert_sand',
|
||||
sounds = default.node_sound_dirt_defaults({
|
||||
footstep = {name="default_grass_footstep", gain=0.4},
|
||||
}),
|
||||
})
|
||||
]]--
|
||||
minetest.register_craft({ output = 'node "4seasons:slimtree" 1', recipe = {
|
||||
{'','default:leaves',''},
|
||||
{'','default:leaves',''},
|
||||
{'','default:stick',''},
|
||||
}})
|
||||
minetest.register_craft({ output = 'node "4seasons:palmtree" 1', recipe = {
|
||||
{'default:leaves','default:stick','default:leaves'},
|
||||
{'','default:stick',''},
|
||||
{'','default:stick',''},
|
||||
}})
|
|
@ -0,0 +1,467 @@
|
|||
-- ***********************************************************************************
|
||||
-- ***********************************************
|
||||
-- 4SEASONS **************************************************
|
||||
-- ***********************************************
|
||||
-- ***********************************************************************************
|
||||
|
||||
SEASON_LENGTH = 1500 -- max tested 1500
|
||||
WEATHER_CHANGE_INTERVAL = 60
|
||||
BIRDS = true
|
||||
|
||||
PLANTLIKE = function(nodeid, nodename,type,option)
|
||||
if option == nil then option = false end
|
||||
|
||||
local params ={ description = nodename, drawtype = "plantlike", tile_images = {"4seasons_"..nodeid..'.png'},
|
||||
inventory_image = "4seasons_"..nodeid..'.png', wield_image = "4seasons_"..nodeid..'.png', paramtype = "light", }
|
||||
|
||||
if type == 'veg' then
|
||||
params.groups = {snappy=2,dig_immediate=3,flammable=2}
|
||||
params.sounds = default.node_sound_leaves_defaults()
|
||||
if option == false then params.walkable = false end
|
||||
elseif type == 'met' then -- metallic
|
||||
params.groups = {cracky=3}
|
||||
params.sounds = default.node_sound_stone_defaults()
|
||||
elseif type == 'cri' then -- craft items
|
||||
params.groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3}
|
||||
params.sounds = default.node_sound_wood_defaults()
|
||||
if option == false then params.walkable = false end
|
||||
elseif type == 'eat' then -- edible
|
||||
params.groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3}
|
||||
params.sounds = default.node_sound_wood_defaults()
|
||||
params.walkable = false
|
||||
params.on_use = minetest.item_eat(option)
|
||||
end
|
||||
minetest.register_node("4seasons:"..nodeid, params)
|
||||
end
|
||||
|
||||
-- ***********************************************************************************
|
||||
-- SEASONAL CHANGES **************************************************
|
||||
-- ***********************************************************************************
|
||||
SEASON_FILE = minetest.get_worldpath()..'/4seasons.season'
|
||||
|
||||
local function set_season(t)
|
||||
CURRENT_SEASON = t
|
||||
-- write to file
|
||||
local f = io.open(SEASON_FILE, "w")
|
||||
f:write(CURRENT_SEASON)
|
||||
io.close(f)
|
||||
end
|
||||
|
||||
local f = io.open(SEASON_FILE, "r")
|
||||
if f ~= nil then
|
||||
CURRENT_SEASON = f:read("*n")
|
||||
io.close(f)
|
||||
else
|
||||
print('could not find season file, creating one (setting summer).')
|
||||
set_season(3)
|
||||
|
||||
end
|
||||
|
||||
switch_seasons = function()
|
||||
if CURRENT_SEASON == 1 then
|
||||
set_season(2) -- set to spring
|
||||
print('changing to spring')
|
||||
minetest.after(SEASON_LENGTH,switch_seasons)
|
||||
elseif CURRENT_SEASON == 2 then
|
||||
set_season(3) -- set to summer
|
||||
print('changing to summer')
|
||||
minetest.after(SEASON_LENGTH,switch_seasons)
|
||||
elseif CURRENT_SEASON == 3 then
|
||||
set_season(4) -- set to autumn
|
||||
print('changing to autumn')
|
||||
minetest.after(SEASON_LENGTH,switch_seasons)
|
||||
elseif CURRENT_SEASON == 4 then
|
||||
set_season(1) -- set to winter
|
||||
print('changing to winter')
|
||||
minetest.after(SEASON_LENGTH,switch_seasons)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
minetest.after(SEASON_LENGTH,switch_seasons)
|
||||
|
||||
minetest.register_chatcommand("season", {
|
||||
params = "<season>",
|
||||
description = "set the season",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
if param == 'winter' or param == 'Winter' then set_season(1)
|
||||
elseif param == 'spring' or param == 'Spring' then set_season(2)
|
||||
elseif param == 'summer' or param == 'Summer' then set_season(3)
|
||||
elseif param == 'fall' or param == 'Fall' then set_season(4)
|
||||
elseif param == 'pause' or param == 'Pause' then set_season(0)
|
||||
minetest.chat_send_player(name, "Season paused.")
|
||||
return
|
||||
else
|
||||
minetest.chat_send_player(name, "Invalid paramater '"..param.."', try 'winter','spring','summer' or 'fall'.")
|
||||
return
|
||||
end
|
||||
minetest.chat_send_player(name, "Season changed.")
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = { "default:dirt_with_grass","4seasons:grass_autumn",'4seasons:grass_winter',"4seasons:grass_spring",
|
||||
'default:leaves','4seasons:leaves_autumn','4seasons:leaves_winter','4seasons:leaves_spring',
|
||||
"default:water_source","default:water_flowing", "default:cactus","default:desert_sand","default:sand","4seasons:desertsand_winter", "4seasons:sand_winter","4seasons:cactus_winter",'4seasons:ice_source','4seasons:ice_flowing' },
|
||||
interval = WEATHER_CHANGE_INTERVAL,
|
||||
chance = 6,
|
||||
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if CURRENT_SEASON == 1 then
|
||||
if node.name == '4seasons:grass_autumn' or node.name == 'default:dirt_with_grass' or node.name == '4seasons:grass_spring' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:grass_winter'})
|
||||
elseif node.name == '4seasons:leaves_autumn' or node.name == 'default:leaves' or node.name == '4seasons:leaves_spring' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:leaves_winter'})
|
||||
|
||||
elseif node.name == 'default:desert_sand' then
|
||||
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
if above ~= nil and above.name == 'air' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:desertsand_winter'})
|
||||
end
|
||||
elseif node.name == 'default:sand' then
|
||||
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
if above ~= nil and above.name == 'air' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:sand_winter'})
|
||||
end
|
||||
elseif node.name == 'default:cactus' then
|
||||
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
if above ~= nil and above.name == 'air' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:cactus_winter'})
|
||||
end
|
||||
elseif node.name == 'default:water_source' then
|
||||
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
if above ~= nil and above.name == 'air' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:ice_source'})
|
||||
end
|
||||
elseif node.name == 'default:water_flowing' then
|
||||
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
if above ~= nil and above.name == 'air' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:ice_flowing'})
|
||||
end
|
||||
end
|
||||
elseif CURRENT_SEASON == 2 then
|
||||
if node.name == '4seasons:grass_winter' or node.name == '4seasons:grass_autumn' or node.name == 'default:dirt_with_grass' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:grass_spring'})
|
||||
elseif node.name == '4seasons:leaves_winter' or node.name == '4seasons:leaves_autumn' or node.name == 'default:leaves' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:leaves_spring'})
|
||||
elseif node.name == '4seasons:desertsand_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:desert_sand'})
|
||||
elseif node.name == '4seasons:sand_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:sand'})
|
||||
elseif node.name == '4seasons:cactus_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:cactus'})
|
||||
elseif node.name == '4seasons:ice_source' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:water_source'})
|
||||
elseif node.name == '4seasons:ice_flowing' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:water_flowing'})
|
||||
end
|
||||
elseif CURRENT_SEASON == 3 then
|
||||
if node.name == '4seasons:leaves_spring' or node.name == '4seasons:leaves_winter' or node.name == '4seasons:leaves_autumn' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:leaves'})
|
||||
elseif node.name == '4seasons:grass_spring' or node.name == '4seasons:grass_winter' or node.name == '4seasons:grass_autumn' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:dirt_with_grass'})
|
||||
elseif node.name == '4seasons:desertsand_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:desert_sand'})
|
||||
elseif node.name == '4seasons:sand_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:sand'})
|
||||
elseif node.name == '4seasons:cactus_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:cactus'})
|
||||
elseif node.name == '4seasons:ice_source' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:water_source'})
|
||||
elseif node.name == '4seasons:ice_flowing' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:water_flowing'})
|
||||
end
|
||||
elseif CURRENT_SEASON == 4 then
|
||||
if node.name == 'default:leaves' or node.name == '4seasons:leaves_spring' or node.name == '4seasons:leaves_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:leaves_autumn'})
|
||||
elseif node.name == 'default:dirt_with_grass' or node.name == '4seasons:grass_spring' or node.name == '4seasons:grass_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='4seasons:grass_autumn'})
|
||||
elseif node.name == '4seasons:desertsand_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:desert_sand'})
|
||||
elseif node.name == '4seasons:sand_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:sand'})
|
||||
elseif node.name == '4seasons:cactus_winter' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:cactus'})
|
||||
elseif node.name == '4seasons:ice_source' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:water_source'})
|
||||
elseif node.name == '4seasons:ice_flowing' then
|
||||
minetest.env:add_node(pos,{type="node",name='default:water_flowing'})
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
-- ***********************************************************************************
|
||||
-- BIRDS SPRING/SUMMER **************************************************
|
||||
-- ***********************************************************************************
|
||||
if BIRDS == true then
|
||||
local bird = {}
|
||||
bird.sounds = {}
|
||||
bird_sound = function(p)
|
||||
local wanted_sound = {name="bird", gain=0.6}
|
||||
bird.sounds[minetest.hash_node_position(p)] = {
|
||||
handle = minetest.sound_play(wanted_sound, {pos=p, loop=true}),
|
||||
name = wanted_sound.name, }
|
||||
end
|
||||
|
||||
bird_stop = function(p)
|
||||
local sound = bird.sounds[minetest.hash_node_position(p)]
|
||||
if sound ~= nil then
|
||||
minetest.sound_stop(sound.handle)
|
||||
bird.sounds[minetest.hash_node_position(p)] = nil
|
||||
end
|
||||
end
|
||||
minetest.register_on_dignode(function(p, node)
|
||||
if node.name == "4seasons:bird" then
|
||||
bird_stop(p)
|
||||
|
||||
end
|
||||
end)
|
||||
minetest.register_abm({
|
||||
nodenames = { "4seasons:leaves_spring",'default:leaves' },
|
||||
interval = NATURE_GROW_INTERVAL,
|
||||
chance = 200,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local air = { x=pos.x, y=pos.y+1,z=pos.z }
|
||||
local is_air = minetest.env:get_node_or_nil(air)
|
||||
if is_air ~= nil and is_air.name == 'air' then
|
||||
minetest.env:add_node(air,{type="node",name='4seasons:bird'})
|
||||
bird_sound(air)
|
||||
end
|
||||
end
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {'4seasons:bird' },
|
||||
interval = NATURE_GROW_INTERVAL,
|
||||
chance = 2,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
minetest.env:remove_node(pos)
|
||||
bird_stop(pos)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
-- ***********************************************************************************
|
||||
-- SLIMTREES **************************************************
|
||||
-- ***********************************************************************************
|
||||
minetest.register_abm({
|
||||
nodenames = { "4seasons:slimtree" },
|
||||
interval = 120,
|
||||
chance = 1,
|
||||
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+1,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+2,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+3,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x+1,y=pos.y+3,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x-1,y=pos.y+3,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+3,z=pos.z+1},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+3,z=pos.z-1},{type="node",name="default:leaves"})
|
||||
|
||||
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+4,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x+1,y=pos.y+4,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x-1,y=pos.y+4,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+4,z=pos.z+1},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+4,z=pos.z-1},{type="node",name="default:leaves"})
|
||||
|
||||
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+5,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x+1,y=pos.y+5,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x-1,y=pos.y+5,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+5,z=pos.z+1},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+5,z=pos.z-1},{type="node",name="default:leaves"})
|
||||
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+6,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x+1,y=pos.y+6,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x-1,y=pos.y+6,z=pos.z},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+6,z=pos.z+1},{type="node",name="default:leaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+6,z=pos.z-1},{type="node",name="default:leaves"})
|
||||
end
|
||||
})
|
||||
-- ***********************************************************************************
|
||||
-- PALM TREES **************************************************
|
||||
-- ***********************************************************************************
|
||||
minetest.register_abm({
|
||||
nodenames = { "4seasons:palmtree" },
|
||||
interval = 120,
|
||||
chance = 1,
|
||||
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+1,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+2,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+3,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+4,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+5,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+6,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+7,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+8,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
|
||||
minetest.env:add_node({x=pos.x+2,y=pos.y+8,z=pos.z},{type="node",name="4seasons:palmleaves"})
|
||||
minetest.env:add_node({x=pos.x-2,y=pos.y+8,z=pos.z},{type="node",name="4seasons:palmleaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+8,z=pos.z+2},{type="node",name="4seasons:palmleaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+8,z=pos.z-2},{type="node",name="4seasons:palmleaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+9,z=pos.z},{type="node",name="4seasons:palmleaves"})
|
||||
minetest.env:add_node({x=pos.x+1,y=pos.y+9,z=pos.z},{type="node",name="4seasons:palmleaves"})
|
||||
minetest.env:add_node({x=pos.x-1,y=pos.y+9,z=pos.z},{type="node",name="4seasons:palmleaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+9,z=pos.z+1},{type="node",name="4seasons:palmleaves"})
|
||||
minetest.env:add_node({x=pos.x,y=pos.y+9,z=pos.z-1},{type="node",name="4seasons:palmleaves"})
|
||||
end
|
||||
})
|
||||
|
||||
-- ***********************************************************************************
|
||||
-- NODES **************************************************
|
||||
-- ***********************************************************************************
|
||||
|
||||
PLANTLIKE('palmtree','Palmtree Sapling','veg')
|
||||
PLANTLIKE('slimtree','Slimtree Sapling','veg')
|
||||
PLANTLIKE('bird','Bird','veg')
|
||||
minetest.register_node("4seasons:palmleaves", {
|
||||
description = "Rail",
|
||||
drawtype = "raillike",
|
||||
tile_images = {"4seasons_palmleaves.png", "4seasons_palmleaves_top.png", "4seasons_palmleaves_top.png", "4seasons_palmleaves_top.png"},
|
||||
inventory_image = "4seasons_palmleaves.png",
|
||||
wield_image = "4seasons_palmleaves.png",
|
||||
paramtype = "light",
|
||||
is_ground_content = true,
|
||||
walkable = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
--fixed = <default>
|
||||
},
|
||||
groups = {bendy=2,snappy=1,dig_immediate=2},
|
||||
})
|
||||
minetest.register_node("4seasons:slimtree_wood", {
|
||||
description = "Slimtree",
|
||||
drawtype = "fencelike",
|
||||
tile_images = {"default_tree.png"},
|
||||
-- inventory_image = "default_tree.png",
|
||||
-- wield_image = "default_tree.png",
|
||||
paramtype = "light",
|
||||
is_ground_content = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
|
||||
},
|
||||
groups = {tree=1,snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = 'default:fence_wood',
|
||||
})
|
||||
minetest.register_node("4seasons:ice_source", {
|
||||
description = "Ice",
|
||||
tile_images = {"4seasons_ice.png"},
|
||||
is_ground_content = true,
|
||||
groups = {snappy=2,choppy=3},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
minetest.register_node("4seasons:ice_flowing", {
|
||||
description = "Ice",
|
||||
tile_images = {"4seasons_ice.png"},
|
||||
is_ground_content = true,
|
||||
groups = {snappy=2,choppy=3},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
minetest.register_node("4seasons:leaves_autumn", {
|
||||
description = "Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
visual_scale = 1.3,
|
||||
tile_images = {"4seasons_leaves_autumn.png"},
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, leafdecay=3, flammable=2},
|
||||
drop = {
|
||||
max_items = 1, items = {
|
||||
{items = {'default:sapling'}, rarity = 20,},
|
||||
{items = {'4seasons:leaves_autumn'},}
|
||||
}},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
minetest.register_node("4seasons:leaves_spring", {
|
||||
description = "Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
visual_scale = 1.3,
|
||||
tile_images = {"4seasons_leaves_spring.png"},
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, leafdecay=3, flammable=2},
|
||||
drop = {
|
||||
max_items = 1, items = {
|
||||
{items = {'default:sapling'}, rarity = 20,},
|
||||
{items = {'4seasons:leaves_spring'},}
|
||||
}},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
minetest.register_node("4seasons:grass_spring", {
|
||||
description = "Dirt with snow",
|
||||
tile_images = {"4seasons_grass_spring.png", "default_dirt.png", "default_dirt.png^4seasons_grass_spring_side.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
drop = 'default:dirt',
|
||||
sounds = default.node_sound_dirt_defaults({
|
||||
footstep = {name="default_grass_footstep", gain=0.4},
|
||||
}),
|
||||
})
|
||||
minetest.register_node("4seasons:grass_autumn", {
|
||||
description = "Dirt with snow",
|
||||
tile_images = {"4seasons_grass_autumn.png", "default_dirt.png", "default_dirt.png^4seasons_grass_autumn_side.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
drop = 'default:dirt',
|
||||
sounds = default.node_sound_dirt_defaults({
|
||||
footstep = {name="default_grass_footstep", gain=0.4},
|
||||
}),
|
||||
})
|
||||
minetest.register_node("4seasons:grass_winter", {
|
||||
description = "Dirt with snow",
|
||||
tile_images = {"4seasons_snow.png", "default_dirt.png", "default_dirt.png^4seasons_grass_w_snow_side.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
drop = 'default:dirt',
|
||||
sounds = default.node_sound_dirt_defaults({
|
||||
footstep = {name="default_grass_footstep", gain=0.4},
|
||||
}),
|
||||
})
|
||||
minetest.register_node("4seasons:leaves_winter", {
|
||||
description = "Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
visual_scale = 1.3,
|
||||
tile_images = {"4seasons_leaves_with_snow.png"},
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, leafdecay=3, flammable=2},
|
||||
drop = {
|
||||
max_items = 1, items = {
|
||||
{items = {'default:sapling'}, rarity = 20,},
|
||||
{items = {'4seasons:leaves_winter'},}
|
||||
}},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
minetest.register_node("4seasons:cactus_winter", {
|
||||
description = "Cactus",
|
||||
tile_images = {"4seasons_cactus_wsnow_top.png", "4seasons_cactus_wsnow_top.png", "4seasons_cactus_wsnow_side.png"},
|
||||
is_ground_content = true,
|
||||
groups = {snappy=2,choppy=3,flammable=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
minetest.register_node("4seasons:sand_winter", {
|
||||
description = "Sand with snow",
|
||||
tile_images = {"4seasons_snow.png", "default_sand.png", "default_sand.png^4seasons_sand_w_snow_side.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
drop = 'default:sand',
|
||||
sounds = default.node_sound_dirt_defaults({
|
||||
footstep = {name="default_grass_footstep", gain=0.4},
|
||||
}),
|
||||
})
|
||||
minetest.register_node("4seasons:desertsand_winter", {
|
||||
description = "Desert Sand with snow",
|
||||
tile_images = {"4seasons_snow.png", "default_desert_sand.png", "default_desert_sand.png^4seasons_desertsand_w_snow_side.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
drop = 'default:desert_sand',
|
||||
sounds = default.node_sound_dirt_defaults({
|
||||
footstep = {name="default_grass_footstep", gain=0.4},
|
||||
}),
|
||||
})
|
||||
|
After Width: | Height: | Size: 358 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 358 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1,72 @@
|
|||
|
||||
-- ***********************************************************************************
|
||||
-- go **************************************************
|
||||
-- ***********************************************************************************
|
||||
local write_gofile = function()
|
||||
local output = '' -- WRITE CHANGES TO FILE
|
||||
for name, coords in pairs(GONETWORK) do output = output..name..':'..coords.x..','..coords.y..','..coords.z..';' end
|
||||
local f = io.open(minetest.get_worldpath()..'/bookmarks.go', "w")
|
||||
f:write(output)
|
||||
io.close(f)
|
||||
end
|
||||
|
||||
|
||||
GONETWORK = {}
|
||||
local gonfile = io.open(minetest.get_worldpath()..'/bookmarks.go', "r")
|
||||
if gonfile then
|
||||
local contents = gonfile:read()
|
||||
io.close(gonfile)
|
||||
if contents ~= nil then
|
||||
local entries = contents:split(";")
|
||||
for i,entry in pairs(entries) do
|
||||
local goname, coords = unpack(entry:split(":"))
|
||||
local p = {}
|
||||
p.x, p.y, p.z = string.match(coords, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
|
||||
if p.x and p.y and p.z then
|
||||
GONETWORK[goname] = {x = tonumber(p.x),y= tonumber(p.y),z = tonumber(p.z)}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
minetest.register_chatcommand("setgo", {
|
||||
params = "<name>",
|
||||
description = "set /go destination",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
local target = minetest.env:get_player_by_name(name)
|
||||
if target then
|
||||
GONETWORK[param] = target:getpos()
|
||||
write_gofile()
|
||||
minetest.chat_send_player(name, "/go "..param.." set")
|
||||
return
|
||||
end
|
||||
end,
|
||||
})
|
||||
minetest.register_chatcommand("go", {
|
||||
params = "<goname>",
|
||||
description = "go to destination",
|
||||
func = function(name, param)
|
||||
if GONETWORK[param] == nil then minetest.chat_send_player(name, "no such destination") return end
|
||||
teleportee = minetest.env:get_player_by_name(name)
|
||||
teleportee:setpos(GONETWORK[param])
|
||||
end,
|
||||
})
|
||||
minetest.register_chatcommand("delgo", {
|
||||
params = "<name>",
|
||||
description = "delete /go destination",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
if GONETWORK[param] then
|
||||
GONETWORK[param] = nil
|
||||
write_gofile()
|
||||
end
|
||||
end,
|
||||
})
|
||||
minetest.register_chatcommand("listgo", {
|
||||
params = "<goname>",
|
||||
description = "list all go destinations",
|
||||
func = function(name, param)
|
||||
for go, coords in pairs(GONETWORK) do minetest.chat_send_player(name, "/go "..go.. ' at '..coords.x..','..coords.y..','..coords.z) end
|
||||
end,
|
||||
})
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
Minetest 0.4 mod: default
|
||||
==========================
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
Copyright (C) 2011-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
|
||||
License of media (textures and sounds)
|
||||
--------------------------------------
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
Authors of media files
|
||||
-----------------------
|
||||
Everything not listed in here:
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
Originating from work by kddekadenz/Dogers:
|
||||
default_grass_footstep.{1,2,3}.ogg
|
||||
default_dig_crumbly.{1,2}.ogg
|
||||
|
||||
Cisoun's WTFPL texture pack:
|
||||
default_chest_front.png
|
||||
default_chest_lock.png
|
||||
default_chest_side.png
|
||||
default_chest_top.png
|
||||
default_cobble.png
|
||||
default_dirt.png
|
||||
default_grass.png
|
||||
default_grass_side.png
|
||||
default_jungletree.png
|
||||
default_jungletree_top.png
|
||||
default_lava.png
|
||||
default_leaves.png
|
||||
default_mossycobble.png
|
||||
default_sand.png
|
||||
default_sapling.png
|
||||
default_sign_wall.png
|
||||
default_stone.png
|
||||
default_tool_mesepick.png
|
||||
default_tool_steelpick.png
|
||||
default_tool_steelshovel.png
|
||||
default_tool_steelsword.png
|
||||
default_tool_stonepick.png
|
||||
default_tool_stoneshovel.png
|
||||
default_tool_woodpick.png
|
||||
default_tool_woodshovel.png
|
||||
default_tree.png
|
||||
default_tree_top.png
|
||||
default_water.png
|
||||
|
||||
Originating from G4JC's Almost MC Texture Pack:
|
||||
default_wood.png
|
||||
default_torch.png
|
||||
default_torch_on_ceiling.png
|
||||
default_torch_on_floor.png
|
||||
|
|
@ -0,0 +1,277 @@
|
|||
-- minetest/default/mapgen.lua
|
||||
|
||||
--
|
||||
-- Aliases for map generator outputs
|
||||
--
|
||||
|
||||
minetest.register_alias("mapgen_air", "air")
|
||||
minetest.register_alias("mapgen_stone", "air")
|
||||
minetest.register_alias("mapgen_tree", "air")
|
||||
minetest.register_alias("mapgen_leaves", "air")
|
||||
minetest.register_alias("mapgen_apple", "air")
|
||||
minetest.register_alias("mapgen_water_source", "air")
|
||||
minetest.register_alias("mapgen_dirt", "air")
|
||||
minetest.register_alias("mapgen_sand", "air")
|
||||
minetest.register_alias("mapgen_gravel", "air")
|
||||
minetest.register_alias("mapgen_clay", "air")
|
||||
minetest.register_alias("mapgen_lava_source", "air")
|
||||
minetest.register_alias("mapgen_cobble", "air")
|
||||
minetest.register_alias("mapgen_mossycobble", "air")
|
||||
minetest.register_alias("mapgen_dirt_with_grass", "air")
|
||||
minetest.register_alias("mapgen_junglegrass", "air")
|
||||
minetest.register_alias("mapgen_stone_with_coal", "air")
|
||||
minetest.register_alias("mapgen_stone_with_iron", "air")
|
||||
minetest.register_alias("mapgen_mese", "air")
|
||||
minetest.register_alias("mapgen_desert_sand", "air")
|
||||
minetest.register_alias("mapgen_desert_stone", "air")
|
||||
|
||||
--
|
||||
-- Ore generation
|
||||
--
|
||||
--[[
|
||||
local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, chunk_size, ore_per_chunk, height_min, height_max)
|
||||
if maxp.y < height_min or minp.y > height_max then
|
||||
return
|
||||
end
|
||||
local y_min = math.max(minp.y, height_min)
|
||||
local y_max = math.min(maxp.y, height_max)
|
||||
local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
|
||||
local pr = PseudoRandom(seed)
|
||||
local num_chunks = math.floor(chunks_per_volume * volume)
|
||||
local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
|
||||
--print("generate_ore num_chunks: "..dump(num_chunks))
|
||||
for i=1,num_chunks do
|
||||
local y0 = pr:next(y_min, y_max-chunk_size+1)
|
||||
if y0 >= height_min and y0 <= height_max then
|
||||
local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
|
||||
local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
|
||||
local p0 = {x=x0, y=y0, z=z0}
|
||||
for x1=0,chunk_size-1 do
|
||||
for y1=0,chunk_size-1 do
|
||||
for z1=0,chunk_size-1 do
|
||||
if pr:next(1,inverse_chance) == 1 then
|
||||
local x2 = x0+x1
|
||||
local y2 = y0+y1
|
||||
local z2 = z0+z1
|
||||
local p2 = {x=x2, y=y2, z=z2}
|
||||
if minetest.env:get_node(p2).name == wherein then
|
||||
minetest.env:set_node(p2, {name=name})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--print("generate_ore done")
|
||||
end
|
||||
|
||||
function default.make_papyrus(pos, size)
|
||||
for y=0,size-1 do
|
||||
local p = {x=pos.x, y=pos.y+y, z=pos.z}
|
||||
minetest.env:set_node(p, {name="default:papyrus"})
|
||||
end
|
||||
end
|
||||
|
||||
function default.make_cactus(pos, size)
|
||||
for y=0,size-1 do
|
||||
local p = {x=pos.x, y=pos.y+y, z=pos.z}
|
||||
minetest.env:set_node(p, {name="default:cactus"})
|
||||
end
|
||||
end
|
||||
|
||||
-- facedir: 0/1/2/3 (head node facedir value)
|
||||
-- length: length of rainbow tail
|
||||
|
||||
function default.make_nyancat(pos, facedir, length)
|
||||
local tailvec = {x=0, y=0, z=0}
|
||||
if facedir == 0 then
|
||||
tailvec.z = 1
|
||||
elseif facedir == 1 then
|
||||
tailvec.x = 1
|
||||
elseif facedir == 2 then
|
||||
tailvec.z = -1
|
||||
elseif facedir == 3 then
|
||||
tailvec.x = -1
|
||||
else
|
||||
print("default.make_nyancat(): Invalid facedir: "+dump(facedir))
|
||||
facedir = 0
|
||||
tailvec.z = 1
|
||||
end
|
||||
local p = {x=pos.x, y=pos.y, z=pos.z}
|
||||
minetest.env:set_node(p, {name="default:nyancat", param2=facedir})
|
||||
for i=1,length do
|
||||
p.x = p.x + tailvec.x
|
||||
p.z = p.z + tailvec.z
|
||||
minetest.env:set_node(p, {name="default:nyancat_rainbow"})
|
||||
end
|
||||
end
|
||||
|
||||
function generate_nyancats(seed, minp, maxp)
|
||||
local height_min = -31000
|
||||
local height_max = -32
|
||||
if maxp.y < height_min or minp.y > height_max then
|
||||
return
|
||||
end
|
||||
local y_min = math.max(minp.y, height_min)
|
||||
local y_max = math.min(maxp.y, height_max)
|
||||
local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
|
||||
local pr = PseudoRandom(seed + 9324342)
|
||||
local max_num_nyancats = math.floor(volume / (16*16*16))
|
||||
for i=1,max_num_nyancats do
|
||||
if pr:next(0, 1000) == 0 then
|
||||
local x0 = pr:next(minp.x, maxp.x)
|
||||
local y0 = pr:next(minp.y, maxp.y)
|
||||
local z0 = pr:next(minp.z, maxp.z)
|
||||
local p0 = {x=x0, y=y0, z=z0}
|
||||
default.make_nyancat(p0, pr:next(0,3), pr:next(3,15))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
|
||||
-- Generate regular ores
|
||||
generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed+0, 1/8/8/8, 3, 8, -31000, 64)
|
||||
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+1, 1/12/12/12, 2, 3, -15, 2)
|
||||
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+2, 1/9/9/9, 3, 5, -63, -16)
|
||||
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+3, 1/7/7/7, 3, 5, -31000, -64)
|
||||
generate_ore("default:mese", "default:stone", minp, maxp, seed+4, 1/16/16/16, 2, 3, -127, -64)
|
||||
generate_ore("default:mese", "default:stone", minp, maxp, seed+5, 1/9/9/9, 3, 5, -31000,-128)
|
||||
|
||||
generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed+7, 1/24/24/24, 6,27, -31000, 0)
|
||||
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+6, 1/24/24/24, 6,27, -31000, -64)
|
||||
|
||||
if maxp.y >= 2 and minp.y <= 0 then
|
||||
-- Generate clay
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 4
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0+1,divs-1-1 do
|
||||
for divz=0+1,divs-1-1 do
|
||||
local cx = minp.x + math.floor((divx+0.5)*divlen)
|
||||
local cz = minp.z + math.floor((divz+0.5)*divlen)
|
||||
if minetest.env:get_node({x=cx,y=1,z=cz}).name == "default:water_source" and
|
||||
minetest.env:get_node({x=cx,y=0,z=cz}).name == "default:sand" then
|
||||
local is_shallow = true
|
||||
local num_water_around = 0
|
||||
if minetest.env:get_node({x=cx-divlen*2,y=1,z=cz+0}).name == "default:water_source" then
|
||||
num_water_around = num_water_around + 1 end
|
||||
if minetest.env:get_node({x=cx+divlen*2,y=1,z=cz+0}).name == "default:water_source" then
|
||||
num_water_around = num_water_around + 1 end
|
||||
if minetest.env:get_node({x=cx+0,y=1,z=cz-divlen*2}).name == "default:water_source" then
|
||||
num_water_around = num_water_around + 1 end
|
||||
if minetest.env:get_node({x=cx+0,y=1,z=cz+divlen*2}).name == "default:water_source" then
|
||||
num_water_around = num_water_around + 1 end
|
||||
if num_water_around >= 2 then
|
||||
is_shallow = false
|
||||
end
|
||||
if is_shallow then
|
||||
for x1=-divlen,divlen do
|
||||
for z1=-divlen,divlen do
|
||||
if minetest.env:get_node({x=cx+x1,y=0,z=cz+z1}).name == "default:sand" then
|
||||
minetest.env:set_node({x=cx+x1,y=0,z=cz+z1}, {name="default:clay"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Generate papyrus
|
||||
local perlin1 = minetest.env:get_perlin(354, 3, 0.7, 100)
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 8
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0,divs-1 do
|
||||
for divz=0,divs-1 do
|
||||
local x0 = minp.x + math.floor((divx+0)*divlen)
|
||||
local z0 = minp.z + math.floor((divz+0)*divlen)
|
||||
local x1 = minp.x + math.floor((divx+1)*divlen)
|
||||
local z1 = minp.z + math.floor((divz+1)*divlen)
|
||||
-- Determine papyrus amount from perlin noise
|
||||
local papyrus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 45 - 20)
|
||||
-- Find random positions for papyrus based on this random
|
||||
local pr = PseudoRandom(seed+1)
|
||||
for i=0,papyrus_amount do
|
||||
local x = pr:next(x0, x1)
|
||||
local z = pr:next(z0, z1)
|
||||
if minetest.env:get_node({x=x,y=1,z=z}).name == "default:dirt_with_grass" and
|
||||
minetest.env:find_node_near({x=x,y=1,z=z}, 1, "default:water_source") then
|
||||
default.make_papyrus({x=x,y=2,z=z}, pr:next(2, 4))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Generate cactuses
|
||||
local perlin1 = minetest.env:get_perlin(230, 3, 0.6, 100)
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 16
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0,divs-1 do
|
||||
for divz=0,divs-1 do
|
||||
local x0 = minp.x + math.floor((divx+0)*divlen)
|
||||
local z0 = minp.z + math.floor((divz+0)*divlen)
|
||||
local x1 = minp.x + math.floor((divx+1)*divlen)
|
||||
local z1 = minp.z + math.floor((divz+1)*divlen)
|
||||
-- Determine cactus amount from perlin noise
|
||||
local cactus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 6 - 3)
|
||||
-- Find random positions for cactus based on this random
|
||||
local pr = PseudoRandom(seed+1)
|
||||
for i=0,cactus_amount do
|
||||
local x = pr:next(x0, x1)
|
||||
local z = pr:next(z0, z1)
|
||||
-- Find ground level (0...15)
|
||||
local ground_y = nil
|
||||
for y=30,0,-1 do
|
||||
if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then
|
||||
ground_y = y
|
||||
break
|
||||
end
|
||||
end
|
||||
-- If desert sand, make cactus
|
||||
if ground_y and minetest.env:get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then
|
||||
default.make_cactus({x=x,y=ground_y+1,z=z}, pr:next(3, 4))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Generate dry shrubs
|
||||
local perlin1 = minetest.env:get_perlin(329, 3, 0.6, 100)
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 16
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0,divs-1 do
|
||||
for divz=0,divs-1 do
|
||||
local x0 = minp.x + math.floor((divx+0)*divlen)
|
||||
local z0 = minp.z + math.floor((divz+0)*divlen)
|
||||
local x1 = minp.x + math.floor((divx+1)*divlen)
|
||||
local z1 = minp.z + math.floor((divz+1)*divlen)
|
||||
-- Determine cactus amount from perlin noise
|
||||
local cactus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 5 + 0)
|
||||
-- Find random positions for cactus based on this random
|
||||
local pr = PseudoRandom(seed+1)
|
||||
for i=0,cactus_amount do
|
||||
local x = pr:next(x0, x1)
|
||||
local z = pr:next(z0, z1)
|
||||
-- Find ground level (0...15)
|
||||
local ground_y = nil
|
||||
for y=30,0,-1 do
|
||||
if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then
|
||||
ground_y = y
|
||||
break
|
||||
end
|
||||
end
|
||||
-- If desert sand, make cactus
|
||||
if ground_y and minetest.env:get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then
|
||||
minetest.env:set_node({x=x,y=ground_y+1,z=z}, {name="default:dry_shrub"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Generate nyan cats
|
||||
generate_nyancats(seed, minp, maxp)
|
||||
end)
|
||||
]]--
|
|
@ -0,0 +1,277 @@
|
|||
-- minetest/default/mapgen.lua
|
||||
|
||||
--
|
||||
-- Aliases for map generator outputs
|
||||
--
|
||||
|
||||
minetest.register_alias("mapgen_air", "air")
|
||||
minetest.register_alias("mapgen_stone", "air")
|
||||
minetest.register_alias("mapgen_tree", "air")
|
||||
minetest.register_alias("mapgen_leaves", "air")
|
||||
minetest.register_alias("mapgen_apple", "air")
|
||||
minetest.register_alias("mapgen_water_source", "air")
|
||||
minetest.register_alias("mapgen_dirt", "air")
|
||||
minetest.register_alias("mapgen_sand", "air")
|
||||
minetest.register_alias("mapgen_gravel", "air")
|
||||
minetest.register_alias("mapgen_clay", "air")
|
||||
minetest.register_alias("mapgen_lava_source", "air")
|
||||
minetest.register_alias("mapgen_cobble", "air")
|
||||
minetest.register_alias("mapgen_mossycobble", "air")
|
||||
minetest.register_alias("mapgen_dirt_with_grass", "air")
|
||||
minetest.register_alias("mapgen_junglegrass", "air")
|
||||
minetest.register_alias("mapgen_stone_with_coal", "air")
|
||||
minetest.register_alias("mapgen_stone_with_iron", "air")
|
||||
minetest.register_alias("mapgen_mese", "air")
|
||||
minetest.register_alias("mapgen_desert_sand", "air")
|
||||
minetest.register_alias("mapgen_desert_stone", "air")
|
||||
|
||||
--
|
||||
-- Ore generation
|
||||
--
|
||||
--[[
|
||||
local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, chunk_size, ore_per_chunk, height_min, height_max)
|
||||
if maxp.y < height_min or minp.y > height_max then
|
||||
return
|
||||
end
|
||||
local y_min = math.max(minp.y, height_min)
|
||||
local y_max = math.min(maxp.y, height_max)
|
||||
local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
|
||||
local pr = PseudoRandom(seed)
|
||||
local num_chunks = math.floor(chunks_per_volume * volume)
|
||||
local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
|
||||
--print("generate_ore num_chunks: "..dump(num_chunks))
|
||||
for i=1,num_chunks do
|
||||
local y0 = pr:next(y_min, y_max-chunk_size+1)
|
||||
if y0 >= height_min and y0 <= height_max then
|
||||
local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
|
||||
local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
|
||||
local p0 = {x=x0, y=y0, z=z0}
|
||||
for x1=0,chunk_size-1 do
|
||||
for y1=0,chunk_size-1 do
|
||||
for z1=0,chunk_size-1 do
|
||||
if pr:next(1,inverse_chance) == 1 then
|
||||
local x2 = x0+x1
|
||||
local y2 = y0+y1
|
||||
local z2 = z0+z1
|
||||
local p2 = {x=x2, y=y2, z=z2}
|
||||
if minetest.env:get_node(p2).name == wherein then
|
||||
minetest.env:set_node(p2, {name=name})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--print("generate_ore done")
|
||||
end
|
||||
|
||||
function default.make_papyrus(pos, size)
|
||||
for y=0,size-1 do
|
||||
local p = {x=pos.x, y=pos.y+y, z=pos.z}
|
||||
minetest.env:set_node(p, {name="default:papyrus"})
|
||||
end
|
||||
end
|
||||
|
||||
function default.make_cactus(pos, size)
|
||||
for y=0,size-1 do
|
||||
local p = {x=pos.x, y=pos.y+y, z=pos.z}
|
||||
minetest.env:set_node(p, {name="default:cactus"})
|
||||
end
|
||||
end
|
||||
|
||||
-- facedir: 0/1/2/3 (head node facedir value)
|
||||
-- length: length of rainbow tail
|
||||
]]--
|
||||
function default.make_nyancat(pos, facedir, length)
|
||||
local tailvec = {x=0, y=0, z=0}
|
||||
if facedir == 0 then
|
||||
tailvec.z = 1
|
||||
elseif facedir == 1 then
|
||||
tailvec.x = 1
|
||||
elseif facedir == 2 then
|
||||
tailvec.z = -1
|
||||
elseif facedir == 3 then
|
||||
tailvec.x = -1
|
||||
else
|
||||
print("default.make_nyancat(): Invalid facedir: "+dump(facedir))
|
||||
facedir = 0
|
||||
tailvec.z = 1
|
||||
end
|
||||
local p = {x=pos.x, y=pos.y, z=pos.z}
|
||||
minetest.env:set_node(p, {name="default:nyancat", param2=facedir})
|
||||
for i=1,length do
|
||||
p.x = p.x + tailvec.x
|
||||
p.z = p.z + tailvec.z
|
||||
minetest.env:set_node(p, {name="default:nyancat_rainbow"})
|
||||
end
|
||||
end
|
||||
|
||||
function generate_nyancats(seed, minp, maxp)
|
||||
local height_min = -31000
|
||||
local height_max = -32
|
||||
if maxp.y < height_min or minp.y > height_max then
|
||||
return
|
||||
end
|
||||
local y_min = math.max(minp.y, height_min)
|
||||
local y_max = math.min(maxp.y, height_max)
|
||||
local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
|
||||
local pr = PseudoRandom(seed + 9324342)
|
||||
local max_num_nyancats = math.floor(volume / (16*16*16))
|
||||
for i=1,max_num_nyancats do
|
||||
if pr:next(0, 1000) == 0 then
|
||||
local x0 = pr:next(minp.x, maxp.x)
|
||||
local y0 = pr:next(minp.y, maxp.y)
|
||||
local z0 = pr:next(minp.z, maxp.z)
|
||||
local p0 = {x=x0, y=y0, z=z0}
|
||||
default.make_nyancat(p0, pr:next(0,3), pr:next(3,15))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
--[[
|
||||
-- Generate regular ores
|
||||
generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed+0, 1/8/8/8, 3, 8, -31000, 64)
|
||||
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+1, 1/12/12/12, 2, 3, -15, 2)
|
||||
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+2, 1/9/9/9, 3, 5, -63, -16)
|
||||
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+3, 1/7/7/7, 3, 5, -31000, -64)
|
||||
generate_ore("default:mese", "default:stone", minp, maxp, seed+4, 1/16/16/16, 2, 3, -127, -64)
|
||||
generate_ore("default:mese", "default:stone", minp, maxp, seed+5, 1/9/9/9, 3, 5, -31000,-128)
|
||||
|
||||
generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed+7, 1/24/24/24, 6,27, -31000, 0)
|
||||
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+6, 1/24/24/24, 6,27, -31000, -64)
|
||||
|
||||
if maxp.y >= 2 and minp.y <= 0 then
|
||||
-- Generate clay
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 4
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0+1,divs-1-1 do
|
||||
for divz=0+1,divs-1-1 do
|
||||
local cx = minp.x + math.floor((divx+0.5)*divlen)
|
||||
local cz = minp.z + math.floor((divz+0.5)*divlen)
|
||||
if minetest.env:get_node({x=cx,y=1,z=cz}).name == "default:water_source" and
|
||||
minetest.env:get_node({x=cx,y=0,z=cz}).name == "default:sand" then
|
||||
local is_shallow = true
|
||||
local num_water_around = 0
|
||||
if minetest.env:get_node({x=cx-divlen*2,y=1,z=cz+0}).name == "default:water_source" then
|
||||
num_water_around = num_water_around + 1 end
|
||||
if minetest.env:get_node({x=cx+divlen*2,y=1,z=cz+0}).name == "default:water_source" then
|
||||
num_water_around = num_water_around + 1 end
|
||||
if minetest.env:get_node({x=cx+0,y=1,z=cz-divlen*2}).name == "default:water_source" then
|
||||
num_water_around = num_water_around + 1 end
|
||||
if minetest.env:get_node({x=cx+0,y=1,z=cz+divlen*2}).name == "default:water_source" then
|
||||
num_water_around = num_water_around + 1 end
|
||||
if num_water_around >= 2 then
|
||||
is_shallow = false
|
||||
end
|
||||
if is_shallow then
|
||||
for x1=-divlen,divlen do
|
||||
for z1=-divlen,divlen do
|
||||
if minetest.env:get_node({x=cx+x1,y=0,z=cz+z1}).name == "default:sand" then
|
||||
minetest.env:set_node({x=cx+x1,y=0,z=cz+z1}, {name="default:clay"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Generate papyrus
|
||||
local perlin1 = minetest.env:get_perlin(354, 3, 0.7, 100)
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 8
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0,divs-1 do
|
||||
for divz=0,divs-1 do
|
||||
local x0 = minp.x + math.floor((divx+0)*divlen)
|
||||
local z0 = minp.z + math.floor((divz+0)*divlen)
|
||||
local x1 = minp.x + math.floor((divx+1)*divlen)
|
||||
local z1 = minp.z + math.floor((divz+1)*divlen)
|
||||
-- Determine papyrus amount from perlin noise
|
||||
local papyrus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 45 - 20)
|
||||
-- Find random positions for papyrus based on this random
|
||||
local pr = PseudoRandom(seed+1)
|
||||
for i=0,papyrus_amount do
|
||||
local x = pr:next(x0, x1)
|
||||
local z = pr:next(z0, z1)
|
||||
if minetest.env:get_node({x=x,y=1,z=z}).name == "default:dirt_with_grass" and
|
||||
minetest.env:find_node_near({x=x,y=1,z=z}, 1, "default:water_source") then
|
||||
default.make_papyrus({x=x,y=2,z=z}, pr:next(2, 4))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Generate cactuses
|
||||
local perlin1 = minetest.env:get_perlin(230, 3, 0.6, 100)
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 16
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0,divs-1 do
|
||||
for divz=0,divs-1 do
|
||||
local x0 = minp.x + math.floor((divx+0)*divlen)
|
||||
local z0 = minp.z + math.floor((divz+0)*divlen)
|
||||
local x1 = minp.x + math.floor((divx+1)*divlen)
|
||||
local z1 = minp.z + math.floor((divz+1)*divlen)
|
||||
-- Determine cactus amount from perlin noise
|
||||
local cactus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 6 - 3)
|
||||
-- Find random positions for cactus based on this random
|
||||
local pr = PseudoRandom(seed+1)
|
||||
for i=0,cactus_amount do
|
||||
local x = pr:next(x0, x1)
|
||||
local z = pr:next(z0, z1)
|
||||
-- Find ground level (0...15)
|
||||
local ground_y = nil
|
||||
for y=30,0,-1 do
|
||||
if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then
|
||||
ground_y = y
|
||||
break
|
||||
end
|
||||
end
|
||||
-- If desert sand, make cactus
|
||||
if ground_y and minetest.env:get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then
|
||||
default.make_cactus({x=x,y=ground_y+1,z=z}, pr:next(3, 4))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Generate dry shrubs
|
||||
local perlin1 = minetest.env:get_perlin(329, 3, 0.6, 100)
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 16
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0,divs-1 do
|
||||
for divz=0,divs-1 do
|
||||
local x0 = minp.x + math.floor((divx+0)*divlen)
|
||||
local z0 = minp.z + math.floor((divz+0)*divlen)
|
||||
local x1 = minp.x + math.floor((divx+1)*divlen)
|
||||
local z1 = minp.z + math.floor((divz+1)*divlen)
|
||||
-- Determine cactus amount from perlin noise
|
||||
local cactus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 5 + 0)
|
||||
-- Find random positions for cactus based on this random
|
||||
local pr = PseudoRandom(seed+1)
|
||||
for i=0,cactus_amount do
|
||||
local x = pr:next(x0, x1)
|
||||
local z = pr:next(z0, z1)
|
||||
-- Find ground level (0...15)
|
||||
local ground_y = nil
|
||||
for y=30,0,-1 do
|
||||
if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then
|
||||
ground_y = y
|
||||
break
|
||||
end
|
||||
end
|
||||
-- If desert sand, make cactus
|
||||
if ground_y and minetest.env:get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then
|
||||
minetest.env:set_node({x=x,y=ground_y+1,z=z}, {name="default:dry_shrub"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
]]--
|
||||
-- Generate nyan cats
|
||||
generate_nyancats(seed, minp, maxp)
|
||||
end)
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
-- this goes in builtin/misc_register.lua
|
||||
local function is_node_owner(meta, player)
|
||||
if meta:get_string("owner") == '' then
|
||||
meta:set_string("owner", player:get_player_name())
|
||||
elseif meta:get_string("owner") ~= player:get_player_name() then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
local can_dig = function(pos,player)
|
||||
meta = minetest.env:get_meta(pos)
|
||||
return is_node_owner(meta, player)
|
||||
endi
|
||||
|
||||
-- replace the default function for this one in builtin/misc_register.lua
|
||||
function minetest.register_node(name, nodedef)
|
||||
nodedef.type = "node"
|
||||
if not nodedef.can_dig then nodedef.can_dig = can_dig end
|
||||
minetest.register_item(name, nodedef)
|
||||
end
|
||||
|
||||
-- this can go in /default/init.lua or any mod folder
|
||||
minetest.register_on_placenode(function(p, node, placer)
|
||||
local meta = minetest.env:get_meta(p)
|
||||
local player = placer:get_player_name()
|
||||
meta:set_string("owner",player)
|
||||
end)
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
-- this goes in builtin/misc_register.lua
|
||||
local function is_node_owner(meta, player)
|
||||
if meta:get_string("owner") == '' then
|
||||
meta:set_string("owner", player:get_player_name())
|
||||
elseif meta:get_string("owner") ~= player:get_player_name() then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
local can_dig = function(pos,player)
|
||||
meta = minetest.env:get_meta(pos)
|
||||
return is_node_owner(meta, player)
|
||||
end
|
||||
|
||||
-- replace the default function for this one in builtin/misc_register.lua
|
||||
function minetest.register_node(name, nodedef)
|
||||
nodedef.type = "node"
|
||||
if not nodedef.can_dig then nodedef.can_dig = can_dig end
|
||||
minetest.register_item(name, nodedef)
|
||||
end
|
||||
|
||||
-- this can go in /default/init.lua or any mod folder
|
||||
minetest.register_on_placenode(function(p, node, placer)
|
||||
local meta = minetest.env:get_meta(p)
|
||||
local player = placer:get_player_name()
|
||||
meta:set_string("owner",player)
|
||||
end)
|
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 203 B |
After Width: | Height: | Size: 292 B |
After Width: | Height: | Size: 597 B |
After Width: | Height: | Size: 604 B |
After Width: | Height: | Size: 763 B |
After Width: | Height: | Size: 682 B |
After Width: | Height: | Size: 769 B |
After Width: | Height: | Size: 871 B |
After Width: | Height: | Size: 714 B |
After Width: | Height: | Size: 628 B |
After Width: | Height: | Size: 613 B |
After Width: | Height: | Size: 249 B |
After Width: | Height: | Size: 210 B |
After Width: | Height: | Size: 118 B |
After Width: | Height: | Size: 933 B |
After Width: | Height: | Size: 744 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 517 B |
After Width: | Height: | Size: 888 B |
After Width: | Height: | Size: 450 B |
After Width: | Height: | Size: 539 B |
After Width: | Height: | Size: 731 B |
After Width: | Height: | Size: 313 B |
After Width: | Height: | Size: 865 B |
After Width: | Height: | Size: 651 B |
After Width: | Height: | Size: 826 B |
After Width: | Height: | Size: 731 B |
After Width: | Height: | Size: 731 B |
After Width: | Height: | Size: 978 B |
After Width: | Height: | Size: 794 B |
After Width: | Height: | Size: 856 B |
After Width: | Height: | Size: 925 B |
After Width: | Height: | Size: 591 B |
After Width: | Height: | Size: 936 B |
After Width: | Height: | Size: 672 B |
After Width: | Height: | Size: 751 B |
After Width: | Height: | Size: 865 B |