Thyme 2.0

About advanced scenes, and the Thyme scripting language used in Algodoo.

Thyme 2.0

Postby Kilinich » Mon Oct 31, 2011 1:47 pm

Did you notice new string.length function? Now we know size of lists. With readable it's possible to get surfaces values of existing polygon and do some magic with it. :idea:

btw, just another (simpler) extended for-cycle:

n1 and n2 must be integer, n2 >= n1

Code: Select all
scene.my.xFor = (n1, n2, code) => {
  n2 > n1 ? {
    m := (n1 + n2) / 2;
    scene.my.xFor(n1, m, code);
    scene.my.xFor(m + 1, n2, code)
  } : {code(n1)}
}


usage example, ten thousands cycles:

scene.my.xFor(0,10000, (n) => {print(n)})
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Thyme 2.0

Postby Kilinich » Mon Oct 31, 2011 10:25 pm

Yeaaaa!
It was impossible, but now it's just a simple trick :ugeek:

Rating: rated 8
Filesize: 187.29 kB
Comments: 20
Ratings: 12
download
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Thyme 2.0

Postby tatt61880 » Tue Nov 01, 2011 5:27 am

Kilinich's scene is epoch making for Thyme scripting. :clap:
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan

Re: Thyme 2.0

Postby KarateBrot » Wed Nov 02, 2011 4:42 am

the melting ice is amazing! btw how do you find out about new thyme commands?
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Thyme 2.0

Postby Kilinich » Wed Nov 02, 2011 7:30 am

KarateBrot wrote:the melting ice is amazing! btw how do you find out about new thyme commands?


Just press tab in console, and search for something new.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Thyme 2.0

Postby KarateBrot » Wed Nov 02, 2011 3:43 pm

yeah i know but for example if you have commands that are not in the console like the (put some id commands here).pos and stuff
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Thyme 2.0

Postby Kilinich » Wed Nov 02, 2011 9:18 pm

oh, sometimes I just make a wild guess =)
Did you try layers btw? It's cool! - scene.addLayer / scene.selectLayer / layer in geom.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Thyme 2.0

Postby KarateBrot » Thu Nov 03, 2011 12:40 am

haha nice :thumbup:

no how does it work?^^
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Thyme 2.0

Postby tatt61880 » Sat Apr 14, 2012 3:22 am

I've improved xFor function. ;)

* FIXED: Negative value issue.
> xFor(-2, 0, (n)=>{n}) ... "Stack overflow!"
> xFor_improved(-2, 0, (n)=>{n}) ... -2, -1, 0
* FIXED: Larger to lower issue.
> xFor( 2, 0, (n)=>{n}) ... 2
> xFor_improved( 2, 0, (n)=>{n}) ... 2, 1, 0
Code: Select all
Scene.my.xFor_improved := (n1, n2, code)=>{
   (n2 % 1 != 0 || n1 % 1 != 0) ? {
      print ("ERROR - Usage: Scene.my.xFor_improved(int, int, func)")
   } : {
      (n1 == n2) ? {
         code(n1)
      } : {
         m := ((n1 + n2) % 2 == 0) ?
             {(n1 + n2) / 2} :
             {(n1 + n2 - 1) / 2}; /* (n1, n2) = (-2, -1) => m = -2 */
         (n2 > n1) ? {
            Scene.my.xFor_improved( n1,   m, code);
            Scene.my.xFor_improved(m+1,  n2, code)
         } : {
            Scene.my.xFor_improved( n1, m+1, code);
            Scene.my.xFor_improved(  m,  n2, code)
         }
      }
   }
};


NOTE: Kilinich's xFor (below) is good enough when 0 <= n1 <= n2
Code: Select all
scene.my.xFor = (n1, n2, code) => {
      n2 > n1 ? {
        m := (n1 + n2) / 2;
        scene.my.xFor(n1, m, code);
        scene.my.xFor(m + 1, n2, code)
      } : {code(n1)}
    }
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 11 guests

cron