Hello Markus,
EGSL knows no recursion ?
Of course, you can use recursion in EGSL, because you can use recursion in Lua (is there any serious programming language in which using recursion is not possible?). The problem in your example is variable scope. In Lua variables defined inside a function are by default global, while in other languages they may be by default local. You need to remember that when you copy/paste the code written in other language. Just add
local to x2 and y2 and it'll be working properly.
openwindow(600,600,0,"Tree")
backcolor(240,255,255)
function tree(x1, y1, a, d)
if d ~= 0 then
local x2 = x1 + math.cos(math.rad(a)) * d * 10
local y2 = y1 + math.sin(math.rad(a)) * d * 10
color(170,108,0)
line(x1, y1, x2, y2)
redraw()
tree(x2, y2, a - 20, d - 1)
tree(x2, y2, a + 20, d - 1)
end
end
tree(300, 550, -90, 9)
redraw()
inkey()