2014-06-14 16:41:51 +02:00
|
|
|
local load_time_start = os.clock()
|
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={}
|
|
|
|
|
|
|
|
--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:24:35 +02:00
|
|
|
inventory_image = minetest.inventorycube("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,
|
|
|
|
groups = {dig_immediate = 3},
|
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
|
|
|
inventory_image = minetest.inventorycube("nyanland_cloudstone_var.png"),
|
|
|
|
use_texture_alpha = true,
|
|
|
|
sunlight_propagates = true,
|
|
|
|
drop = '',
|
|
|
|
light_source = 10,
|
|
|
|
groups = {dig_immediate = 3},
|
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"},
|
|
|
|
groups = {tree=1,cracky=1,level=2},
|
|
|
|
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
|
|
|
inventory_image = minetest.inventorycube("nyanland_meseleaves.png"),
|
|
|
|
paramtype = "light",
|
|
|
|
furnace_burntime = 5,
|
2013-08-15 15:26:48 +02:00
|
|
|
groups = {snappy=3, flammable=2},
|
|
|
|
-- 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,
|
|
|
|
groups = {snappy=3,flammable=3,attached_node=1},
|
|
|
|
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",
|
|
|
|
tiles = {"nyanland_mese_shrub_fruits.png"},
|
|
|
|
inventory_image = "nyanland_mese_shrub_fruits.png",
|
|
|
|
wield_image = "nyanland_mese_shrub_fruits.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,
|
|
|
|
groups = {snappy=3,flammable=3,attached_node=1},
|
|
|
|
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
|
|
|
})
|
|
|
|
|
|
|
|
-- 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", {
|
2013-08-24 12:36:41 +02:00
|
|
|
tiles = {"nyanland_clonestone.png"},
|
2013-08-15 15:24:35 +02:00
|
|
|
inventory_image = minetest.inventorycube("nyanland_clonestone.png"),
|
|
|
|
furnace_burntime = 100,
|
|
|
|
groups = {cracky = 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,
|
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", {
|
2013-08-15 15:26:48 +02:00
|
|
|
description = "nyanland:healstone",
|
2013-08-24 12:36:41 +02:00
|
|
|
tiles = {"nyanland_healstone.png"},
|
2013-08-15 15:24:35 +02:00
|
|
|
inventory_image = minetest.inventorycube("nyanland_healstone.png"),
|
|
|
|
furnace_burntime = 100,
|
|
|
|
groups = {cracky = 1},
|
|
|
|
})
|
|
|
|
|
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
|
|
|
|
2015-05-17 01:03:32 +02:00
|
|
|
-- Weierstrass function stuff from https://github.com/slemonide/gen
|
|
|
|
local SIZE = 1000
|
|
|
|
local ssize = math.ceil(math.abs(SIZE))
|
|
|
|
local function do_ws_func(depth, a, x)
|
|
|
|
local n = x/(16*SIZE)
|
|
|
|
local y = 0
|
|
|
|
for k=1,depth do
|
2015-07-05 21:01:30 +02:00
|
|
|
y = y + math.sin(math.pi * k^a * n)/(k^a)
|
2015-05-17 01:03:32 +02:00
|
|
|
end
|
2015-07-05 21:01:30 +02:00
|
|
|
return SIZE*y/math.pi
|
2015-05-17 01:03:32 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local chunksize = minetest.setting_get("chunksize") or 5
|
|
|
|
local ws_lists = {}
|
|
|
|
local function get_ws_list(a,x)
|
|
|
|
ws_lists[a] = ws_lists[a] or {}
|
|
|
|
local v = ws_lists[a][x]
|
|
|
|
if v then
|
|
|
|
return v
|
|
|
|
end
|
|
|
|
v = {}
|
|
|
|
for x=x,x + (chunksize*16 - 1) do
|
|
|
|
local y = do_ws_func(ssize, a, x)
|
|
|
|
v[x] = y
|
|
|
|
end
|
|
|
|
ws_lists[a][x] = v
|
|
|
|
return v
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2015-05-16 23:44:52 +02:00
|
|
|
local generate_mesetree
|
|
|
|
|
2013-08-15 15: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")
|
2015-05-17 01:03:32 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
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)
|
|
|
|
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
|
|
|
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}
|
|
|
|
|
2015-05-16 23:44:52 +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})
|
2015-05-17 01:03:32 +02:00
|
|
|
local strassx = get_ws_list(3, minp.x)
|
|
|
|
local strassz = get_ws_list(5, minp.z)
|
|
|
|
local strassnx = get_ws_list(2, minp.x)
|
|
|
|
local strassnz = get_ws_list(2, 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
|
2015-05-17 01:03:32 +02:00
|
|
|
local depth = math.floor(((strassx[x]+strassz[z])%14)*math.min((test2-0.2)*25/4, 1)+0.5)
|
|
|
|
if depth ~= 0 then
|
|
|
|
local sel = math.floor(strassnx[x]+strassnz[z]+0.5)%10
|
|
|
|
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)
|
|
|
|
minetest.add_node(pos, {name="default:nyancat"})
|
|
|
|
local length = math.random(4,15)
|
|
|
|
for _ = 1, length do
|
|
|
|
pos.z = pos.z+1
|
|
|
|
minetest.add_node(pos, {name="default:nyancat_rainbow"})
|
2013-08-15 15:24:35 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-10-18 22:05:00 +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")
|
2015-05-16 23:44:52 +02:00
|
|
|
local c_ignore = minetest.get_content_id("ignore")
|
|
|
|
|
|
|
|
local function mesetree(pos, tran, nodes, area, pr)
|
|
|
|
-- stem
|
|
|
|
local head_y = pos.y+4+tran
|
|
|
|
for y = pos.y, head_y do
|
|
|
|
p = area:index(pos.x, y, pos.z)
|
|
|
|
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({
|
|
|
|
nodenames = {"default:nyancat"},
|
2013-08-15 15:26:48 +02:00
|
|
|
interval = 10,
|
|
|
|
chance = 100,
|
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,
|
2013-08-15 15:24:35 +02:00
|
|
|
visual = "sprite",
|
|
|
|
timer=0,
|
2015-05-20 21:02:04 +02:00
|
|
|
lastpos = {x=0, y=0, z=0},
|
2013-08-15 15:24:35 +02:00
|
|
|
textures = {"default_nc_side.png", "default_nc_side.png", "default_nc_side.png",
|
|
|
|
"default_nc_side.png", "default_nc_back.png", "default_nc_front.png"},
|
|
|
|
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
|
|
|
visual = "cube",
|
|
|
|
on_activate = function(self, staticdata)
|
|
|
|
self.object:setvelocity({x=0, y=0, z=-2})
|
2015-05-20 21:02:04 +02:00
|
|
|
self.lastpos = vector.round(self.object:getpos())
|
2013-08-15 15:24:35 +02:00
|
|
|
end,
|
|
|
|
|
|
|
|
on_punch = function(self, hitter)
|
|
|
|
local mesepos=self.object:getpos()
|
|
|
|
mesepos.y=mesepos.y-1
|
2013-09-21 22:29:54 +02:00
|
|
|
minetest.add_entity(mesepos, "nyanland:mese")
|
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
|
2015-05-20 21:02:04 +02:00
|
|
|
minetest.add_node(self.lastpos, {name="default:nyancat"})
|
2013-08-15 15:24:35 +02:00
|
|
|
self.object:remove()
|
2013-08-15 15:26:48 +02:00
|
|
|
return
|
|
|
|
end
|
2015-05-20 21:02:04 +02:00
|
|
|
local pos = vector.round(self.object:getpos())
|
|
|
|
if vector.equals(self.lastpos, pos) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
self.lastpos = pos
|
2015-05-29 12:09:18 +02:00
|
|
|
if minetest.get_node(pos).name == "default: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
|
2013-09-21 22:29:54 +02:00
|
|
|
if minetest.get_node(p).name == "default:nyancat_rainbow" then
|
|
|
|
minetest.remove_node(p)
|
2015-05-20 21:02:04 +02:00
|
|
|
else
|
|
|
|
break
|
2013-08-15 15:26:48 +02:00
|
|
|
end
|
|
|
|
end
|
2015-05-20 21:02:04 +02:00
|
|
|
for i = 1,6 do
|
|
|
|
p.z = pos.z+i
|
2013-09-21 22:29:54 +02:00
|
|
|
if minetest.get_node(p).name == "air" then
|
|
|
|
minetest.add_node(p, {name="default:nyancat_rainbow"})
|
2013-08-15 15:26:48 +02:00
|
|
|
else
|
|
|
|
return
|
|
|
|
end
|
2013-08-15 15:24:35 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_entity("nyanland:tail_entity", {
|
|
|
|
physical = false,
|
|
|
|
visual = "sprite",
|
|
|
|
timer=0,
|
|
|
|
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
|
|
|
visual = "cube",
|
2013-08-15 15:26:48 +02:00
|
|
|
on_step = function(self)
|
|
|
|
self.object:remove()
|
2013-08-15 15:24:35 +02:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_entity("nyanland:mese", {
|
|
|
|
physical = true,
|
|
|
|
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
|
|
|
visual = "cube",
|
2013-08-15 15:26:48 +02:00
|
|
|
textures = {"default_mese_block.png", "default_mese_block.png", "default_mese_block.png", "default_mese_block.png", "default_mese_block.png", "default_mese_block.png"},
|
2013-08-15 15:24:35 +02:00
|
|
|
on_activate = function(self)
|
|
|
|
self.object:setvelocity({x=0, y=-.1, z =0})
|
2015-05-20 21:02:04 +02:00
|
|
|
self.object:setacceleration({x=0, y=-9, z=0})
|
2013-08-15 15:24:35 +02:00
|
|
|
end,
|
|
|
|
on_step = function(self, dtime)
|
2015-05-20 21:02:04 +02:00
|
|
|
--[[local pos = self.object:getpos()
|
2015-05-29 12:09:18 +02:00
|
|
|
local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z}
|
2013-09-21 22:29:54 +02:00
|
|
|
local bcn = minetest.get_node(bcp)
|
2013-08-15 15:24:35 +02:00
|
|
|
--if bcn.name ~= "air" then
|
2015-05-20 21:02:04 +02:00
|
|
|
-- local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}--]]
|
2013-08-15 15:24:35 +02:00
|
|
|
if self.object:getvelocity().y == 0 then
|
2013-09-21 22:29:54 +02:00
|
|
|
minetest.add_node(self.object:getpos(), {name="default:mese_block"})
|
2013-08-15 15:24:35 +02:00
|
|
|
self.object:remove()
|
|
|
|
end
|
2015-05-29 12:09:18 +02:00
|
|
|
--
|
2013-08-15 15:24:35 +02:00
|
|
|
--end
|
|
|
|
end
|
|
|
|
})
|
2013-09-21 22:29:54 +02:00
|
|
|
|
|
|
|
dofile(minetest.get_modpath("nyanland").."/portal.lua")
|
2014-12-28 22:01:25 +01:00
|
|
|
minetest.log("info", string.format("[nyanland] loaded after ca. %.2fs", os.clock() - load_time_start))
|