Compare commits
34 Commits
0.4.dev-20
...
0.4.dev-20
Author | SHA1 | Date | |
---|---|---|---|
fcaacdb4ad | |||
dd9b33db67 | |||
894f98d878 | |||
3a1a7d511d | |||
53e9b0e107 | |||
216227bac3 | |||
1a62348e44 | |||
3aac1adb15 | |||
2302e55dbb | |||
279eff9a7f | |||
df2037b886 | |||
ccf3b71c28 | |||
5296dc1518 | |||
51fce37fc1 | |||
9207e9af46 | |||
befc604af3 | |||
5f6039bc3c | |||
4abfcda81f | |||
95f4ccab51 | |||
dee4b328a3 | |||
60c16eb57b | |||
68504124d7 | |||
fe315ac1eb | |||
ab84afd071 | |||
48a76211a8 | |||
de13e8f1fa | |||
5bd33df1a3 | |||
1d4ae73e0d | |||
492e86050c | |||
0b157335d1 | |||
8fece11cc7 | |||
fa06d11909 | |||
b4d659d8ae | |||
ad58e41580 |
23
README.txt
@ -8,11 +8,23 @@ in the Minetest Engine.
|
|||||||
The Minetest Engine can be found in:
|
The Minetest Engine can be found in:
|
||||||
https://github.com/celeron55/minetest/
|
https://github.com/celeron55/minetest/
|
||||||
|
|
||||||
This has been tested to work with the version tagged 0.4.dev-20120326.
|
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
|
License of source code
|
||||||
----------------------
|
----------------------
|
||||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
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
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -31,13 +43,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
License of media (textures and sounds)
|
License of media (textures and sounds)
|
||||||
--------------------------------------
|
--------------------------------------
|
||||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
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)
|
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||||
http://creativecommons.org/licenses/by-sa/3.0/
|
http://creativecommons.org/licenses/by-sa/3.0/
|
||||||
|
|
||||||
Authors of media files
|
|
||||||
-----------------------
|
|
||||||
Everything not mentioned in here - Perttu Ahola <celeron55@gmail.com>
|
|
||||||
default_grass_footstep.{1,2,3}.ogg - Modified versions of sounds by kddekadenz/Dogers
|
|
||||||
default_dig_crumbly.{1,2}.ogg - Modified versions of sounds by kddekadenz/Dogers
|
|
||||||
|
|
||||||
|
26
mods/bucket/README.txt
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
Minetest 0.4 mod: bucket
|
||||||
|
=========================
|
||||||
|
|
||||||
|
License of source code:
|
||||||
|
-----------------------
|
||||||
|
Copyright (C) 2011-2012 Kahrl <kahrl@gmx.net>
|
||||||
|
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 General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
http://www.gnu.org/licenses/gpl-2.0.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>
|
||||||
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
-- bucket (Minetest 0.4 mod)
|
-- Minetest 0.4 mod: bucket
|
||||||
-- A bucket, which can pick up water and lava
|
-- See README.txt for licensing and other information.
|
||||||
|
|
||||||
minetest.register_alias("bucket", "bucket:bucket_empty")
|
minetest.register_alias("bucket", "bucket:bucket_empty")
|
||||||
minetest.register_alias("bucket_water", "bucket:bucket_water")
|
minetest.register_alias("bucket_water", "bucket:bucket_water")
|
||||||
|
64
mods/default/README.txt
Normal file
@ -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 General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
http://www.gnu.org/licenses/gpl-2.0.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
|
||||||
|
|
92
mods/default/leafdecay.lua
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
-- minetest/default/leafdecay.lua
|
||||||
|
|
||||||
|
-- To enable leaf decay for a node, add it to the "leafdecay" group.
|
||||||
|
--
|
||||||
|
-- The rating of the group determines how far from a node in the group "tree"
|
||||||
|
-- the node can be without decaying.
|
||||||
|
--
|
||||||
|
-- If param2 of the node is ~= 0, the node will always be preserved. Thus, if
|
||||||
|
-- the player places a node of that kind, you will want to set param2=1 or so.
|
||||||
|
|
||||||
|
default.leafdecay_trunk_cache = {}
|
||||||
|
default.leafdecay_enable_cache = true
|
||||||
|
-- Spread the load of finding trunks
|
||||||
|
default.leafdecay_trunk_find_allow_accumulator = 0
|
||||||
|
|
||||||
|
minetest.register_globalstep(function(dtime)
|
||||||
|
local finds_per_second = 5000
|
||||||
|
default.leafdecay_trunk_find_allow_accumulator =
|
||||||
|
math.floor(dtime * finds_per_second)
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"group:leafdecay"},
|
||||||
|
neighbors = {"air", "group:liquid"},
|
||||||
|
-- A low interval and a high inverse chance spreads the load
|
||||||
|
interval = 2,
|
||||||
|
chance = 5,
|
||||||
|
|
||||||
|
action = function(p0, node, _, _)
|
||||||
|
--print("leafdecay ABM at "..p0.x..", "..p0.y..", "..p0.z..")")
|
||||||
|
local do_preserve = false
|
||||||
|
local d = minetest.registered_nodes[node.name].groups.leafdecay
|
||||||
|
if not d or d == 0 then
|
||||||
|
--print("not groups.leafdecay")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local n0 = minetest.env:get_node(p0)
|
||||||
|
if n0.param2 ~= 0 then
|
||||||
|
--print("param2 ~= 0")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local p0_hash = nil
|
||||||
|
if default.leafdecay_enable_cache then
|
||||||
|
p0_hash = minetest.hash_node_position(p0)
|
||||||
|
local trunkp = default.leafdecay_trunk_cache[p0_hash]
|
||||||
|
if trunkp then
|
||||||
|
local n = minetest.env:get_node(trunkp)
|
||||||
|
local reg = minetest.registered_nodes[n.name]
|
||||||
|
-- Assume ignore is a trunk, to make the thing work at the border of the active area
|
||||||
|
if n.name == "ignore" or (reg.groups.tree and reg.groups.tree ~= 0) then
|
||||||
|
--print("cached trunk still exists")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
--print("cached trunk is invalid")
|
||||||
|
-- Cache is invalid
|
||||||
|
table.remove(default.leafdecay_trunk_cache, p0_hash)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if default.leafdecay_trunk_find_allow_accumulator <= 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
default.leafdecay_trunk_find_allow_accumulator =
|
||||||
|
default.leafdecay_trunk_find_allow_accumulator - 1
|
||||||
|
-- Assume ignore is a trunk, to make the thing work at the border of the active area
|
||||||
|
local p1 = minetest.env:find_node_near(p0, d, {"ignore", "group:tree"})
|
||||||
|
if p1 then
|
||||||
|
do_preserve = true
|
||||||
|
if default.leafdecay_enable_cache then
|
||||||
|
--print("caching trunk")
|
||||||
|
-- Cache the trunk
|
||||||
|
default.leafdecay_trunk_cache[p0_hash] = p1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not do_preserve then
|
||||||
|
-- Drop stuff other than the node itself
|
||||||
|
itemstacks = minetest.get_node_drops(n0.name)
|
||||||
|
for _, itemname in ipairs(itemstacks) do
|
||||||
|
if itemname ~= n0.name then
|
||||||
|
local p_drop = {
|
||||||
|
x = p0.x - 0.5 + math.random(),
|
||||||
|
y = p0.y - 0.5 + math.random(),
|
||||||
|
z = p0.z - 0.5 + math.random(),
|
||||||
|
}
|
||||||
|
minetest.env:add_item(p_drop, itemname)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Remove node
|
||||||
|
minetest.env:remove_node(p0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
275
mods/default/mapgen.lua
Normal file
@ -0,0 +1,275 @@
|
|||||||
|
-- minetest/default/mapgen.lua
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Aliases for map generator outputs
|
||||||
|
--
|
||||||
|
|
||||||
|
minetest.register_alias("mapgen_air", "air")
|
||||||
|
minetest.register_alias("mapgen_stone", "default:stone")
|
||||||
|
minetest.register_alias("mapgen_tree", "default:tree")
|
||||||
|
minetest.register_alias("mapgen_leaves", "default:leaves")
|
||||||
|
minetest.register_alias("mapgen_apple", "default:apple")
|
||||||
|
minetest.register_alias("mapgen_water_source", "default:water_source")
|
||||||
|
minetest.register_alias("mapgen_dirt", "default:dirt")
|
||||||
|
minetest.register_alias("mapgen_sand", "default:sand")
|
||||||
|
minetest.register_alias("mapgen_gravel", "default:gravel")
|
||||||
|
minetest.register_alias("mapgen_clay", "default:clay")
|
||||||
|
minetest.register_alias("mapgen_lava_source", "default:lava_source")
|
||||||
|
minetest.register_alias("mapgen_cobble", "default:cobble")
|
||||||
|
minetest.register_alias("mapgen_mossycobble", "default:mossycobble")
|
||||||
|
minetest.register_alias("mapgen_dirt_with_grass", "default:dirt_with_grass")
|
||||||
|
minetest.register_alias("mapgen_junglegrass", "default:junglegrass")
|
||||||
|
minetest.register_alias("mapgen_stone_with_coal", "default:stone_with_coal")
|
||||||
|
minetest.register_alias("mapgen_stone_with_iron", "default:stone_with_iron")
|
||||||
|
minetest.register_alias("mapgen_mese", "default:mese")
|
||||||
|
minetest.register_alias("mapgen_desert_sand", "default:desert_sand")
|
||||||
|
minetest.register_alias("mapgen_desert_stone", "default:desert_stone")
|
||||||
|
|
||||||
|
--
|
||||||
|
-- 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)
|
||||||
|
|
Before Width: | Height: | Size: 279 B After Width: | Height: | Size: 763 B |
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 682 B |
BIN
mods/default/textures/default_chest_front.png
Normal file → Executable file
Before Width: | Height: | Size: 167 B After Width: | Height: | Size: 769 B |
Before Width: | Height: | Size: 224 B After Width: | Height: | Size: 871 B |
BIN
mods/default/textures/default_chest_side.png
Normal file → Executable file
Before Width: | Height: | Size: 151 B After Width: | Height: | Size: 714 B |
BIN
mods/default/textures/default_chest_top.png
Normal file → Executable file
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 628 B |
BIN
mods/default/textures/default_cobble.png
Normal file → Executable file
Before Width: | Height: | Size: 830 B After Width: | Height: | Size: 744 B |
BIN
mods/default/textures/default_desert_sand.png
Normal file
After Width: | Height: | Size: 627 B |
BIN
mods/default/textures/default_desert_stone.png
Normal file
After Width: | Height: | Size: 517 B |
BIN
mods/default/textures/default_dirt.png
Normal file → Executable file
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 888 B |
BIN
mods/default/textures/default_dry_shrub.png
Normal file
After Width: | Height: | Size: 450 B |
BIN
mods/default/textures/default_furnace_bottom.png
Normal file
After Width: | Height: | Size: 731 B |
BIN
mods/default/textures/default_furnace_fire_bg.png
Normal file
After Width: | Height: | Size: 313 B |
BIN
mods/default/textures/default_furnace_fire_fg.png
Normal file
After Width: | Height: | Size: 865 B |
Before Width: | Height: | Size: 246 B After Width: | Height: | Size: 651 B |
BIN
mods/default/textures/default_furnace_front_active.png
Normal file
After Width: | Height: | Size: 826 B |
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 731 B |
BIN
mods/default/textures/default_furnace_top.png
Normal file
After Width: | Height: | Size: 731 B |
BIN
mods/default/textures/default_grass.png
Normal file → Executable file
Before Width: | Height: | Size: 874 B After Width: | Height: | Size: 794 B |
BIN
mods/default/textures/default_grass_side.png
Normal file → Executable file
Before Width: | Height: | Size: 878 B After Width: | Height: | Size: 925 B |
Before Width: | Height: | Size: 502 B After Width: | Height: | Size: 751 B |
Before Width: | Height: | Size: 507 B After Width: | Height: | Size: 865 B |
Before Width: | Height: | Size: 357 B After Width: | Height: | Size: 772 B |
BIN
mods/default/textures/default_leaves.png
Normal file → Executable file
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 451 B |
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 299 B |
BIN
mods/default/textures/default_mossycobble.png
Normal file → Executable file
Before Width: | Height: | Size: 965 B After Width: | Height: | Size: 988 B |
BIN
mods/default/textures/default_sand.png
Normal file → Executable file
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 732 B |
Before Width: | Height: | Size: 502 B After Width: | Height: | Size: 358 B |
BIN
mods/default/textures/default_sign_wall.png
Normal file → Executable file
Before Width: | Height: | Size: 489 B After Width: | Height: | Size: 617 B |
BIN
mods/default/textures/default_stone.png
Normal file → Executable file
Before Width: | Height: | Size: 806 B After Width: | Height: | Size: 558 B |
BIN
mods/default/textures/default_tool_mesepick.png
Normal file → Executable file
Before Width: | Height: | Size: 252 B After Width: | Height: | Size: 341 B |
BIN
mods/default/textures/default_tool_steelpick.png
Normal file → Executable file
Before Width: | Height: | Size: 271 B After Width: | Height: | Size: 322 B |
0
mods/default/textures/default_tool_steelshovel.png
Normal file → Executable file
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 216 B |
BIN
mods/default/textures/default_tool_steelsword.png
Normal file → Executable file
Before Width: | Height: | Size: 291 B After Width: | Height: | Size: 306 B |
BIN
mods/default/textures/default_tool_stonepick.png
Normal file → Executable file
Before Width: | Height: | Size: 262 B After Width: | Height: | Size: 365 B |
0
mods/default/textures/default_tool_stoneshovel.png
Normal file → Executable file
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
BIN
mods/default/textures/default_tool_woodpick.png
Normal file → Executable file
Before Width: | Height: | Size: 245 B After Width: | Height: | Size: 307 B |
0
mods/default/textures/default_tool_woodshovel.png
Normal file → Executable file
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
Before Width: | Height: | Size: 925 B After Width: | Height: | Size: 252 B |
Before Width: | Height: | Size: 913 B After Width: | Height: | Size: 245 B |
Before Width: | Height: | Size: 917 B After Width: | Height: | Size: 232 B |
BIN
mods/default/textures/default_tree.png
Normal file → Executable file
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 706 B |
BIN
mods/default/textures/default_tree_top.png
Normal file → Executable file
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 843 B |
BIN
mods/default/textures/default_water.png
Normal file → Executable file
Before Width: | Height: | Size: 518 B After Width: | Height: | Size: 384 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 387 B |
43
mods/doors/README.txt
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
Minetest 0.4 mod: doors
|
||||||
|
========================
|
||||||
|
|
||||||
|
License of source code:
|
||||||
|
-----------------------
|
||||||
|
Original license text:
|
||||||
|
-- (c) 2011 Fernando Zapata
|
||||||
|
-- Code licensed under GNU GPLv3
|
||||||
|
-- Content licensed under CC BY-SA 3.0
|
||||||
|
-- 2012-01-08 11:03:57
|
||||||
|
|
||||||
|
There has been unsuccesful attempts to contact the original author. Thus,
|
||||||
|
based on the intentions of the author, it is assumed that this code is
|
||||||
|
distributable and modifiable under GPLv2+later, under which Minetest is
|
||||||
|
distributed.
|
||||||
|
|
||||||
|
Modifications:
|
||||||
|
Copyright (C) 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 General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
http://www.gnu.org/licenses/gpl-2.0.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>
|
||||||
|
|
||||||
|
From the original zlpdoors mod by Fernando Zapata:
|
||||||
|
door_wood_a.png
|
||||||
|
door_wood_a_r.png
|
||||||
|
door_wood_b.png
|
||||||
|
door_wood_b_r.png
|
||||||
|
door_wood.png
|
||||||
|
|
@ -1,2 +1 @@
|
|||||||
default
|
default
|
||||||
|
|
205
mods/doors/init.lua
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
-- Minetest 0.4 mod: doors
|
||||||
|
-- See README.txt for licensing and other information.
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local WALLMX = 3
|
||||||
|
local WALLMZ = 5
|
||||||
|
local WALLPX = 2
|
||||||
|
local WALLPZ = 4
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
minetest.register_alias('door', 'doors:door_wood')
|
||||||
|
minetest.register_alias('door_wood', 'doors:door_wood')
|
||||||
|
|
||||||
|
minetest.register_node( 'doors:door_wood', {
|
||||||
|
description = 'Wooden Door',
|
||||||
|
drawtype = 'signlike',
|
||||||
|
tile_images = { 'door_wood.png' },
|
||||||
|
inventory_image = 'door_wood.png',
|
||||||
|
wield_image = 'door_wood.png',
|
||||||
|
paramtype2 = 'wallmounted',
|
||||||
|
selection_box = { type = 'wallmounted' },
|
||||||
|
groups = { choppy=2, dig_immediate=2 },
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft( {
|
||||||
|
output = 'doors:door_wood',
|
||||||
|
recipe = {
|
||||||
|
{ 'default:wood', 'default:wood' },
|
||||||
|
{ 'default:wood', 'default:wood' },
|
||||||
|
{ 'default:wood', 'default:wood' },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
type = 'fuel',
|
||||||
|
recipe = 'doors:door_wood',
|
||||||
|
burntime = 30,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node( 'doors:door_wood_a_c', {
|
||||||
|
Description = 'Top Closed Door',
|
||||||
|
drawtype = 'signlike',
|
||||||
|
tile_images = { 'door_wood_a.png' },
|
||||||
|
inventory_image = 'door_wood_a.png',
|
||||||
|
paramtype = 'light',
|
||||||
|
paramtype2 = 'wallmounted',
|
||||||
|
walkable = true,
|
||||||
|
selection_box = { type = "wallmounted", },
|
||||||
|
groups = { choppy=2, dig_immediate=2 },
|
||||||
|
legacy_wallmounted = true,
|
||||||
|
drop = 'doors:door_wood',
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node( 'doors:door_wood_b_c', {
|
||||||
|
Description = 'Bottom Closed Door',
|
||||||
|
drawtype = 'signlike',
|
||||||
|
tile_images = { 'door_wood_b.png' },
|
||||||
|
inventory_image = 'door_wood_b.png',
|
||||||
|
paramtype = 'light',
|
||||||
|
paramtype2 = 'wallmounted',
|
||||||
|
walkable = true,
|
||||||
|
selection_box = { type = "wallmounted", },
|
||||||
|
groups = { choppy=2, dig_immediate=2 },
|
||||||
|
legacy_wallmounted = true,
|
||||||
|
drop = 'doors:door_wood',
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node( 'doors:door_wood_a_o', {
|
||||||
|
Description = 'Top Open Door',
|
||||||
|
drawtype = 'signlike',
|
||||||
|
tile_images = { 'door_wood_a_r.png' },
|
||||||
|
inventory_image = 'door_wood_a_r.png',
|
||||||
|
paramtype = 'light',
|
||||||
|
paramtype2 = 'wallmounted',
|
||||||
|
walkable = false,
|
||||||
|
selection_box = { type = "wallmounted", },
|
||||||
|
groups = { choppy=2, dig_immediate=2 },
|
||||||
|
legacy_wallmounted = true,
|
||||||
|
drop = 'doors:door_wood',
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node( 'doors:door_wood_b_o', {
|
||||||
|
Description = 'Bottom Open Door',
|
||||||
|
drawtype = 'signlike',
|
||||||
|
tile_images = { 'door_wood_b_r.png' },
|
||||||
|
inventory_image = 'door_wood_b_r.png',
|
||||||
|
paramtype = 'light',
|
||||||
|
paramtype2 = 'wallmounted',
|
||||||
|
walkable = false,
|
||||||
|
selection_box = { type = "wallmounted", },
|
||||||
|
groups = { choppy=2, dig_immediate=2 },
|
||||||
|
legacy_wallmounted = true,
|
||||||
|
drop = 'doors:door_wood',
|
||||||
|
})
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local round = function( n )
|
||||||
|
if n >= 0 then
|
||||||
|
return math.floor( n + 0.5 )
|
||||||
|
else
|
||||||
|
return math.ceil( n - 0.5 )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local on_door_placed = function( pos, node, placer )
|
||||||
|
if node.name ~= 'doors:door_wood' then return end
|
||||||
|
|
||||||
|
upos = { x = pos.x, y = pos.y - 1, z = pos.z }
|
||||||
|
apos = { x = pos.x, y = pos.y + 1, z = pos.z }
|
||||||
|
und = minetest.env:get_node( upos )
|
||||||
|
abv = minetest.env:get_node( apos )
|
||||||
|
|
||||||
|
dir = placer:get_look_dir()
|
||||||
|
|
||||||
|
if round( dir.x ) == 1 then
|
||||||
|
newparam = WALLMX
|
||||||
|
elseif round( dir.x ) == -1 then
|
||||||
|
newparam = WALLPX
|
||||||
|
elseif round( dir.z ) == 1 then
|
||||||
|
newparam = WALLMZ
|
||||||
|
elseif round( dir.z ) == -1 then
|
||||||
|
newparam = WALLPZ
|
||||||
|
end
|
||||||
|
|
||||||
|
if und.name == 'air' then
|
||||||
|
minetest.env:add_node( pos, { name = 'doors:door_wood_a_c', param2 = newparam } )
|
||||||
|
minetest.env:add_node( upos, { name = 'doors:door_wood_b_c', param2 = newparam } )
|
||||||
|
elseif abv.name == 'air' then
|
||||||
|
minetest.env:add_node( pos, { name = 'doors:door_wood_b_c', param2 = newparam } )
|
||||||
|
minetest.env:add_node( apos, { name = 'doors:door_wood_a_c', param2 = newparam } )
|
||||||
|
else
|
||||||
|
minetest.env:remove_node( pos )
|
||||||
|
placer:get_inventory():add_item( "main", 'doors:door_wood' )
|
||||||
|
minetest.chat_send_player( placer:get_player_name(), 'not enough space' )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local on_door_punched = function( pos, node, puncher )
|
||||||
|
if string.find( node.name, 'doors:door_wood' ) == nil then return end
|
||||||
|
|
||||||
|
upos = { x = pos.x, y = pos.y - 1, z = pos.z }
|
||||||
|
apos = { x = pos.x, y = pos.y + 1, z = pos.z }
|
||||||
|
|
||||||
|
if string.find( node.name, '_c', -2 ) ~= nil then
|
||||||
|
if node.param2 == WALLPX then
|
||||||
|
newparam = WALLMZ
|
||||||
|
elseif node.param2 == WALLMZ then
|
||||||
|
newparam = WALLMX
|
||||||
|
elseif node.param2 == WALLMX then
|
||||||
|
newparam = WALLPZ
|
||||||
|
elseif node.param2 == WALLPZ then
|
||||||
|
newparam = WALLPX
|
||||||
|
end
|
||||||
|
elseif string.find( node.name, '_o', -2 ) ~= nil then
|
||||||
|
if node.param2 == WALLMZ then
|
||||||
|
newparam = WALLPX
|
||||||
|
elseif node.param2 == WALLMX then
|
||||||
|
newparam = WALLMZ
|
||||||
|
elseif node.param2 == WALLPZ then
|
||||||
|
newparam = WALLMX
|
||||||
|
elseif node.param2 == WALLPX then
|
||||||
|
newparam = WALLPZ
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if ( node.name == 'doors:door_wood_a_c' ) then
|
||||||
|
minetest.env:add_node( pos, { name = 'doors:door_wood_a_o', param2 = newparam } )
|
||||||
|
minetest.env:add_node( upos, { name = 'doors:door_wood_b_o', param2 = newparam } )
|
||||||
|
|
||||||
|
elseif ( node.name == 'doors:door_wood_b_c' ) then
|
||||||
|
minetest.env:add_node( pos, { name = 'doors:door_wood_b_o', param2 = newparam } )
|
||||||
|
minetest.env:add_node( apos, { name = 'doors:door_wood_a_o', param2 = newparam } )
|
||||||
|
|
||||||
|
elseif ( node.name == 'doors:door_wood_a_o' ) then
|
||||||
|
minetest.env:add_node( pos, { name = 'doors:door_wood_a_c', param2 = newparam } )
|
||||||
|
minetest.env:add_node( upos, { name = 'doors:door_wood_b_c', param2 = newparam } )
|
||||||
|
|
||||||
|
elseif ( node.name == 'doors:door_wood_b_o' ) then
|
||||||
|
minetest.env:add_node( pos, { name = 'doors:door_wood_b_c', param2 = newparam } )
|
||||||
|
minetest.env:add_node( apos, { name = 'doors:door_wood_a_c', param2 = newparam } )
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local on_door_digged = function( pos, node, digger )
|
||||||
|
upos = { x = pos.x, y = pos.y - 1, z = pos.z }
|
||||||
|
apos = { x = pos.x, y = pos.y + 1, z = pos.z }
|
||||||
|
|
||||||
|
if ( node.name == 'doors:door_wood_a_c' ) or ( node.name == 'doors:door_wood_a_o' ) then
|
||||||
|
minetest.env:remove_node( upos )
|
||||||
|
elseif ( node.name == 'doors:door_wood_b_c' ) or ( node.name == 'doors:door_wood_b_o' ) then
|
||||||
|
minetest.env:remove_node( apos )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
minetest.register_on_placenode( on_door_placed )
|
||||||
|
minetest.register_on_punchnode( on_door_punched )
|
||||||
|
minetest.register_on_dignode( on_door_digged )
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
BIN
mods/doors/textures/door_wood.png
Normal file
After Width: | Height: | Size: 166 B |
BIN
mods/doors/textures/door_wood_a.png
Normal file
After Width: | Height: | Size: 245 B |
BIN
mods/doors/textures/door_wood_a_r.png
Normal file
After Width: | Height: | Size: 249 B |
BIN
mods/doors/textures/door_wood_b.png
Normal file
After Width: | Height: | Size: 216 B |
BIN
mods/doors/textures/door_wood_b_r.png
Normal file
After Width: | Height: | Size: 216 B |
@ -1,652 +0,0 @@
|
|||||||
--
|
|
||||||
-- Experimental things
|
|
||||||
--
|
|
||||||
|
|
||||||
-- For testing random stuff
|
|
||||||
|
|
||||||
experimental = {}
|
|
||||||
|
|
||||||
timers_to_add = {}
|
|
||||||
timers = {}
|
|
||||||
minetest.register_globalstep(function(dtime)
|
|
||||||
for indes, timer in ipairs(timers_to_add) do
|
|
||||||
table.insert(timers, timer)
|
|
||||||
end
|
|
||||||
timers_to_add = {}
|
|
||||||
for index, timer in ipairs(timers) do
|
|
||||||
timer.time = timer.time - dtime
|
|
||||||
if timer.time <= 0 then
|
|
||||||
timer.func()
|
|
||||||
timers[index] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
after = function(time, func)
|
|
||||||
table.insert(timers_to_add, {time=time, func=func})
|
|
||||||
end
|
|
||||||
|
|
||||||
--[[
|
|
||||||
stepsound = -1
|
|
||||||
function test_sound()
|
|
||||||
print("test_sound")
|
|
||||||
stepsound = minetest.sound_play("default_grass_footstep", {gain=1.0})
|
|
||||||
after(2.0, test_sound)
|
|
||||||
--after(0.1, test_sound_stop)
|
|
||||||
end
|
|
||||||
function test_sound_stop()
|
|
||||||
print("test_sound_stop")
|
|
||||||
minetest.sound_stop(stepsound)
|
|
||||||
after(2.0, test_sound)
|
|
||||||
end
|
|
||||||
test_sound()
|
|
||||||
--]]
|
|
||||||
|
|
||||||
function on_step(dtime)
|
|
||||||
-- print("experimental on_step")
|
|
||||||
--[[
|
|
||||||
objs = minetest.env:get_objects_inside_radius({x=0,y=0,z=0}, 10)
|
|
||||||
for k, obj in pairs(objs) do
|
|
||||||
name = obj:get_player_name()
|
|
||||||
if name then
|
|
||||||
print(name.." at "..dump(obj:getpos()))
|
|
||||||
print(name.." dir: "..dump(obj:get_look_dir()))
|
|
||||||
print(name.." pitch: "..dump(obj:get_look_pitch()))
|
|
||||||
print(name.." yaw: "..dump(obj:get_look_yaw()))
|
|
||||||
else
|
|
||||||
print("Some object at "..dump(obj:getpos()))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--]]
|
|
||||||
--[[
|
|
||||||
if experimental.t1 == nil then
|
|
||||||
experimental.t1 = 0
|
|
||||||
end
|
|
||||||
experimental.t1 = experimental.t1 + dtime
|
|
||||||
if experimental.t1 >= 2 then
|
|
||||||
experimental.t1 = experimental.t1 - 2
|
|
||||||
minetest.log("time of day is "..minetest.env:get_timeofday())
|
|
||||||
if experimental.day then
|
|
||||||
minetest.log("forcing day->night")
|
|
||||||
experimental.day = false
|
|
||||||
minetest.env:set_timeofday(0.0)
|
|
||||||
else
|
|
||||||
minetest.log("forcing night->day")
|
|
||||||
experimental.day = true
|
|
||||||
minetest.env:set_timeofday(0.5)
|
|
||||||
end
|
|
||||||
minetest.log("time of day is "..minetest.env:get_timeofday())
|
|
||||||
end
|
|
||||||
--]]
|
|
||||||
end
|
|
||||||
minetest.register_globalstep(on_step)
|
|
||||||
|
|
||||||
-- An example furnace-thing implemented in Lua
|
|
||||||
|
|
||||||
--[[
|
|
||||||
minetest.register_node("experimental:luafurnace", {
|
|
||||||
tile_images = {"default_lava.png", "default_furnace_side.png",
|
|
||||||
"default_furnace_side.png", "default_furnace_side.png",
|
|
||||||
"default_furnace_side.png", "default_furnace_front.png"},
|
|
||||||
--inventory_image = "furnace_front.png",
|
|
||||||
inventory_image = minetest.inventorycube("default_furnace_front.png"),
|
|
||||||
paramtype = "facedir_simple",
|
|
||||||
metadata_name = "generic",
|
|
||||||
material = minetest.digprop_stonelike(3.0),
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_on_placenode(function(pos, newnode, placer)
|
|
||||||
if newnode.name == "experimental:luafurnace" then
|
|
||||||
local meta = minetest.env:get_meta(pos)
|
|
||||||
meta:inventory_set_list("fuel", {""})
|
|
||||||
meta:inventory_set_list("src", {""})
|
|
||||||
meta:inventory_set_list("dst", {"","","",""})
|
|
||||||
meta:set_inventory_draw_spec(
|
|
||||||
"invsize[8,9;]"
|
|
||||||
.."list[current_name;fuel;2,3;1,1;]"
|
|
||||||
.."list[current_name;src;2,1;1,1;]"
|
|
||||||
.."list[current_name;dst;5,1;2,2;]"
|
|
||||||
.."list[current_player;main;0,5;8,4;]"
|
|
||||||
)
|
|
||||||
|
|
||||||
local total_cooked = 0;
|
|
||||||
meta:set_string("total_cooked", total_cooked)
|
|
||||||
meta:set_infotext("Lua Furnace: total cooked: "..total_cooked)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"experimental:luafurnace"},
|
|
||||||
interval = 1.0,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
local meta = minetest.env:get_meta(pos)
|
|
||||||
for i, name in ipairs({
|
|
||||||
"fuel_totaltime",
|
|
||||||
"fuel_time",
|
|
||||||
"src_totaltime",
|
|
||||||
"src_time"
|
|
||||||
}) do
|
|
||||||
if not meta:get_string(name) then
|
|
||||||
meta:set_string(name, 0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
|
|
||||||
local fuelitem = inv:get_stack("fuel", 1):peek_item()
|
|
||||||
local srcitem = inv:get_stack("src", 1):peek_item()
|
|
||||||
--print("fuelitem="..dump(fuelitem))
|
|
||||||
--print("srcitem="..dump(srcitem))
|
|
||||||
|
|
||||||
local was_active = false
|
|
||||||
|
|
||||||
local src_cooktime = -1
|
|
||||||
local result_stackstring = nil
|
|
||||||
|
|
||||||
if srcitem then
|
|
||||||
local prop = get_item_definition(srcitem)
|
|
||||||
if prop and prop.cookresult_itemstring ~= "" then
|
|
||||||
result_stackstring = prop.cookresult_itemstring
|
|
||||||
src_cooktime = prop.furnace_cooktime or 3
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
print("src_cooktime="..dump(src_cooktime))
|
|
||||||
print("result_stackstring="..dump(result_stackstring))
|
|
||||||
|
|
||||||
if tonumber(meta:get_string("fuel_time")) < tonumber(meta:get_string("fuel_totaltime")) then
|
|
||||||
was_active = true
|
|
||||||
meta:set_string("fuel_time", tonumber(meta:get_string("fuel_time")) + 1)
|
|
||||||
meta:set_string("src_time", tonumber(meta:get_string("src_time")) + 1)
|
|
||||||
--print("result_stackstring="..dump(result_stackstring))
|
|
||||||
--print('tonumber(meta:get_string("src_time"))='..dump(tonumber(meta:get_string("src_time"))))
|
|
||||||
--print("src_cooktime="..dump(src_cooktime))
|
|
||||||
if result_stackstring and tonumber(meta:get_string("src_time")) >= src_cooktime and src_cooktime >= 0 then
|
|
||||||
-- Put result in "dst" list
|
|
||||||
success = inv:autoinsert_stackstring("dst", result_stackstring)
|
|
||||||
if not success then
|
|
||||||
print("Could not autoinsert '"..result_stackstring.."'")
|
|
||||||
end
|
|
||||||
-- If succeeded, take stuff from "src" list
|
|
||||||
if success then
|
|
||||||
srcstack = inv:get_stack("src", 1)
|
|
||||||
srcstack:take_item()
|
|
||||||
inv:set_stack("src", 1, srcstack)
|
|
||||||
end
|
|
||||||
meta:set_string("src_time", 0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if tonumber(meta:get_string("fuel_time")) < tonumber(meta:get_string("fuel_totaltime")) then
|
|
||||||
meta:set_infotext("Furnace active: "..(tonumber(meta:get_string("fuel_time"))/tonumber(meta:get_string("fuel_totaltime"))*100).."%")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local srcitem = inv:get_stack("src", 1):peek_item()
|
|
||||||
|
|
||||||
local src_cooktime = 0
|
|
||||||
local result_stackstring = nil
|
|
||||||
|
|
||||||
if srcitem then
|
|
||||||
local prop = get_item_definition(srcitem)
|
|
||||||
if prop and prop.cookresult_itemstring ~= "" then
|
|
||||||
result_stackstring = prop.cookresult_itemstring
|
|
||||||
src_cooktime = prop.furnace_cooktime or 3
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local fuelitem = inv:get_stack("fuel", 1):peek_item()
|
|
||||||
|
|
||||||
if not result_stackstring or not fuelitem then
|
|
||||||
if was_active then
|
|
||||||
meta:set_infotext("Furnace is empty")
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local burntime = -1
|
|
||||||
if fuelitem then
|
|
||||||
local prop = get_item_definition(fuelitem)
|
|
||||||
if prop then
|
|
||||||
burntime = prop.furnace_burntime or -1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if burntime <= 0 then
|
|
||||||
meta:set_infotext("Furnace out of fuel")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
meta:set_string("fuel_totaltime", burntime)
|
|
||||||
meta:set_string("fuel_time", 0)
|
|
||||||
|
|
||||||
local stack = inv:get_stack("fuel", 1)
|
|
||||||
stack:take_item()
|
|
||||||
inv:set_stack("fuel", 1, stack)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"experimental:luafurnace"},
|
|
||||||
interval = 1.0,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
local meta = minetest.env:get_meta(pos)
|
|
||||||
local fuellist = meta:inventory_get_list("fuel")
|
|
||||||
local srclist = meta:inventory_get_list("src")
|
|
||||||
local dstlist = meta:inventory_get_list("dst")
|
|
||||||
if fuellist == nil or srclist == nil or dstlist == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
_, srcitem = stackstring_take_item(srclist[1])
|
|
||||||
_, fuelitem = stackstring_take_item(fuellist[1])
|
|
||||||
if not srcitem or not fuelitem then return end
|
|
||||||
if fuelitem.type == "node" then
|
|
||||||
local prop = minetest.registered_nodes[fuelitem.name]
|
|
||||||
if prop == nil then return end
|
|
||||||
if prop.furnace_burntime < 0 then return end
|
|
||||||
else
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local resultstack = nil
|
|
||||||
if srcitem.type == "node" then
|
|
||||||
local prop = minetest.registered_nodes[srcitem.name]
|
|
||||||
if prop == nil then return end
|
|
||||||
if prop.cookresult_item == "" then return end
|
|
||||||
resultstack = prop.cookresult_item
|
|
||||||
else
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if resultstack == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
dstlist[1], success = stackstring_put_stackstring(dstlist[1], resultstack)
|
|
||||||
if not success then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
fuellist[1], _ = stackstring_take_item(fuellist[1])
|
|
||||||
srclist[1], _ = stackstring_take_item(srclist[1])
|
|
||||||
|
|
||||||
meta:inventory_set_list("fuel", fuellist)
|
|
||||||
meta:inventory_set_list("src", srclist)
|
|
||||||
meta:inventory_set_list("dst", dstlist)
|
|
||||||
|
|
||||||
local total_cooked = meta:get_string("total_cooked")
|
|
||||||
total_cooked = tonumber(total_cooked) + 1
|
|
||||||
meta:set_string("total_cooked", total_cooked)
|
|
||||||
meta:set_infotext("Lua Furnace: total cooked: "..total_cooked)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
minetest.register_craft({
|
|
||||||
output = 'node "experimental:luafurnace" 1',
|
|
||||||
recipe = {
|
|
||||||
{'node "default:cobble"', 'node "default:cobble"', 'node "default:cobble"'},
|
|
||||||
{'node "default:cobble"', 'node "default:steel_ingot"', 'node "default:cobble"'},
|
|
||||||
{'node "default:cobble"', 'node "default:cobble"', 'node "default:cobble"'},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
--]]
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Random stuff
|
|
||||||
--
|
|
||||||
|
|
||||||
--[[
|
|
||||||
minetest.register_tool("experimental:horribletool", {
|
|
||||||
image = "default_lava.png",
|
|
||||||
basetime = 2.0
|
|
||||||
dt_weight = 0.2
|
|
||||||
dt_crackiness = 0.2
|
|
||||||
dt_crumbliness = 0.2
|
|
||||||
dt_cuttability = 0.2
|
|
||||||
basedurability = 50
|
|
||||||
dd_weight = -5
|
|
||||||
dd_crackiness = -5
|
|
||||||
dd_crumbliness = -5
|
|
||||||
dd_cuttability = -5
|
|
||||||
})
|
|
||||||
--]]
|
|
||||||
|
|
||||||
--
|
|
||||||
-- TNT (not functional)
|
|
||||||
--
|
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = 'experimental:tnt',
|
|
||||||
recipe = {
|
|
||||||
{'default:wood'},
|
|
||||||
{'default:coal_lump'},
|
|
||||||
{'default:wood'}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("experimental:tnt", {
|
|
||||||
tile_images = {"default_tnt_top.png", "default_tnt_bottom.png",
|
|
||||||
"default_tnt_side.png", "default_tnt_side.png",
|
|
||||||
"default_tnt_side.png", "default_tnt_side.png"},
|
|
||||||
inventory_image = minetest.inventorycube("default_tnt_top.png",
|
|
||||||
"default_tnt_side.png", "default_tnt_side.png"),
|
|
||||||
drop = '', -- Get nothing
|
|
||||||
material = {
|
|
||||||
diggability = "not",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_on_punchnode(function(p, node)
|
|
||||||
if node.name == "experimental:tnt" then
|
|
||||||
minetest.env:remove_node(p)
|
|
||||||
minetest.env:add_entity(p, "experimental:tnt")
|
|
||||||
nodeupdate(p)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
local TNT = {
|
|
||||||
-- Static definition
|
|
||||||
physical = true, -- Collides with things
|
|
||||||
-- weight = 5,
|
|
||||||
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
|
||||||
visual = "cube",
|
|
||||||
textures = {"default_tnt_top.png", "default_tnt_bottom.png",
|
|
||||||
"default_tnt_side.png", "default_tnt_side.png",
|
|
||||||
"default_tnt_side.png", "default_tnt_side.png"},
|
|
||||||
-- Initial value for our timer
|
|
||||||
timer = 0,
|
|
||||||
-- Number of punches required to defuse
|
|
||||||
health = 1,
|
|
||||||
blinktimer = 0,
|
|
||||||
blinkstatus = true,
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Called when a TNT object is created
|
|
||||||
function TNT:on_activate(staticdata)
|
|
||||||
print("TNT:on_activate()")
|
|
||||||
self.object:setvelocity({x=0, y=4, z=0})
|
|
||||||
self.object:setacceleration({x=0, y=-10, z=0})
|
|
||||||
self.object:settexturemod("^[brighten")
|
|
||||||
self.object:set_armor_groups({immortal=1})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Called periodically
|
|
||||||
function TNT:on_step(dtime)
|
|
||||||
--print("TNT:on_step()")
|
|
||||||
self.timer = self.timer + dtime
|
|
||||||
self.blinktimer = self.blinktimer + dtime
|
|
||||||
if self.blinktimer > 0.5 then
|
|
||||||
self.blinktimer = self.blinktimer - 0.5
|
|
||||||
if self.blinkstatus then
|
|
||||||
self.object:settexturemod("")
|
|
||||||
else
|
|
||||||
self.object:settexturemod("^[brighten")
|
|
||||||
end
|
|
||||||
self.blinkstatus = not self.blinkstatus
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Called when object is punched
|
|
||||||
function TNT:on_punch(hitter)
|
|
||||||
print("TNT:on_punch()")
|
|
||||||
self.health = self.health - 1
|
|
||||||
if self.health <= 0 then
|
|
||||||
self.object:remove()
|
|
||||||
hitter:get_inventory():add_item("main", "experimental:tnt")
|
|
||||||
--hitter:set_hp(hitter:get_hp() - 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Called when object is right-clicked
|
|
||||||
function TNT:on_rightclick(clicker)
|
|
||||||
--pos = self.object:getpos()
|
|
||||||
--pos = {x=pos.x, y=pos.y+0.1, z=pos.z}
|
|
||||||
--self.object:moveto(pos, false)
|
|
||||||
end
|
|
||||||
|
|
||||||
--print("TNT dump: "..dump(TNT))
|
|
||||||
--print("Registering TNT");
|
|
||||||
minetest.register_entity("experimental:tnt", TNT)
|
|
||||||
|
|
||||||
-- Add TNT's old name also
|
|
||||||
minetest.register_alias("TNT", "experimental:tnt")
|
|
||||||
|
|
||||||
--
|
|
||||||
-- The dummyball!
|
|
||||||
--
|
|
||||||
|
|
||||||
minetest.register_entity("experimental:dummyball", {
|
|
||||||
-- Static definition
|
|
||||||
hp_max = 20,
|
|
||||||
physical = false,
|
|
||||||
collisionbox = {-0.4,-0.4,-0.4, 0.4,0.4,0.4},
|
|
||||||
visual = "sprite",
|
|
||||||
visual_size = {x=1, y=1},
|
|
||||||
textures = {"experimental_dummyball.png"},
|
|
||||||
spritediv = {x=1, y=3},
|
|
||||||
initial_sprite_basepos = {x=0, y=0},
|
|
||||||
-- Dynamic variables
|
|
||||||
phase = 0,
|
|
||||||
phasetimer = 0,
|
|
||||||
|
|
||||||
on_activate = function(self, staticdata)
|
|
||||||
minetest.log("Dummyball activated!")
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
|
||||||
self.phasetimer = self.phasetimer + dtime
|
|
||||||
if self.phasetimer > 2.0 then
|
|
||||||
self.phasetimer = self.phasetimer - 2.0
|
|
||||||
self.phase = self.phase + 1
|
|
||||||
if self.phase >= 3 then
|
|
||||||
self.phase = 0
|
|
||||||
end
|
|
||||||
self.object:setsprite({x=0, y=self.phase})
|
|
||||||
phasearmor = {
|
|
||||||
[0]={cracky=3},
|
|
||||||
[1]={crumbly=3},
|
|
||||||
[2]={fleshy=3}
|
|
||||||
}
|
|
||||||
self.object:set_armor_groups(phasearmor[self.phase])
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_punch = function(self, hitter)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_on_chat_message(function(name, message)
|
|
||||||
local cmd = "/dummyball"
|
|
||||||
if message:sub(0, #cmd) == cmd then
|
|
||||||
if not minetest.get_player_privs(name)["give"] then
|
|
||||||
minetest.chat_send_player(name, "you don't have permission to spawn (give)")
|
|
||||||
return true -- Handled chat message
|
|
||||||
end
|
|
||||||
if not minetest.get_player_privs(name)["interact"] then
|
|
||||||
minetest.chat_send_player(name, "you don't have permission to interact")
|
|
||||||
return true -- Handled chat message
|
|
||||||
end
|
|
||||||
local player = minetest.env:get_player_by_name(name)
|
|
||||||
if player == nil then
|
|
||||||
print("Unable to spawn entity, player is nil")
|
|
||||||
return true -- Handled chat message
|
|
||||||
end
|
|
||||||
local entityname = "experimental:dummyball"
|
|
||||||
local p = player:getpos()
|
|
||||||
p.y = p.y + 1
|
|
||||||
minetest.env:add_entity(p, entityname)
|
|
||||||
minetest.chat_send_player(name, '"'..entityname
|
|
||||||
..'" spawned.');
|
|
||||||
return true -- Handled chat message
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
--
|
|
||||||
-- A test entity for testing animated and yaw-modulated sprites
|
|
||||||
--
|
|
||||||
|
|
||||||
minetest.register_entity("experimental:testentity", {
|
|
||||||
-- Static definition
|
|
||||||
physical = true, -- Collides with things
|
|
||||||
-- weight = 5,
|
|
||||||
collisionbox = {-0.7,-1.35,-0.7, 0.7,1.0,0.7},
|
|
||||||
--collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
|
||||||
visual = "sprite",
|
|
||||||
visual_size = {x=2, y=3},
|
|
||||||
textures = {"dungeon_master.png^[makealpha:128,0,0^[makealpha:128,128,0"},
|
|
||||||
spritediv = {x=6, y=5},
|
|
||||||
initial_sprite_basepos = {x=0, y=0},
|
|
||||||
|
|
||||||
on_activate = function(self, staticdata)
|
|
||||||
print("testentity.on_activate")
|
|
||||||
self.object:setsprite({x=0,y=0}, 1, 0, true)
|
|
||||||
--self.object:setsprite({x=0,y=0}, 4, 0.3, true)
|
|
||||||
|
|
||||||
-- Set gravity
|
|
||||||
self.object:setacceleration({x=0, y=-10, z=0})
|
|
||||||
-- Jump a bit upwards
|
|
||||||
self.object:setvelocity({x=0, y=10, z=0})
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_punch = function(self, hitter)
|
|
||||||
self.object:remove()
|
|
||||||
hitter:add_to_inventory('craft testobject1 1')
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
--
|
|
||||||
-- More random stuff
|
|
||||||
--
|
|
||||||
|
|
||||||
minetest.register_on_respawnplayer(function(player)
|
|
||||||
print("on_respawnplayer")
|
|
||||||
-- player:setpos({x=0, y=30, z=0})
|
|
||||||
-- return true
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_on_generated(function(minp, maxp)
|
|
||||||
--print("on_generated: minp="..dump(minp).." maxp="..dump(maxp))
|
|
||||||
--cp = {x=(minp.x+maxp.x)/2, y=(minp.y+maxp.y)/2, z=(minp.z+maxp.z)/2}
|
|
||||||
--minetest.env:add_node(cp, {name="sand"})
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Example setting get
|
|
||||||
--print("setting max_users = " .. dump(minetest.setting_get("max_users")))
|
|
||||||
--print("setting asdf = " .. dump(minetest.setting_get("asdf")))
|
|
||||||
|
|
||||||
minetest.register_on_chat_message(function(name, message)
|
|
||||||
--[[print("on_chat_message: name="..dump(name).." message="..dump(message))
|
|
||||||
local cmd = "/testcommand"
|
|
||||||
if message:sub(0, #cmd) == cmd then
|
|
||||||
print(cmd.." invoked")
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
local cmd = "/help"
|
|
||||||
if message:sub(0, #cmd) == cmd then
|
|
||||||
print("script-overridden help command")
|
|
||||||
minetest.chat_send_all("script-overridden help command")
|
|
||||||
return true
|
|
||||||
end]]
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Grow papyrus on TNT every 10 seconds
|
|
||||||
--[[minetest.register_abm({
|
|
||||||
nodenames = {"TNT"},
|
|
||||||
interval = 10.0,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
print("TNT ABM action")
|
|
||||||
pos.y = pos.y + 1
|
|
||||||
minetest.env:add_node(pos, {name="papyrus"})
|
|
||||||
end,
|
|
||||||
})]]
|
|
||||||
|
|
||||||
-- Replace texts of alls signs with "foo" every 10 seconds
|
|
||||||
--[[minetest.register_abm({
|
|
||||||
nodenames = {"sign_wall"},
|
|
||||||
interval = 10.0,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
print("ABM: Sign text changed")
|
|
||||||
local meta = minetest.env:get_meta(pos)
|
|
||||||
meta:set_text("foo")
|
|
||||||
end,
|
|
||||||
})]]
|
|
||||||
|
|
||||||
--[[local ncpos = nil
|
|
||||||
local ncq = 1
|
|
||||||
local ncstuff = {
|
|
||||||
{2, 1, 0, 3}, {3, 0, 1, 2}, {4, -1, 0, 1}, {5, -1, 0, 1}, {6, 0, -1, 0},
|
|
||||||
{7, 0, -1, 0}, {8, 1, 0, 3}, {9, 1, 0, 3}, {10, 1, 0, 3}, {11, 0, 1, 2},
|
|
||||||
{12, 0, 1, 2}, {13, 0, 1, 2}, {14, -1, 0, 1}, {15, -1, 0, 1}, {16, -1, 0, 1},
|
|
||||||
{17, -1, 0, 1}, {18, 0, -1, 0}, {19, 0, -1, 0}, {20, 0, -1, 0}, {21, 0, -1, 0},
|
|
||||||
{22, 1, 0, 3}, {23, 1, 0, 3}, {24, 1, 0, 3}, {25, 1, 0, 3}, {10, 0, 1, 2}
|
|
||||||
}
|
|
||||||
local ncold = {}
|
|
||||||
local nctime = nil
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"dirt_with_grass"},
|
|
||||||
interval = 100000.0,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
if ncpos ~= nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if pos.x % 16 ~= 8 or pos.z % 16 ~= 8 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
pos.y = pos.y + 1
|
|
||||||
n = minetest.env:get_node(pos)
|
|
||||||
print(dump(n))
|
|
||||||
if n.name ~= "air" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
pos.y = pos.y + 2
|
|
||||||
ncpos = pos
|
|
||||||
nctime = os.clock()
|
|
||||||
minetest.env:add_node(ncpos, {name="nyancat"})
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"nyancat"},
|
|
||||||
interval = 1.0,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
if ncpos == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if pos.x == ncpos.x and pos.y == ncpos.y and pos.z == ncpos.z then
|
|
||||||
clock = os.clock()
|
|
||||||
if clock - nctime < 0.1 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
nctime = clock
|
|
||||||
|
|
||||||
s0 = ncstuff[ncq]
|
|
||||||
ncq = s0[1]
|
|
||||||
s1 = ncstuff[ncq]
|
|
||||||
p0 = pos
|
|
||||||
p1 = {x = p0.x + s0[2], y = p0.y, z = p0.z + s0[3]}
|
|
||||||
p2 = {x = p1.x + s1[2], y = p1.y, z = p1.z + s1[3]}
|
|
||||||
table.insert(ncold, 1, p0)
|
|
||||||
while #ncold >= 10 do
|
|
||||||
minetest.env:add_node(ncold[#ncold], {name="air"})
|
|
||||||
table.remove(ncold, #ncold)
|
|
||||||
end
|
|
||||||
minetest.env:add_node(p0, {name="nyancat_rainbow"})
|
|
||||||
minetest.env:add_node(p1, {name="nyancat", param1=s0[4]})
|
|
||||||
minetest.env:add_node(p2, {name="air"})
|
|
||||||
ncpos = p1
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})--]]
|
|
||||||
|
|
||||||
minetest.log("experimental modname="..dump(minetest.get_current_modname()))
|
|
||||||
minetest.log("experimental modpath="..dump(minetest.get_modpath("experimental")))
|
|
||||||
minetest.log("experimental worldpath="..dump(minetest.get_worldpath()))
|
|
||||||
|
|
||||||
-- END
|
|
Before Width: | Height: | Size: 838 B |
30
mods/fire/README.txt
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
Minetest 0.4 mod: fire
|
||||||
|
======================
|
||||||
|
|
||||||
|
License of source code:
|
||||||
|
-----------------------
|
||||||
|
Copyright (C) 2012 Perttu Ahola (celeron55) <celeron55@gmail.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
http://www.gnu.org/licenses/gpl-2.0.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) 2012 Perttu Ahola (celeron55) <celeron55@gmail.com>
|
||||||
|
|
||||||
|
fire_small.ogg sampled from:
|
||||||
|
http://www.freesound.org/people/dobroide/sounds/4211/
|
||||||
|
|
||||||
|
fire_large.ogg sampled from:
|
||||||
|
http://www.freesound.org/people/Dynamicell/sounds/17548/
|
||||||
|
|
188
mods/fire/init.lua
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
-- minetest/fire/init.lua
|
||||||
|
|
||||||
|
minetest.register_node("fire:basic_flame", {
|
||||||
|
description = "Fire",
|
||||||
|
drawtype = "glasslike",
|
||||||
|
tile_images = {"fire_basic_flame.png"},
|
||||||
|
light_source = 14,
|
||||||
|
groups = {igniter=3,dig_immediate=3},
|
||||||
|
drop = '',
|
||||||
|
walkable = false,
|
||||||
|
})
|
||||||
|
|
||||||
|
local fire = {}
|
||||||
|
fire.D = 6
|
||||||
|
-- key: position hash of low corner of area
|
||||||
|
-- value: {handle=sound handle, name=sound name}
|
||||||
|
fire.sounds = {}
|
||||||
|
|
||||||
|
function fire.get_area_p0p1(pos)
|
||||||
|
local p0 = {
|
||||||
|
x=math.floor(pos.x/fire.D)*fire.D,
|
||||||
|
y=math.floor(pos.y/fire.D)*fire.D,
|
||||||
|
z=math.floor(pos.z/fire.D)*fire.D,
|
||||||
|
}
|
||||||
|
local p1 = {
|
||||||
|
x=p0.x+fire.D-1,
|
||||||
|
y=p0.y+fire.D-1,
|
||||||
|
z=p0.z+fire.D-1
|
||||||
|
}
|
||||||
|
return p0, p1
|
||||||
|
end
|
||||||
|
|
||||||
|
function fire.update_sounds_around(pos)
|
||||||
|
local p0, p1 = fire.get_area_p0p1(pos)
|
||||||
|
local cp = {x=(p0.x+p1.x)/2, y=(p0.y+p1.y)/2, z=(p0.z+p1.z)/2}
|
||||||
|
local flames_p = minetest.env:find_nodes_in_area(p0, p1, {"fire:basic_flame"})
|
||||||
|
--print("number of flames at "..minetest.pos_to_string(p0).."/"
|
||||||
|
-- ..minetest.pos_to_string(p1)..": "..#flames_p)
|
||||||
|
local should_have_sound = (#flames_p > 0)
|
||||||
|
local wanted_sound = nil
|
||||||
|
if #flames_p >= 9 then
|
||||||
|
wanted_sound = {name="fire_large", gain=1.5}
|
||||||
|
elseif #flames_p > 0 then
|
||||||
|
wanted_sound = {name="fire_small", gain=1.5}
|
||||||
|
end
|
||||||
|
local p0_hash = minetest.hash_node_position(p0)
|
||||||
|
local sound = fire.sounds[p0_hash]
|
||||||
|
if not sound then
|
||||||
|
if should_have_sound then
|
||||||
|
fire.sounds[p0_hash] = {
|
||||||
|
handle = minetest.sound_play(wanted_sound, {pos=cp, loop=true}),
|
||||||
|
name = wanted_sound.name,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if not wanted_sound then
|
||||||
|
minetest.sound_stop(sound.handle)
|
||||||
|
fire.sounds[p0_hash] = nil
|
||||||
|
elseif sound.name ~= wanted_sound.name then
|
||||||
|
minetest.sound_stop(sound.handle)
|
||||||
|
fire.sounds[p0_hash] = {
|
||||||
|
handle = minetest.sound_play(wanted_sound, {pos=cp, loop=true}),
|
||||||
|
name = wanted_sound.name,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function fire.on_flame_add_at(pos)
|
||||||
|
--print("flame added at "..minetest.pos_to_string(pos))
|
||||||
|
fire.update_sounds_around(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
function fire.on_flame_remove_at(pos)
|
||||||
|
--print("flame removed at "..minetest.pos_to_string(pos))
|
||||||
|
fire.update_sounds_around(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
function fire.find_pos_for_flame_around(pos)
|
||||||
|
return minetest.env:find_node_near(pos, 1, {"air"})
|
||||||
|
end
|
||||||
|
|
||||||
|
function fire.flame_should_extinguish(pos)
|
||||||
|
--return minetest.env:find_node_near(pos, 1, {"group:puts_out_fire"})
|
||||||
|
local p0 = {x=pos.x-2, y=pos.y, z=pos.z-2}
|
||||||
|
local p1 = {x=pos.x+2, y=pos.y, z=pos.z+2}
|
||||||
|
local ps = minetest.env:find_nodes_in_area(p0, p1, {"group:puts_out_fire"})
|
||||||
|
return (#ps ~= 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_on_placenode(function(pos, newnode, placer)
|
||||||
|
if newnode.name == "fire:basic_flame" then
|
||||||
|
fire.on_flame_add_at(pos)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_dignode(function(pos, oldnode, digger)
|
||||||
|
if oldnode.name == "fire:basic_flame" then
|
||||||
|
fire.on_flame_remove_at(pos)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Ignite neighboring nodes
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"group:flammable"},
|
||||||
|
neighbors = {"group:igniter"},
|
||||||
|
interval = 1,
|
||||||
|
chance = 2,
|
||||||
|
action = function(p0, node, _, _)
|
||||||
|
-- If there is water or stuff like that around flame, don't ignite
|
||||||
|
if fire.flame_should_extinguish(p0) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local p = fire.find_pos_for_flame_around(p0)
|
||||||
|
if p then
|
||||||
|
minetest.env:set_node(p, {name="fire:basic_flame"})
|
||||||
|
fire.on_flame_add_at(p)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Rarely ignite things from far
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"group:igniter"},
|
||||||
|
neighbors = {"air"},
|
||||||
|
interval = 2,
|
||||||
|
chance = 10,
|
||||||
|
action = function(p0, node, _, _)
|
||||||
|
local reg = minetest.registered_nodes[node.name]
|
||||||
|
if not reg or not reg.groups.igniter or reg.groups.igniter < 2 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local d = reg.groups.igniter
|
||||||
|
local p = minetest.env:find_node_near(p0, d, {"group:flammable"})
|
||||||
|
if p then
|
||||||
|
-- If there is water or stuff like that around flame, don't ignite
|
||||||
|
if fire.flame_should_extinguish(p) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local p2 = fire.find_pos_for_flame_around(p)
|
||||||
|
if p2 then
|
||||||
|
minetest.env:set_node(p2, {name="fire:basic_flame"})
|
||||||
|
fire.on_flame_add_at(p2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Remove flammable nodes and flame
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"fire:basic_flame"},
|
||||||
|
interval = 1,
|
||||||
|
chance = 2,
|
||||||
|
action = function(p0, node, _, _)
|
||||||
|
-- If there is water or stuff like that around flame, remove flame
|
||||||
|
if fire.flame_should_extinguish(p0) then
|
||||||
|
minetest.env:remove_node(p0)
|
||||||
|
fire.on_flame_remove_at(p0)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- Make the following things rarer
|
||||||
|
if math.random(1,3) == 1 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- If there are no flammable nodes around flame, remove flame
|
||||||
|
if not minetest.env:find_node_near(p0, 1, {"group:flammable"}) then
|
||||||
|
minetest.env:remove_node(p0)
|
||||||
|
fire.on_flame_remove_at(p0)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if math.random(1,4) == 1 then
|
||||||
|
-- remove a flammable node around flame
|
||||||
|
local p = minetest.env:find_node_near(p0, 1, {"group:flammable"})
|
||||||
|
if p then
|
||||||
|
-- If there is water or stuff like that around flame, don't remove
|
||||||
|
if fire.flame_should_extinguish(p0) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
minetest.env:remove_node(p)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- remove flame
|
||||||
|
minetest.env:remove_node(p0)
|
||||||
|
fire.on_flame_remove_at(p0)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
BIN
mods/fire/sounds/fire_large.ogg
Normal file
BIN
mods/fire/sounds/fire_small.ogg
Normal file
BIN
mods/fire/textures/fire_basic_flame.png
Normal file
After Width: | Height: | Size: 847 B |