dsrw / enu

A Logo-like 3D environment, implemented in Nim
http://getenu.com
MIT License
449 stars 15 forks source link

Question: Is it possible to get x,y from block? #14

Closed inv2004 closed 3 years ago

inv2004 commented 3 years ago

Hello,

1st: Thank you for the windows-version. I think it makes setup to kids' laptop much easier.

I want to build something like wall in loop. I do up() every iteration, but, I did not find easy way to return to start point?

Thank you,

dsrw commented 3 years ago

You can't currently get or set x, y, z coordinates from a block. I plan to implement it at some point, but I don't think it will be in the next release. Possibly the one after that (0.3).

However, you can save() your current position, direction, and color, then restore() it later. So, to build a wall, you could do something like this:

10.times:
  save()
  forward 10
  restore()
  up()

You can also give the save and restore points names, if you need to manage more than one:

8.times:
  save "start"
  10.times:
    save()
    forward 10
    restore()
    up()
  restore "start"
  turn_right 45

image

Thanks for the question. I hope that helps.