2016-09-10 14:43:44 +02:00
|
|
|
local load_time_start = minetest.get_us_time()
|
|
|
|
|
2015-12-06 11:51:37 +01:00
|
|
|
|
2013-08-15 15:24:35 +02:00
|
|
|
NYANLAND_HEIGHT=30688
|
|
|
|
NYANCAT_PROP=1
|
|
|
|
NYANLAND_TREESIZE=2
|
2014-10-02 16:28:02 +02:00
|
|
|
local info = minetest.is_singleplayer()
|
2013-08-15 15:24:35 +02:00
|
|
|
|
|
|
|
local nyanland={}
|
|
|
|
|
2016-09-09 09:42:25 +02:00
|
|
|
minetest.register_craft({
|
|
|
|
output = "nyanland:mese_shrub_block",
|
|
|
|
recipe = {
|
|
|
|
{"nyanland:mese_shrub", "nyanland:mese_shrub", "nyanland:mese_shrub"},
|
|
|
|
{"nyanland:mese_shrub", "nyanland:mese_shrub", "nyanland:mese_shrub"},
|
|
|
|
{"nyanland:mese_shrub", "nyanland:mese_shrub", "nyanland:mese_shrub"},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2013-08-15 15:24:35 +02:00
|
|
|
--Cloudstone
|
2014-07-15 11:40:34 +02:00
|
|
|
local cloudstone_sounds = {
|
|
|
|
dug = {name="default_dug_node", gain=0.25},
|
|
|
|
place = {name="default_place_node_hard", gain=0.1},
|
|
|
|
footstep = {name="nyanland_cloud_footstep", gain=0.05}
|
|
|
|
}
|
|
|
|
|
2013-08-15 15:24:35 +02:00
|
|
|
minetest.register_node("nyanland:cloudstone", {
|
2013-08-24 12:36:41 +02:00
|
|
|
tiles = {"nyanland_cloudstone.png"},
|
2013-08-15 15:26:48 +02:00
|
|
|
use_texture_alpha = true,
|
|
|
|
sunlight_propagates = true,
|
2013-08-15 15:24:35 +02:00
|
|
|
light_source = 10,
|
2015-07-25 17:31:55 +02:00
|
|
|
groups = {dig_immediate = 3, not_in_creative_inventory=1},
|
2014-07-15 11:40:34 +02:00
|
|
|
sounds = cloudstone_sounds
|
2013-08-15 15:24:35 +02:00
|
|
|
})
|
|
|
|
|
2013-08-15 15:26:48 +02:00
|
|
|
minetest.register_node("nyanland:cloudstone_var", {
|
2013-08-24 12:36:41 +02:00
|
|
|
tiles = {"nyanland_cloudstone_var.png", "nyanland_cloudstone_var.png", "nyanland_cloudstone.png"},
|
2013-08-15 15:26:48 +02:00
|
|
|
use_texture_alpha = true,
|
|
|
|
sunlight_propagates = true,
|
|
|
|
drop = '',
|
|
|
|
light_source = 10,
|
2015-07-25 17:31:55 +02:00
|
|
|
groups = {dig_immediate = 3, not_in_creative_inventory=1},
|
2014-07-15 11:40:34 +02:00
|
|
|
sounds = cloudstone_sounds
|
2013-08-15 15:26:48 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
minetest.register_node("nyanland:mesetree", {
|
|
|
|
description = "Mese Tree",
|
|
|
|
tiles = {"nyanland_mesetree_top.png", "nyanland_mesetree_top.png", "nyanland_mesetree.png"},
|
2015-07-25 17:31:55 +02:00
|
|
|
groups = {tree=1,cracky=1,level=2, not_in_creative_inventory=1},
|
2013-08-15 15:26:48 +02:00
|
|
|
sounds = default.node_sound_stone_defaults(),
|
|
|
|
})
|
|
|
|
|
2013-08-15 15:24:35 +02:00
|
|
|
minetest.register_node("nyanland:meseleaves", {
|
|
|
|
drawtype = "allfaces_optional",
|
2013-08-24 12:36:41 +02:00
|
|
|
tiles = {"nyanland_meseleaves.png"},
|
2013-08-15 15:24:35 +02:00
|
|
|
paramtype = "light",
|
|
|
|
furnace_burntime = 5,
|
2015-07-25 17:31:55 +02:00
|
|
|
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
2013-08-15 15:26:48 +02:00
|
|
|
-- groups = {snappy=3, leafdecay=3, flammable=2},
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("nyanland:mese_shrub", {
|
|
|
|
description = "Mese Shrub",
|
|
|
|
drawtype = "plantlike",
|
|
|
|
tiles = {"nyanland_mese_shrub.png"},
|
|
|
|
inventory_image = "nyanland_mese_shrub.png",
|
|
|
|
wield_image = "nyanland_mese_shrub.png",
|
|
|
|
paramtype = "light",
|
2014-06-14 16:41:51 +02:00
|
|
|
waving = 1,
|
2013-08-15 15:26:48 +02:00
|
|
|
walkable = false,
|
|
|
|
buildable_to = true,
|
2015-07-25 17:31:55 +02:00
|
|
|
groups = {snappy=3,flammable=3,attached_node=1, not_in_creative_inventory=1},
|
2013-08-15 15:26:48 +02:00
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("nyanland:mese_shrub_fruits", {
|
|
|
|
description = "Mese Shrub with fruits",
|
|
|
|
drawtype = "plantlike",
|
2016-06-18 16:03:49 +02:00
|
|
|
tiles = {"nyanland_mese_shrub.png^nyanland_mese_shrub_fruits.png"},
|
|
|
|
inventory_image = "nyanland_mese_shrub.png^nyanland_mese_shrub_fruits.png",
|
|
|
|
wield_image = "nyanland_mese_shrub.png^nyanland_mese_shrub_fruits.png",
|
2013-08-15 15:26:48 +02:00
|
|
|
paramtype = "light",
|
2014-06-14 16:41:51 +02:00
|
|
|
waving = 1,
|
2013-08-15 15:26:48 +02:00
|
|
|
walkable = false,
|
|
|
|
buildable_to = true,
|
2015-07-25 17:31:55 +02:00
|
|
|
groups = {snappy=3,flammable=3,attached_node=1, not_in_creative_inventory=1},
|
2013-08-15 15:26:48 +02:00
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
|
|
|
|
},
|
2013-08-15 15:24:35 +02:00
|
|
|
})
|
|
|
|
|
2016-09-09 09:42:25 +02:00
|
|
|
minetest.register_node("nyanland:mese_shrub_block", {
|
|
|
|
description = "Mese Shrub Block",
|
|
|
|
tiles = {"nyanland_mese_shrub_block.png"},
|
|
|
|
groups = {snappy = 3, flammable = 2, level = 2, not_in_creative_inventory = 1},
|
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
})
|
|
|
|
|
2013-08-15 15:24:35 +02:00
|
|
|
-- Clonestone
|
2013-09-21 22:29:54 +02:00
|
|
|
local function clone_node(pos)
|
2015-05-20 21:02:04 +02:00
|
|
|
pos.y = pos.y+1
|
|
|
|
local nd = minetest.get_node(pos)
|
2015-05-16 23:44:52 +02:00
|
|
|
local node_over = nd.name
|
2013-09-21 22:29:54 +02:00
|
|
|
if node_over ~= "air"
|
2015-05-16 23:44:52 +02:00
|
|
|
and node_over ~= "ignore"
|
|
|
|
and node_over ~= "nyanland:clonestone"
|
|
|
|
and minetest.registered_nodes[node_over] then
|
2015-05-20 21:02:04 +02:00
|
|
|
local metacontent = minetest.get_meta(pos):to_table()
|
|
|
|
pos.y = pos.y-1
|
2015-05-16 23:44:52 +02:00
|
|
|
minetest.add_node(pos, nd)
|
2015-05-20 21:02:04 +02:00
|
|
|
minetest.get_meta(pos):from_table(metacontent)
|
2013-09-21 22:29:54 +02:00
|
|
|
end
|
|
|
|
-- nodeupdate(pos)
|
|
|
|
end
|
|
|
|
|
2013-08-15 15:24:35 +02:00
|
|
|
minetest.register_node("nyanland:clonestone", {
|
2016-02-21 11:39:09 +01:00
|
|
|
description = "clonestone",
|
2013-08-24 12:36:41 +02:00
|
|
|
tiles = {"nyanland_clonestone.png"},
|
2013-08-15 15:24:35 +02:00
|
|
|
furnace_burntime = 100,
|
2015-07-25 17:31:55 +02:00
|
|
|
groups = {cracky = 1, not_in_creative_inventory=1},
|
2015-05-20 21:02:04 +02:00
|
|
|
on_construct = clone_node,
|
2013-08-15 15:24:35 +02:00
|
|
|
})
|
|
|
|
|
2013-08-15 15:26:48 +02:00
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"nyanland:clonestone"},
|
2013-09-21 22:29:54 +02:00
|
|
|
interval = 5,
|
2013-08-15 15:24:35 +02:00
|
|
|
chance = 1,
|
2015-12-06 11:00:50 +01:00
|
|
|
catch_up = false,
|
2013-08-15 15:26:48 +02:00
|
|
|
action = function(pos)
|
2013-09-21 22:29:54 +02:00
|
|
|
clone_node(pos)
|
2013-08-15 15:24:35 +02:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Healstone
|
|
|
|
minetest.register_node("nyanland:healstone", {
|
2016-02-21 11:39:09 +01:00
|
|
|
description = "nyanland healstone",
|
2013-08-24 12:36:41 +02:00
|
|
|
tiles = {"nyanland_healstone.png"},
|
2013-08-15 15:24:35 +02:00
|
|
|
furnace_burntime = 100,
|
2015-07-25 17:31:55 +02:00
|
|
|
groups = {cracky = 1, not_in_creative_inventory=1},
|
2013-08-15 15:24:35 +02:00
|
|
|
})
|
|
|
|
|
2015-05-16 23:44:52 +02:00
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"nyanland:healstone"},
|
2013-08-15 15:24:35 +02:00
|
|
|
interval = 1.0,
|
|
|
|
chance = 1,
|
2013-08-15 15:26:48 +02:00
|
|
|
action = function(pos)
|
2015-05-16 23:44:52 +02:00
|
|
|
for _, obj in pairs(minetest.get_objects_inside_radius(pos, 3)) do
|
2013-08-15 15:26:48 +02:00
|
|
|
local hp = obj:get_hp()
|
|
|
|
if hp >= 20 then return end
|
|
|
|
obj:set_hp(hp+2)
|
2013-08-15 15:24:35 +02:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
2013-08-15 15:26:48 +02:00
|
|
|
|
2016-08-26 19:36:36 +02:00
|
|
|
-- Weierstrass function code from https://github.com/slemonide/gen
|
|
|
|
local function do_ws_func(a, x)
|
|
|
|
local n = math.pi * x / 16000
|
2015-05-17 01:03:32 +02:00
|
|
|
local y = 0
|
2016-08-26 19:36:36 +02:00
|
|
|
for k = 1,1000 do
|
|
|
|
y = y + math.sin(k^a * n)/(k^a)
|
2015-05-17 01:03:32 +02:00
|
|
|
end
|
2016-08-26 19:36:36 +02:00
|
|
|
return 1000*y/math.pi
|
2015-05-17 01:03:32 +02:00
|
|
|
end
|
|
|
|
|
2016-08-26 19:36:36 +02:00
|
|
|
-- caching function
|
|
|
|
local ws_values = {}
|
|
|
|
local function get_ws_value(a, x)
|
|
|
|
local v = ws_values[a]
|
2015-09-03 20:59:09 +02:00
|
|
|
if v then
|
2016-08-26 19:36:36 +02:00
|
|
|
v = v[x]
|
|
|
|
if v then
|
2015-09-03 20:59:09 +02:00
|
|
|
return v
|
2016-08-26 19:36:36 +02:00
|
|
|
end
|
|
|
|
else
|
|
|
|
ws_values[a] = {}
|
|
|
|
-- weak table, see https://www.lua.org/pil/17.1.html
|
|
|
|
setmetatable(ws_values[a], {__mode = "kv"})
|
2015-09-03 20:59:09 +02:00
|
|
|
end
|
2016-08-26 19:36:36 +02:00
|
|
|
v = do_ws_func(a, x)
|
|
|
|
ws_values[a][x] = v
|
2015-09-03 20:59:09 +02:00
|
|
|
return v
|
2015-05-17 01:03:32 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2015-05-16 23:44:52 +02:00
|
|
|
local generate_mesetree
|
|
|
|
|
2016-07-01 12:26:48 +02:00
|
|
|
local c_cloudstone = minetest.get_content_id"nyanland:cloudstone"
|
|
|
|
local c_cloudstone2 = minetest.get_content_id"nyanland:cloudstone_var"
|
|
|
|
local c_clonestone = minetest.get_content_id"nyanland:clonestone"
|
|
|
|
local c_mese_shrub = minetest.get_content_id"nyanland:mese_shrub"
|
|
|
|
local c_mese_shrub_fruits = minetest.get_content_id"nyanland:mese_shrub_fruits"
|
|
|
|
local c_cloud = minetest.get_content_id"default:cloud"
|
|
|
|
local c_mese = minetest.get_content_id"default:mese"
|
|
|
|
local c_ice = minetest.get_content_id"default:ice"
|
2013-08-15 15:26:48 +02:00
|
|
|
|
|
|
|
local ypse = NYANLAND_HEIGHT
|
|
|
|
|
2014-10-02 16:28:02 +02:00
|
|
|
local hole = {
|
|
|
|
seed = 13,
|
|
|
|
octaves = 3,
|
|
|
|
persist = 0.5,
|
|
|
|
spread = {x=500, y=500, z=500},
|
|
|
|
scale = 1,
|
|
|
|
offset = 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
local height = {
|
|
|
|
seed = 133,
|
|
|
|
octaves = 3,
|
|
|
|
persist = 0.5,
|
|
|
|
spread = {x=100, y=100, z=100},
|
|
|
|
scale = 1,
|
|
|
|
offset = 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-15 15:26:48 +02:00
|
|
|
minetest.register_on_generated(function(minp, maxp, seed)
|
|
|
|
if (minp.y >= ypse+10 or maxp.y <= ypse-10) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2015-12-06 11:00:50 +01:00
|
|
|
local t1
|
2013-08-15 15:26:48 +02:00
|
|
|
if info then
|
|
|
|
t1 = os.clock()
|
|
|
|
local geninfo = "[nyanland] generates: x=["..minp.x.."; "..maxp.x.."]; y=["..minp.y.."; "..maxp.y.."]; z=["..minp.z.."; "..maxp.z.."]"
|
2014-12-28 22:01:25 +01:00
|
|
|
minetest.log("info", geninfo)
|
2013-08-15 15:26:48 +02:00
|
|
|
minetest.chat_send_all(geninfo)
|
|
|
|
end
|
|
|
|
local pr = PseudoRandom(seed+112)
|
2016-07-01 12:26:48 +02:00
|
|
|
local vm, emin, emax = minetest.get_mapgen_object"voxelmanip"
|
2013-08-15 15:26:48 +02:00
|
|
|
local data = vm:get_data()
|
|
|
|
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
|
|
|
|
2014-10-02 16:28:02 +02:00
|
|
|
local side_length = maxp.x - minp.x + 1
|
|
|
|
local map_lengths_xyz = {x=side_length, y=side_length, z=side_length}
|
|
|
|
|
2016-07-01 12:26:48 +02:00
|
|
|
local pmap1 = minetest.get_perlin_map(hole, map_lengths_xyz):get2dMap_flat{x=minp.x, y=minp.z}
|
|
|
|
local pmap2 = minetest.get_perlin_map(height, map_lengths_xyz):get2dMap_flat{x=minp.x, y=minp.z}
|
2013-08-15 15:26:48 +02:00
|
|
|
|
|
|
|
local num = 1
|
|
|
|
local tab = {}
|
|
|
|
|
2014-10-02 16:28:02 +02:00
|
|
|
local count = 0
|
2015-05-16 23:44:52 +02:00
|
|
|
for z=minp.z, maxp.z do
|
|
|
|
for x=minp.x, maxp.x do
|
2014-10-02 16:28:02 +02:00
|
|
|
count = count+1
|
|
|
|
local test2 = math.abs(pmap2[count])
|
2013-11-23 12:41:35 +01:00
|
|
|
if test2 >= 0.2 then
|
2015-05-16 23:44:52 +02:00
|
|
|
local y = ypse + math.floor(pmap1[count]*3+0.5)
|
|
|
|
if y <= maxp.y
|
|
|
|
and y >= minp.y then
|
2016-08-26 19:36:36 +02:00
|
|
|
local depth = math.floor(((get_ws_value(3, x)+get_ws_value(5, z))%14)*math.min((test2-0.2)*25/4, 1)+0.5)
|
2015-05-17 01:03:32 +02:00
|
|
|
if depth ~= 0 then
|
2016-08-26 19:36:36 +02:00
|
|
|
local sel = math.floor(get_ws_value(2, x)+get_ws_value(2, z)+0.5)%10
|
2015-05-17 01:03:32 +02:00
|
|
|
local p = area:index(x, y-depth, z)
|
|
|
|
if sel <= 5 then
|
|
|
|
data[p] = c_cloudstone
|
|
|
|
elseif sel == 6 then
|
|
|
|
data[p] = c_ice
|
|
|
|
elseif sel == 7 then
|
|
|
|
data[p] = c_mese
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local p = area:index(x, y, z)
|
2015-05-16 23:44:52 +02:00
|
|
|
local tree_rn = pr:next(1, 1000)
|
|
|
|
if tree_rn == 1 then
|
|
|
|
tab[num] = {x=x, y=y+1, z=z}
|
|
|
|
num = num+1
|
2015-05-17 01:03:32 +02:00
|
|
|
data[p] = c_cloud
|
2015-05-16 23:44:52 +02:00
|
|
|
elseif pr:next(1, 5000) == 1 then
|
2015-05-17 01:03:32 +02:00
|
|
|
data[p] = c_clonestone
|
2015-05-16 23:44:52 +02:00
|
|
|
elseif pr:next(1, 300) == 1 then
|
2015-05-17 01:03:32 +02:00
|
|
|
data[p] = c_cloudstone2
|
2013-11-23 12:41:35 +01:00
|
|
|
else
|
2015-05-17 01:03:32 +02:00
|
|
|
data[p] = c_cloudstone
|
2015-05-16 23:44:52 +02:00
|
|
|
end
|
|
|
|
if tree_rn == 4 then
|
2015-05-17 01:03:32 +02:00
|
|
|
local p = area:index(x, y+1, z)
|
2015-05-16 23:44:52 +02:00
|
|
|
if pr:next(1, 1000) == 2 then
|
2015-05-17 01:03:32 +02:00
|
|
|
data[p] = c_mese_shrub_fruits
|
2015-05-16 23:44:52 +02:00
|
|
|
else
|
2015-05-17 01:03:32 +02:00
|
|
|
data[p] = c_mese_shrub
|
2015-05-16 23:44:52 +02:00
|
|
|
end
|
2013-11-23 12:41:35 +01:00
|
|
|
end
|
2013-08-15 15:24:35 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-08-15 15:26:48 +02:00
|
|
|
end
|
2013-08-15 15:24:35 +02:00
|
|
|
|
2015-05-16 23:44:52 +02:00
|
|
|
for _,p in pairs(tab) do
|
|
|
|
generate_mesetree(p, data, area, pr)
|
|
|
|
end
|
|
|
|
|
2013-08-15 15:26:48 +02:00
|
|
|
vm:set_data(data)
|
2015-05-16 23:44:52 +02:00
|
|
|
vm:set_lighting({day=0, night=0})
|
|
|
|
vm:calc_lighting()
|
|
|
|
--vm:update_liquids()
|
2013-08-15 15:26:48 +02:00
|
|
|
vm:write_to_map()
|
|
|
|
|
|
|
|
if math.random(NYANCAT_PROP)==1 then
|
|
|
|
local nyan_headpos={}
|
2015-05-29 12:09:18 +02:00
|
|
|
nyan_headpos={x=minp.x+pr:next(1, 80), y=ypse+pr:next(1, 20)+10, z=minp.z+pr:next(1, 80)}
|
2013-08-15 15:26:48 +02:00
|
|
|
nyanland:add_nyancat(nyan_headpos, minp)
|
|
|
|
end
|
|
|
|
if info then
|
|
|
|
local geninfo = string.format("[nyanland] done after: %.2fs", os.clock() - t1)
|
2014-12-28 22:01:25 +01:00
|
|
|
minetest.log("info", geninfo)
|
2013-08-15 15:26:48 +02:00
|
|
|
minetest.chat_send_all(geninfo)
|
|
|
|
end
|
2013-08-15 15:24:35 +02:00
|
|
|
end)
|
|
|
|
|
2015-05-20 21:02:04 +02:00
|
|
|
function nyanland:add_nyancat(pos)
|
2016-07-18 16:45:11 +02:00
|
|
|
minetest.add_node(pos, {name="nyancat:nyancat"})
|
2015-05-20 21:02:04 +02:00
|
|
|
local length = math.random(4,15)
|
|
|
|
for _ = 1, length do
|
|
|
|
pos.z = pos.z+1
|
2016-07-18 16:45:11 +02:00
|
|
|
minetest.add_node(pos, {name="nyancat:nyancat_rainbow"})
|
2013-08-15 15:24:35 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-07-01 12:26:48 +02:00
|
|
|
local c_tree = minetest.get_content_id"nyanland:mesetree"
|
|
|
|
local c_hls = minetest.get_content_id"nyanland:healstone"
|
|
|
|
local c_apple = minetest.get_content_id"default:apple"
|
|
|
|
local c_leaves = minetest.get_content_id"nyanland:meseleaves"
|
|
|
|
local c_air = minetest.get_content_id"air"
|
|
|
|
local c_ignore = minetest.get_content_id"ignore"
|
2015-05-16 23:44:52 +02:00
|
|
|
|
|
|
|
local function mesetree(pos, tran, nodes, area, pr)
|
|
|
|
-- stem
|
|
|
|
local head_y = pos.y+4+tran
|
|
|
|
for y = pos.y, head_y do
|
2015-12-06 11:00:50 +01:00
|
|
|
local p = area:index(pos.x, y, pos.z)
|
2015-05-16 23:44:52 +02:00
|
|
|
if pr:next(1,200) == 1 then
|
|
|
|
nodes[p] = c_hls
|
2013-10-18 22:05:00 +02:00
|
|
|
else
|
2015-05-16 23:44:52 +02:00
|
|
|
nodes[p] = c_tree
|
2013-08-15 15:24:35 +02:00
|
|
|
end
|
|
|
|
end
|
2015-05-16 23:44:52 +02:00
|
|
|
-- head
|
|
|
|
local s = NYANLAND_TREESIZE
|
|
|
|
for x = -s, s do
|
|
|
|
for y = -s, s do
|
|
|
|
for z = -s, s do
|
|
|
|
if x*x + y*y + z*z <= s*s + s then
|
|
|
|
local p = area:index(pos.x+x, head_y+y, pos.z+z)
|
|
|
|
if nodes[p] == c_air
|
|
|
|
or nodes[p] == c_ignore then
|
2013-10-18 22:05:00 +02:00
|
|
|
if pr:next(1,5) ~= 1 then
|
2015-05-16 23:44:52 +02:00
|
|
|
nodes[p] = c_leaves
|
2013-10-18 22:05:00 +02:00
|
|
|
elseif pr:next(1,11) == 1 then
|
2015-05-16 23:44:52 +02:00
|
|
|
nodes[p] = c_apple
|
2013-08-15 15:26:48 +02:00
|
|
|
end
|
2015-05-29 12:09:18 +02:00
|
|
|
end
|
2013-08-15 15:24:35 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-05-16 23:44:52 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function generate_mesetree(pos, nodes, area, pr)
|
|
|
|
mesetree(pos, pr:next(1,2), nodes, area, pr)
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[function nyanland:grow_mesetree(pos)
|
|
|
|
local t1 = os.clock()
|
|
|
|
|
|
|
|
local manip = minetest.get_voxel_manip()
|
|
|
|
local vwidth = NYANLAND_TREESIZE
|
|
|
|
local vheight = 7+vwidth
|
|
|
|
local emerged_pos1, emerged_pos2 = manip:read_from_map({x=pos.x-vwidth, y=pos.y, z=pos.z-vwidth},
|
|
|
|
{x=pos.x+vwidth, y=pos.y+vheight, z=pos.z+vwidth})
|
|
|
|
local area = VoxelArea:new({MinEdge=emerged_pos1, MaxEdge=emerged_pos2})
|
|
|
|
local nodes = manip:get_data()
|
|
|
|
|
|
|
|
local pr = PseudoRandom(math.abs(pos.x+pos.y*3+pos.z*5))
|
|
|
|
|
|
|
|
mesetree(pos, pr:next(1,2), nodes, area, pr)
|
|
|
|
|
2013-08-15 15:26:48 +02:00
|
|
|
manip:set_data(nodes)
|
|
|
|
manip:write_to_map()
|
|
|
|
if info then
|
2014-12-28 22:01:25 +01:00
|
|
|
minetest.log("info", string.format("[nyanland] a mesetree grew at ("..pos.x.."|"..pos.y.."|"..pos.z..") after: %.2fs", os.clock() - t1))
|
2013-11-23 12:41:35 +01:00
|
|
|
t1 = os.clock()
|
|
|
|
end
|
2015-05-16 23:44:52 +02:00
|
|
|
manip:update_map() --calc shadows
|
|
|
|
if info then
|
|
|
|
minetest.log("info", string.format("[nyanland] map updated after: %.2fs", os.clock() - t1))
|
2013-08-15 15:26:48 +02:00
|
|
|
end
|
2015-05-16 23:44:52 +02:00
|
|
|
end]]
|
2013-08-15 15:24:35 +02:00
|
|
|
|
|
|
|
--MOVING NYAN CATS
|
2015-05-20 21:02:04 +02:00
|
|
|
minetest.register_abm({
|
2016-07-18 16:45:11 +02:00
|
|
|
nodenames = {"nyancat:nyancat"},
|
2015-12-06 15:35:57 +01:00
|
|
|
interval = 10,
|
|
|
|
chance = 100,
|
2015-12-06 11:51:37 +01:00
|
|
|
catch_up = false,
|
2015-03-13 19:51:42 +01:00
|
|
|
action = function(pos)
|
|
|
|
if pos.y > NYANLAND_HEIGHT then
|
2013-09-21 22:29:54 +02:00
|
|
|
minetest.remove_node(pos)
|
|
|
|
minetest.add_entity(pos, "nyanland:head_entity")
|
2015-05-20 21:02:04 +02:00
|
|
|
minetest.sound_play("nyanland_cat", {pos = pos, gain = 0.9, max_hear_distance = 35})
|
2013-08-15 15:24:35 +02:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_entity("nyanland:head_entity", {
|
2015-05-20 21:02:04 +02:00
|
|
|
physical = true,
|
|
|
|
lastpos = {x=0, y=0, z=0},
|
2016-07-28 08:02:06 +02:00
|
|
|
textures = {"nyancat_side.png", "nyancat_side.png", "nyancat_side.png",
|
|
|
|
"nyancat_side.png", "nyancat_back.png", "nyancat_front.png"},
|
2013-08-15 15:24:35 +02:00
|
|
|
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
|
|
|
visual = "cube",
|
2016-02-21 11:33:49 +01:00
|
|
|
visual_size = {x=1.001, y=1.001},
|
|
|
|
on_activate = function(self)
|
2016-07-01 12:26:48 +02:00
|
|
|
self.object:setvelocity{x=0, y=0, z=-2}
|
|
|
|
self.object:set_armor_groups{immortal=1}
|
2015-05-20 21:02:04 +02:00
|
|
|
self.lastpos = vector.round(self.object:getpos())
|
2015-12-06 11:51:37 +01:00
|
|
|
self.timer = math.random()*8-4
|
2013-08-15 15:24:35 +02:00
|
|
|
end,
|
|
|
|
|
2016-02-21 11:33:49 +01:00
|
|
|
on_punch = function(self)
|
|
|
|
local mesepos = self.object:getpos()
|
|
|
|
if math.random(10) == 1 then
|
|
|
|
minetest.sound_play("nyanland_cat", {pos = mesepos, gain = 0.9, max_hear_distance = 35})
|
|
|
|
end
|
|
|
|
mesepos.y = mesepos.y-1
|
2015-12-06 11:51:37 +01:00
|
|
|
spawn_falling_node(mesepos, {name = "default:mese_block"})
|
2013-08-15 15:24:35 +02:00
|
|
|
end,
|
|
|
|
|
|
|
|
on_step = function(self, dtime)
|
2015-05-20 21:02:04 +02:00
|
|
|
self.timer = self.timer+dtime
|
2015-05-29 12:09:18 +02:00
|
|
|
if self.timer >= 16 then
|
2016-07-18 16:45:11 +02:00
|
|
|
minetest.add_node(self.lastpos, {name="nyancat:nyancat"})
|
2013-08-15 15:24:35 +02:00
|
|
|
self.object:remove()
|
2013-08-15 15:26:48 +02:00
|
|
|
return
|
|
|
|
end
|
2016-02-21 11:33:49 +01:00
|
|
|
local finepos = self.object:getpos()
|
|
|
|
local pos = vector.round(finepos)
|
2015-05-20 21:02:04 +02:00
|
|
|
if vector.equals(self.lastpos, pos) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
self.lastpos = pos
|
2016-07-18 16:45:11 +02:00
|
|
|
if minetest.get_node(pos).name == "nyancat:nyancat_rainbow" then
|
2013-08-15 15:26:48 +02:00
|
|
|
self.object:remove()
|
|
|
|
return
|
|
|
|
end
|
2015-05-20 21:02:04 +02:00
|
|
|
local p = vector.new(pos)
|
|
|
|
for i = math.random(6)+18,300 do
|
|
|
|
p.z = pos.z+i
|
2016-07-18 16:45:11 +02:00
|
|
|
if minetest.get_node(p).name ~= "nyancat:nyancat_rainbow" then
|
2015-05-20 21:02:04 +02:00
|
|
|
break
|
2013-08-15 15:26:48 +02:00
|
|
|
end
|
2015-12-06 11:51:37 +01:00
|
|
|
minetest.remove_node(p)
|
2013-08-15 15:26:48 +02:00
|
|
|
end
|
2016-02-21 11:33:49 +01:00
|
|
|
local z = math.floor(finepos.z+0.1)
|
2015-05-20 21:02:04 +02:00
|
|
|
for i = 1,6 do
|
2016-02-21 11:33:49 +01:00
|
|
|
p.z = z+i
|
2015-12-06 11:51:37 +01:00
|
|
|
if minetest.get_node(p).name ~= "air" then
|
2013-08-15 15:26:48 +02:00
|
|
|
return
|
|
|
|
end
|
2016-07-18 16:45:11 +02:00
|
|
|
minetest.add_node(p, {name="nyancat:nyancat_rainbow"})
|
2013-08-15 15:24:35 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2015-07-25 17:31:55 +02:00
|
|
|
|
|
|
|
local nt = {
|
2016-08-08 15:52:46 +02:00
|
|
|
"[combine:32x16:0,0=nyancat_rainbow.png^[transformFX^[combine:32x16:0,0=nyancat_rainbow.png^[transformR90",
|
|
|
|
"[combine:16x32:0,0=nyancat_rainbow.png^[transformFX^[combine:16x32:0,16=nyancat_rainbow.png"
|
2015-07-25 17:31:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for i = 1,2 do
|
2016-07-28 08:12:27 +02:00
|
|
|
nt[2*i-1] = {
|
2015-07-25 17:31:55 +02:00
|
|
|
name = nt[i],
|
|
|
|
animation = {
|
|
|
|
type = "vertical_frames",
|
|
|
|
aspect_w = 16,
|
|
|
|
aspect_h = 16,
|
2016-09-01 17:52:07 +02:00
|
|
|
length = 0.3
|
2016-08-08 15:52:46 +02:00
|
|
|
}
|
2015-07-25 17:31:55 +02:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2015-12-06 11:51:37 +01:00
|
|
|
nt[2] = nt[1]
|
|
|
|
|
2016-07-18 16:45:11 +02:00
|
|
|
minetest.override_item("nyancat:nyancat_rainbow", {tiles = nt})
|
2015-07-25 17:31:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
minetest.register_node("nyanland:nyancat", {
|
|
|
|
description = "golden Nyan Cat",
|
2016-07-28 08:02:06 +02:00
|
|
|
tiles = {"nyancat_side.png", "nyancat_side.png", "nyancat_side.png",
|
|
|
|
"nyancat_side.png", "default_gold_block.png^nyanland_nc_back.png", "default_gold_block.png^nyanland_nc_front.png"},
|
2015-07-25 17:31:55 +02:00
|
|
|
paramtype2 = "facedir",
|
|
|
|
groups = {cracky=1, not_in_creative_inventory=1},
|
|
|
|
is_ground_content = false,
|
|
|
|
legacy_facedir_simple = true,
|
|
|
|
sounds = default.node_sound_defaults(),
|
2016-07-29 13:51:31 +02:00
|
|
|
after_place_node = function(pos, player)
|
|
|
|
minetest.get_meta(pos):set_string("owner", player:get_player_name())
|
2015-07-25 17:31:55 +02:00
|
|
|
end,
|
2016-07-29 13:51:31 +02:00
|
|
|
can_dig = function(pos, player)
|
2016-07-22 21:51:41 +02:00
|
|
|
local owner = minetest.get_meta(pos):get_string"owner"
|
2016-07-29 13:51:31 +02:00
|
|
|
return not owner
|
|
|
|
or owner == ""
|
|
|
|
or (
|
|
|
|
owner == player:get_player_name()
|
|
|
|
and player:get_player_control().sneak
|
|
|
|
)
|
2015-07-25 17:31:55 +02:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
local punchfct = minetest.registered_nodes["nyanland:nyancat"].on_punch
|
|
|
|
minetest.override_item("nyanland:nyancat", {
|
|
|
|
on_punch = function(pos, node, player, pt, ...)
|
|
|
|
if pt.above
|
2016-07-01 12:26:48 +02:00
|
|
|
and minetest.get_meta(pos):get_string"owner" == player:get_player_name()
|
2015-07-25 17:31:55 +02:00
|
|
|
and not player:get_player_control().sneak
|
|
|
|
and minetest.get_node(pt.above).name == "air" then
|
|
|
|
minetest.sound_play("nyanland_cat", {pos = pos, gain = 2, max_hear_distance = 41})
|
|
|
|
minetest.set_node(pt.above, {name="default:goldblock"})
|
|
|
|
end
|
|
|
|
return punchfct(pos, node, player, pt, ...)
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
2016-07-18 16:45:11 +02:00
|
|
|
local makecat = nyancat.place
|
|
|
|
function nyancat.place(pos, facedir, length)
|
2015-07-25 17:31:55 +02:00
|
|
|
if minetest.get_node(pos).name ~= "default:stone_with_gold" then
|
|
|
|
return makecat(pos, facedir, length)
|
|
|
|
end
|
|
|
|
local tailvec = minetest.facedir_to_dir(facedir)
|
|
|
|
local p = vector.new(pos)
|
|
|
|
minetest.set_node(p, {name = "nyanland:nyancat", param2 = facedir})
|
|
|
|
for i = 1, length+5 do
|
|
|
|
p.x = p.x + tailvec.x
|
|
|
|
p.z = p.z + tailvec.z
|
2016-07-18 16:45:11 +02:00
|
|
|
minetest.set_node(p, {name = "nyancat:nyancat_rainbow", param2 = facedir})
|
2015-07-25 17:31:55 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2016-07-01 12:26:48 +02:00
|
|
|
dofile(minetest.get_modpath"nyanland".."/portal.lua")
|
2015-12-06 11:51:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
-- legacy
|
|
|
|
|
|
|
|
minetest.register_entity("nyanland:tail_entity", {
|
2016-03-25 19:00:29 +01:00
|
|
|
--[[physical = false,
|
2015-12-06 11:51:37 +01:00
|
|
|
visual = "sprite",
|
|
|
|
timer=0,
|
|
|
|
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
2016-03-25 19:00:29 +01:00
|
|
|
visual = "cube",--]]
|
2015-12-06 11:51:37 +01:00
|
|
|
on_activate = function(self)
|
|
|
|
self.object:remove()
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_entity("nyanland:mese", {
|
|
|
|
on_activate = function(self)
|
|
|
|
self.object:remove()
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2016-09-10 14:43:44 +02:00
|
|
|
local time = (minetest.get_us_time() - load_time_start) / 1000000
|
|
|
|
local msg = "[nyanland] loaded after ca. " .. time .. " seconds."
|
|
|
|
if time > 0.01 then
|
|
|
|
print(msg)
|
|
|
|
else
|
|
|
|
minetest.log("info", msg)
|
|
|
|
end
|