forked from mrkubax10/industrialtest
Fix rubber tree
This commit is contained in:
parent
f700a33a2a
commit
a3bdc55b37
46
mapgen.lua
46
mapgen.lua
@ -14,45 +14,13 @@
|
|||||||
-- You should have received a copy of the GNU General Public License
|
-- You should have received a copy of the GNU General Public License
|
||||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
local definition={
|
minetest.register_on_generated(function(minp,maxp,seed)
|
||||||
name="industrialtest:rubber_tree",
|
if industrialtest.random:next(1,100)>40 then
|
||||||
deco_type="schematic",
|
return
|
||||||
sidelen=16,
|
|
||||||
noise_params={
|
|
||||||
offset=0.024,
|
|
||||||
scale=0.015,
|
|
||||||
spread={x=250,y=250,z=250},
|
|
||||||
seed=2,
|
|
||||||
octaves=3,
|
|
||||||
persist=0.66
|
|
||||||
},
|
|
||||||
schematic={
|
|
||||||
size=vector.new(1,1,1),
|
|
||||||
data={
|
|
||||||
{
|
|
||||||
name="industrialtest:rubber_sapling",
|
|
||||||
param2=1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
flags="place_center_x, place_center_z"
|
|
||||||
}
|
|
||||||
if industrialtest.mtgAvailable then
|
|
||||||
definition.place_on={"default:dirt_with_grass"}
|
|
||||||
definition.biomes={"deciduous_forest"}
|
|
||||||
definition.y_max=31000
|
|
||||||
definition.y_min=1
|
|
||||||
end
|
end
|
||||||
minetest.register_decoration(definition)
|
local center=vector.new((maxp.x-minp.x)/2+ minp.x,(maxp.y-minp.y)/2+minp.y,(maxp.z-minp.z)/2+minp.z)
|
||||||
minetest.register_lbm({
|
local pos=minetest.find_node_near(center,maxp.x-minp.x,{"default:dirt_with_grass"})
|
||||||
label="Make rubber trees",
|
if pos then
|
||||||
name="industrialtest:make_rubber_trees",
|
|
||||||
nodenames={"industrialtest:rubber_sapling"},
|
|
||||||
run_at_every_load=false,
|
|
||||||
action=function(pos)
|
|
||||||
local node=minetest.get_node(pos)
|
|
||||||
if node.param2==1 then
|
|
||||||
industrialtest.makeRubberTree(pos)
|
industrialtest.makeRubberTree(pos)
|
||||||
end
|
end
|
||||||
end
|
end)
|
||||||
})
|
|
||||||
|
@ -214,9 +214,9 @@ end
|
|||||||
industrialtest.makeRubberTree=function(pos)
|
industrialtest.makeRubberTree=function(pos)
|
||||||
-- FIXME: Replace this with placing schematic
|
-- FIXME: Replace this with placing schematic
|
||||||
-- Taken and adapted from https://github.com/minetest/minetest_game/blob/master/mods/default/trees.lua#L182
|
-- Taken and adapted from https://github.com/minetest/minetest_game/blob/master/mods/default/trees.lua#L182
|
||||||
minetest.chat_send_all("Making rubber sapling")
|
|
||||||
local height=industrialtest.random:next(4,5)
|
local height=industrialtest.random:next(4,5)
|
||||||
local tree=minetest.get_content_id("industrialtest:rubber_wood")
|
local tree=minetest.get_content_id("industrialtest:rubber_wood")
|
||||||
|
local treeWithRubber=minetest.get_content_id("industrialtest:rubber_wood_with_rubber")
|
||||||
local leaves=minetest.get_content_id("industrialtest:rubber_leaves")
|
local leaves=minetest.get_content_id("industrialtest:rubber_leaves")
|
||||||
local air=minetest.get_content_id("air")
|
local air=minetest.get_content_id("air")
|
||||||
local ignore=minetest.get_content_id("ignore")
|
local ignore=minetest.get_content_id("ignore")
|
||||||
@ -235,7 +235,7 @@ industrialtest.makeRubberTree=function(pos)
|
|||||||
local index=area:index(pos.x,y,pos.z)
|
local index=area:index(pos.x,y,pos.z)
|
||||||
local id=data[index]
|
local id=data[index]
|
||||||
if id==air or id==ignore or id==leaves then
|
if id==air or id==ignore or id==leaves then
|
||||||
data[index]=tree
|
data[index]=(industrialtest.random:next(0,5)==1 and treeWithRubber or tree)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Force leaves near the trunk
|
-- Force leaves near the trunk
|
||||||
|
Loading…
Reference in New Issue
Block a user