Generate random tree
If you put a few trees next to each other:
local TREE = elements.allocate("SSCCSSCC", "TREE")
elements.element(elements.SSCCSSCC_PT_TREE, elements.element(elements.DEFAULT_PT_IRON))
elements.property(elements.SSCCSSCC_PT_TREE, "Name", "TREE")
elements.property(elements.SSCCSSCC_PT_TREE, "Description", "Generate random tree")
elements.property(elements.SSCCSSCC_PT_TREE, "Colour", 0x00FF00)
elements.property(elements.SSCCSSCC_PT_TREE, "MenuSection", 11)
r=0
local function test(i,x,y,s,n)
local k=math.random(40,55)
local kk=math.random(40,55)
local l=math.random(55,90)
local ll=math.random(10,22)
local lll=math.random(10,22)
for o = 1 , l do
local b=math.random(0,10)
if b==1 then
local r=r+1
tpt.create(x+r,y-o, 'wood')
x=x+1
elseif b==2 then
local r=r-1
tpt.create(x+r,y-o, 'wood')
x=x-1
else
tpt.create(x,y-o, 'wood')
end
if o==39 then
for i = 1 , 2 do
tpt.create(x+i,y-39, 'plnt')
end
for i = 1 , 2 do
tpt.create(x-i,y-39, 'plnt')
end
end
if o==40 then
for i = 1 , 3 do
tpt.create(x+i,y-40, 'plnt')
end
for i = 1 , 3 do
tpt.create(x-i,y-40, 'plnt')
end
end
if o==k then
yb=y
for i = 1 , ll do
local q=math.random(0,4)
if q==1 then
tpt.create(x+i,y-k-i, 'wood')
y=y+1
elseif b==2 then
tpt.create(x+i,y-k-i, 'wood')
y=y-1
else
tpt.create(x+i,y-k-i, 'wood')
end
tpt.create(x+i,y-k-i, 'vine')
end
y=yb
end
if o==kk then
yb=y
for i = 1 , lll do
local q=math.random(0,4)
if q==1 then
tpt.create(x-i,y-kk-i, 'wood')
y=y+1
elseif b==2 then
tpt.create(x-i,y-kk-i, 'wood')
y=y-1
else
tpt.create(x-i,y-kk-i, 'wood')
end
tpt.create(x-i,y-kk-i, 'vine')
end
y=yb
end
if o==l-1 then
tpt.create(x,y-l, 'vine')
end
end
tpt.set_property("type","wood","tree")
end
tpt.element_func(test,TREE)
great realization!
That's so cool! They should add something like that in the offical.
That is very cool.