Added realtest.register_dirt

This commit is contained in:
Kotolegokot 2013-04-22 21:03:02 +06:00
parent 0579e3f664
commit ff80bddbf5
20 changed files with 236 additions and 73 deletions

View File

@ -43,3 +43,4 @@ minetest.register_alias("trees:mapple_planks_slab", "trees:maple_planks_slab")
minetest.register_alias("trees:mapple_planks_slab_r", "trees:maple_planks_slab_r") minetest.register_alias("trees:mapple_planks_slab_r", "trees:maple_planks_slab_r")
minetest.register_alias("trees:mapple_planks_stair", "trees:maple_planks_stair") minetest.register_alias("trees:mapple_planks_stair", "trees:maple_planks_stair")
minetest.register_alias("trees:mapple_planks_stair_upside_down", "trees:maple_planks_stair_upside_down") minetest.register_alias("trees:mapple_planks_stair_upside_down", "trees:maple_planks_stair_upside_down")
minetest.register_alias("default:clay_lump", "grounds:clay_lump")

View File

@ -68,14 +68,6 @@ minetest.register_craft({
} }
}) })
minetest.register_craft({
output = "default:clay",
recipe = {
{"default:clay_lump", "default:clay_lump"},
{"default:clay_lump", "default:clay_lump"},
}
})
minetest.register_craft({ minetest.register_craft({
output = "default:brick", output = "default:brick",
recipe = { recipe = {
@ -124,12 +116,6 @@ minetest.register_craft({
recipe = "default:desert_sand", recipe = "default:desert_sand",
}) })
minetest.register_craft({
type = "cooking",
output = "default:clay_brick",
recipe = "default:clay_lump",
})
-- --
-- Fuels -- Fuels
-- --
@ -327,27 +313,6 @@ minetest.register_node("default:cobbleblock_flat", {
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
minetest.register_node("default:dirt_with_grass", {
description = "Dirt with Grass",
tiles = {"default_grass.png", "default_dirt.png", "default_grass.png"},
particle_image = {"default_dirt.png"},
is_ground_content = true,
groups = {crumbly=3,drop_on_dig=1},
drop = "default:dirt",
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
}),
})
minetest.register_node("default:dirt", {
description = "Dirt",
tiles = {"default_dirt.png"},
particle_image = {"default_dirt.png"},
is_ground_content = true,
groups = {crumbly=3,drop_on_dig=1, falling_node=1},
sounds = default.node_sound_dirt_defaults(),
})
minetest.register_node("default:sand", { minetest.register_node("default:sand", {
description = "Sand", description = "Sand",
tiles = {"default_sand.png"}, tiles = {"default_sand.png"},
@ -387,43 +352,6 @@ minetest.register_node("default:sandstone", {
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
minetest.register_node("default:sand_with_clay", {
description = "Clay",
tiles = {"default_sand.png^default_clay.png"},
particle_image = {"default_clay_lump.png"},
is_ground_content = true,
groups = {crumbly=3,drop_on_dig=1},
drop = "default:clay_lump 4",
sounds = default.node_sound_dirt_defaults({
footstep = "",
}),
})
minetest.register_node("default:dirt_with_clay", {
description = "Clay",
tiles = {"default_dirt.png^default_clay.png"},
particle_image = {"default_clay_lump.png"},
is_ground_content = true,
groups = {crumbly=3, drop_on_dig=1},
drop = "default:clay_lump 4",
sounds = default.node_sound_dirt_defaults({
footstep = "",
}),
})
minetest.register_node("default:dirt_with_grass_and_clay", {
description = "Clay",
tiles = {"default_grass.png", "default_dirt.png^default_clay.png", "default_grass.png"},
particle_image = {"default_clay_lump.png"},
is_ground_content = true,
groups = {crumbly=3, drop_on_dig=1},
drop = "default:clay_lump 4",
sounds = default.node_sound_dirt_defaults({
footstep = "",
}),
})
minetest.register_node("default:brick", { minetest.register_node("default:brick", {
description = "Brick Block", description = "Brick Block",
tiles = {"default_brick.png"}, tiles = {"default_brick.png"},

Binary file not shown.

Before

Width:  |  Height:  |  Size: 769 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 871 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 B

View File

Before

Width:  |  Height:  |  Size: 839 B

After

Width:  |  Height:  |  Size: 839 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 988 B

2
mods/grounds/depends.txt Normal file
View File

@ -0,0 +1,2 @@
core
default

220
mods/grounds/dirt.lua Normal file
View File

@ -0,0 +1,220 @@
realtest.registered_dirts = {}
realtest.registered_dirts_list = {}
function realtest.register_dirt(name, DirtRef)
local dirt = {
name = name,
description = DirtRef.description or "Dirt",
grass = true,
clay = true,
farm = true
}
if DirtRef.grass == false then
dirt.grass = false
end
if DirtRef.clay == false then
dirt.clay = false
end
if DirtRef.farm == false then
dirt.farm = false
end
realtest.registered_dirts[name] = dirt
table.insert(realtest.registered_dirts_list, name)
local name_ = name:get_modname_prefix().."_"..name:remove_modname_prefix()
local nograss_grass = {
[name] = name.."_with_grass",
[name.."_farm"] = name.."_farm_with_grass",
[name.."_with_clay"] = name.."_with_grass_and_clay",
[name.."_farm_with_clay"] = name.."_farm_with_grass_and_clay",
}
local grass_nograss = {
[name.."_with_grass"] = name,
[name.."_farm_with_grass"] = name.."_farm",
[name.."_with_grass_and_clay"] = name.."_with_clay",
[name.."_farm_with_grass_and_clay"] = name.."_farm_with_clay",
}
local farm_nofarm = {
[name.."_farm"] = name,
[name.."_farm_with_grass"] = name.."_with_grass",
[name.."_farm_with_clay"] = name.."_with_clay",
[name.."_farm_with_grass_and_clay"] = name.."_with_grass_and_clay"
}
minetest.register_node(":"..name, {
description = dirt.description,
tiles = {name_..".png"},
particle_image = {name_..".png"},
groups = {crumbly=3,drop_on_dig=1, falling_node=1, dirt=1},
sounds = default.node_sound_dirt_defaults(),
})
if dirt.grass then
minetest.register_node(":"..name .. "_with_grass", {
description = dirt.description .. " with Grass",
tiles = {name_.."_grass.png", name_..".png", name_.."_grass.png"},
particle_image = {name_..".png"},
groups = {crumbly=3,drop_on_dig=1,dirt=1,grass=1},
drop = name,
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
}),
})
end
if dirt.clay then
minetest.register_node(":"..name.."_with_clay", {
description = dirt.description .. " with Clay",
tiles = {name_..".png^grounds_clay.png"},
particle_image = {"grounds_clay_lump.png"},
groups = {crumbly=3, drop_on_dig=1, dirt=1,clay=1, falling_node=1},
drop = "grounds:clay_lump 4",
sounds = default.node_sound_dirt_defaults(),
})
end
if dirt.farm then
minetest.register_node(":"..name.."_farm", {
description = "Farm " .. dirt.description,
tiles = {name_.."_farm.png", name_..".png", name_..".png"},
particle_image = {name_..".png"},
drop = name,
groups = {crumbly=3,drop_on_dig=1, falling_node=1, dirt=1, farm=1},
sounds = default.node_sound_dirt_defaults(),
on_falling = function(pos, node)
minetest.env:set_node(pos, {name = farm_nofarm[node.name]})
nodeupdate_single(pos)
end,
})
end
if dirt.grass and dirt.clay then
minetest.register_node(":"..name.."_with_grass_and_clay", {
description = dirt.description .. " with Grass and Clay",
tiles = {name_.."_grass.png", name_..".png^grounds_clay.png", name_.."_grass.png"},
particle_image = {"grounds_clay_lump.png"},
groups = {crumbly=3, drop_on_dig=1, dirt=1, grass=1, clay=1},
drop = "grounds:clay_lump 4",
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
}),
})
end
if dirt.farm and dirt.grass then
minetest.register_node(":"..name.."_farm_with_grass", {
description = "Farm " .. dirt.description .. " with Grass",
tiles = {name_.."_farm.png", name_..".png", name_.."_grass.png"},
particle_image = {name_..".png"},
drop = name,
groups = {crumbly=3,drop_on_dig=1, dirt=1, grass=1, farm=1},
sounds = default.node_sound_dirt_defaults(),
on_falling = function(pos, node)
minetest.env:set_node(pos, {name = farm_nofarm[node.name]})
nodeupdate_single(pos)
end,
})
end
if dirt.farm and dirt.clay then
minetest.register_node(":"..name.."_farm_with_clay", {
description = "Farm " .. dirt.description .. " with Clay",
tiles = {name_.."_farm.png",name_..".png^grounds_clay.png",name_..".png^grounds_clay.png"},
particle_image = {"grounds_clay_lump.png"},
groups = {crumbly=3, drop_on_dig=1, dirt=1, farm=1, clay=1, falling_node=1},
drop = "grounds:clay_lump 4",
sounds = default.node_sound_dirt_defaults(),
on_falling = function(pos, node)
minetest.env:set_node(pos, {name = farm_nofarm[node.name]})
nodeupdate_single(pos)
end,
})
end
if dirt.farm and dirt.grass and dirt.clay then
minetest.register_node(":"..name.."_farm_with_grass_and_clay", {
description = "Farm " .. dirt.description .. " with Grass and Clay",
tiles = {name_.."_farm.png", name_..".png^grounds_clay.png", name_.."_grass.png"},
particle_image = {"grounds_clay_lump.png"},
groups = {crumbly=3, drop_on_dig=1, dirt=1, farm=1, grass=1, clay=1},
drop = "grounds:clay_lump 4",
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
}),
on_falling = function(pos, node)
minetest.env:set_node(pos, {name = farm_nofarm[node.name]})
nodeupdate_single(pos)
end,
})
end
minetest.register_abm({
nodenames = {name, name.."_farm", name.."_with_clay", name.."_farm_with_clay"},
interval = 200,
chance = 200,
action = function(pos, node)
pos.y = pos.y+1
local n = minetest.registered_nodes[minetest.env:get_node(pos).name]
if not n then
return
end
if not n.sunlight_propagates then
return
end
if n.liquidtype and n.liquidtype ~= "none" then
return
end
if not minetest.env:get_node_light(pos) then
return
end
if minetest.env:get_node_light(pos) < 13 then
return
end
pos.y = pos.y-1
minetest.env:set_node(pos, {name=nograss_grass[node.name]})
end
})
minetest.register_abm({
nodenames = {name.."_with_grass", name.."_farm_with_grass", name.."_with_grass_and_clay", name.."_farm_with_grass_and_clay"},
interval = 200,
chance = 200,
action = function(pos, node)
pos.y = pos.y+1
local n = minetest.registered_nodes[minetest.env:get_node(pos).name]
if not n then
return
end
if (n.liquidtype and n.liquidtype ~= "none")
or (minetest.env:get_node_light(pos) and minetest.env:get_node_light(pos) < 5)
or minetest.registered_nodes[minetest.env:get_node({x=pos.x,y=pos.y-2,z=pos.z}).name].buildable_to then
pos.y = pos.y-1
minetest.env:set_node(pos, {name=grass_nograss[node.name]})
nodeupdate_single(pos)
end
end
})
minetest.register_abm({
nodenames = {name.."_farm", name.."_farm_with_grass", name.."_farm_with_clay", name.."_farm_with_grass_and_clay"},
interval = 1,
chance = 2,
action = function(pos, node)
pos.y = pos.y + 1
local objs = minetest.env:get_objects_inside_radius(pos, 1)
for k, obj in pairs(objs) do
if obj:is_player() then
pos.y = pos.y - 1
minetest.env:set_node(pos, {name = farm_nofarm[node.name]})
return
end
end
end,
})
end
realtest.register_dirt("default:dirt", {description = "Dirt"})

12
mods/grounds/init.lua Normal file
View File

@ -0,0 +1,12 @@
minetest.register_craftitem("grounds:clay_lump", {
description = "Clay Lump",
inventory_image = "grounds_clay_lump.png"
})
minetest.register_craft({
type = "cooking",
output = "default:clay_brick",
recipe = "grounds:clay_lump",
})
dofile(minetest.get_modpath("grounds").."/dirt.lua")

Binary file not shown.

After

Width:  |  Height:  |  Size: 983 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 839 B