Page 1 of 1

turtle graphics

Posted: Thu Aug 22, 2013 12:24
by jin_xi
hello all,

this mod adds turtle graphics to minetest. it allows you to spawn generated structures using
luavoxemanipulators. it includes a tool with a simple forth like language for experimenting, but
it is also possible to generate structures in lua. here are some pictures of what it can do:

Image

Image

Image

https://github.com/obneq/turtle

to get the tool use /giveme turtle:tool
right click spawns, left click lets you edit programs, materials and find help.
the forth prompt uses a simple forth like language. here is a sample program to make a
circle:

: c 90 0 do [ U G G G G G G G G G D G ] 4 A Z R loop ; c

this program defines the word 'c' in the part between ':' and ';' and then calls 'c'. the capital letters and '[...]' are the primitives of the turtle systems, things like ':' and 'do...loop' are primitives of forth.

the part between the brackets lifts up the pen, moves forward, lowers pen and thus places one node. this is done 90 times while rotating the turtle around its Z axis. remember it is facing up initially.

you can then use the new word 'c' in other words. here is the spiral example:

: s 90 0 do [ c ] 5 A X R G loop ; s

idk if it is ok like this or if it would be less confusing to use pitch, yaw and roll for the turtle. pls try and give feedback.

if you like to generate turtle programs in lua remember they consist of both the program and a list of materials in one table. the program is just one long string consisting of turtle primitives.

i hope to integrate this into mapgen somehow, to allow for generated decorations in biomes,
dungeons and the like.

this will only work with a git build of minetest. license of code is WTFPL

Posted: Thu Aug 22, 2013 13:17
by Topywo
The images look good!

I myself didn't manage to create something. I just copied the sentence " : 90 0 ... loop ; c ". I probably should take more time to try to understand it. I saw a help which helped me a bit.

Some question with my first impression:
- I see you using a c for circle and a s for spiral. Are those standard or just names you gave them (so for example a d can also mean circle).
- Does the 90 stand for 90 degrees? and the 4 for 4 times?
- Why so much G's

So is it necessary to understand 'forth' to make it work?

Technically: When using creative inventory, moving through the pages switches from creative inventory to the turtle inventory and there moving through the pages moves back to creative etc. Plus escaping from the inventory/turtle is not possible anymore. Maybe it's because I use a 10 days old version of 0.4.7.

Summary: Looks like a fun mod to me, but I would like to have more 'dummies' explanation how to feed it or a link to a site where I could learn it.


Edit: Typo's.

Posted: Thu Aug 22, 2013 13:45
by PenguinDad
That's amazing.

Posted: Thu Aug 22, 2013 15:12
by paramat
Very cool.

Posted: Thu Aug 22, 2013 15:27
by jin_xi
Topywo wrote: Some question with my first impression:
- I see you using a c for circle and a s for spiral. Are those standard or just names you gave them (so for example a d can also mean circle).
- Does the 90 stand for 90 degrees? and the 4 for 4 times?
- Why so much G's
hey, thanks for trying. i know that forth is not the most friendly looking thing, but i chose to use it because of what it allows to do while still being relatively simple to implement. now for your questions:
- with ':' and ';' new words are defined, in the example above its called 'c' but it could be anything there, like so ': circle 90 0 do ... and so on ;' so, the first thing after a : is an arbitrary name.

- in this example 90 stands for how many times the loop is executed. '90 0 do ... loop' mean to repeat something for 90 times.

- the 4 in the example is the angle to rotate around the axis for everytime the loop is run. stuff like '4 A Z R' basically means 'rotate 4 degrees around z axis' Remember that this means the turtles z axis, not minetests!

- each of the many 'G's stands for one step the turtle moves forward. if the pen is down (the 'U' and 'D' commands control the pen) it places a node of either red wool (default) or whatever is in the first inventory slot in the turtle tool formspec.

so, some more examples:

a pole of wool: 'G G G G G G' this examples uses no forth, only turtle commands.

a right angle: 'G G G G G G G 90 A Z R G G G G G G G'

a pentagram: ': seg G G G G G G G G G G G ; : penta 90 A Z R seg 144 A Y R seg R seg R seg R seg ; penta' this looks better with longer seg(ments), so make many Gs...

a forth loop: ': XIIGs 12 0 do G loop ; XIIGs' gives a pole of wool 12 nodes high

arguments: ': Gs 0 do G loop ; 12 Gs' the word Gs now takes one argument, which is the number of how many times it should loop. after you have defined this word you can use it like so '20 Gs' or try '4000 Gs'

one big circle: ': big 360 0 do G 1 A Z R loop ; big' so we make a pole of 360 nodes, but rotate one degree each step, and we end up where we started.

hope these examples help.

unfortunately it seems some forth is necessary to use the tool... but if you like you can use lua to generate turtle programs.
Topywo wrote:Technically: When using creative inventory, moving through the pages switches from creative inventory to the turtle inventory and there moving through the pages moves back to creative etc. Plus escaping from the inventory/turtle is not possible anymore. Maybe it's because I use a 10 days old version of 0.4.7.
kahrl has done some formspec focus fixes lately, which is great, but yes, the inv for the tool is not perfect yet.

Posted: Thu Aug 22, 2013 15:33
by jin_xi
ps, you dont need forth to use it, you can use lua if you like. i did the candyland stuff using lua, here is the code and an example how to use it:
+ Spoiler

Posted: Thu Aug 22, 2013 22:19
by Topywo
Thanks for the explanation!

Your examples should help me out next time I try this mod out. It may take some while, but I'll post the result.

Posted: Thu Aug 29, 2013 17:28
by jin_xi
Image

here is a game that generates some biomes using turtle. put it into games/ folder according to how you have installed minetest, select it and start a new world using mapgen v7.

stay tuned

repo here:
https://github.com/obneq/minetest_j

Posted: Mon Sep 16, 2013 16:58
by darthvader
When I try, this pops up:
ServerError: Luaerror: error ...s\prosper\desktop\minetest\bin\..\mods\turtle/turtle.lua:24:attempt to call field 'get_content_id' ( nil value)

Posted: Mon Sep 16, 2013 20:09
by jin_xi
this will only work with a git build of minetest.

Posted: Tue Sep 17, 2013 11:56
by Mihobre
(ok, this ain't a spoiler, really, i just wanna shorten what jin_xi said about some stuff of forth turtle blah blah)
+ Spoiler
huh? whah? i dinna understand...

Posted: Tue Sep 17, 2013 14:02
by darthvader
jin_xi wrote:this will only work with a git build of minetest.
I don't understand.

Posted: Tue Sep 17, 2013 16:39
by LionsDen
darthvader wrote:
jin_xi wrote:this will only work with a git build of minetest.
I don't understand.
You need to either download a version of the latest development build from one of the people that are nice enough to make and post them in the forums or you need to download the files from github and compile your own copy in order to use this mod.

Re: turtle graphics

Posted: Sat Jun 13, 2015 02:47
by bobomb
anyone got a copy of this mod?

Re: turtle graphics

Posted: Thu Jun 18, 2015 00:26
by Sokomine
I've found what looks like an old copy of it. I don't know how recent it is. The author still seems to be present on github - perhaps you can contact him.