turtle graphics

Post Reply
jin_xi
Member
Posts: 165
Joined: Mon Jul 02, 2012 18:19

turtle graphics

by jin_xi » Post

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

User avatar
Topywo
Member
Posts: 1721
Joined: Fri May 18, 2012 20:27

by Topywo » Post

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.
Last edited by Topywo on Thu Aug 22, 2013 13:18, edited 1 time in total.

PenguinDad
Member
Posts: 122
Joined: Wed Apr 10, 2013 16:46

by PenguinDad » Post

That's amazing.

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

by paramat » Post

Very cool.

jin_xi
Member
Posts: 165
Joined: Mon Jul 02, 2012 18:19

by jin_xi » Post

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.

jin_xi
Member
Posts: 165
Joined: Mon Jul 02, 2012 18:19

by jin_xi » Post

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

Code: Select all

local candycane = function ()
   axiom = "Z11ARX24ARD"
   seg = "1M[Z90ARGG]2M[Z-90ARGG]"
   
   for i = 1, 1200 do
      add("[X"..(i%90*4).."AR"..seg.."]")
      if i%20==0 then
         if i>700 then
            add "Z8ARG"
         else
            add "G"
         end
      end
   end
   return axiom
end

ldef = {
   prog = candycane(),
   materials = { "wool:red", "wool:white" }
}

minetest.register_tool("turtle:spawn", {
   description = "turtle lua spawner",
   inventory_image = "default_stick.png",
   on_use = function(itemstack, user, pointed_thing)
      local pos = pointed_thing.above
      if not pos then return end
      turtle.spawn(pos, lddef)
   end,
})

User avatar
Topywo
Member
Posts: 1721
Joined: Fri May 18, 2012 20:27

by Topywo » Post

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.

jin_xi
Member
Posts: 165
Joined: Mon Jul 02, 2012 18:19

by jin_xi » Post

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
Last edited by jin_xi on Fri Aug 30, 2013 23:13, edited 1 time in total.

User avatar
darthvader
Member
Posts: 119
Joined: Sun Sep 08, 2013 14:35
Location: Death Star

by darthvader » Post

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)
Q. Why cant you write with a broken pencil?
A. Because its not in minetest.
(The original answer is "Because it's pointless.")

jin_xi
Member
Posts: 165
Joined: Mon Jul 02, 2012 18:19

by jin_xi » Post

this will only work with a git build of minetest.

User avatar
Mihobre
Member
Posts: 101
Joined: Tue Oct 30, 2012 08:45
Location: In your mouth

by Mihobre » Post

(ok, this ain't a spoiler, really, i just wanna shorten what jin_xi said about some stuff of forth turtle blah blah)
Spoiler
jin_xi wrote: 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.
huh? whah? i dinna understand...
I wanna fly!!!
I wanna have feathery wings of silver, blue, and white!!!
I wanna soar high and touch the sky!!!
I wanna fly!!!

User avatar
darthvader
Member
Posts: 119
Joined: Sun Sep 08, 2013 14:35
Location: Death Star

by darthvader » Post

jin_xi wrote:this will only work with a git build of minetest.
I don't understand.
Q. Why cant you write with a broken pencil?
A. Because its not in minetest.
(The original answer is "Because it's pointless.")

User avatar
LionsDen
Member
Posts: 530
Joined: Thu Jun 06, 2013 03:19

by LionsDen » Post

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.

User avatar
bobomb
Member
Posts: 162
Joined: Sat May 23, 2015 20:28
GitHub: bobombolo
IRC: bobomb

Re: turtle graphics

by bobomb » Post

anyone got a copy of this mod?

Sokomine
Member
Posts: 4276
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: turtle graphics

by Sokomine » Post

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.
Attachments
turtle-master.zip
(4.58 KiB) Downloaded 181 times
A list of my mods can be found here.

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests