Diference ?

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

Diference ?

Postby Skrubs » Sat May 26, 2018 4:16 pm

Diference between [ ] ,{ } and ( ) ?
Skrubs
 
Posts: 16
Joined: Tue Mar 06, 2018 7:36 pm

Re: Diference ?

Postby Xray » Tue May 29, 2018 11:30 pm

[ ] are used to enclose elements of an array.
example: scene.my.Array2 = [[x],[y],[z]]

{ } are used to enclose executable code which tell Thyme to execute the code when necessary.
example: var1 >= 3.14 ? {x=x+1}:{x=x-1}

( ) are used to enclose one or more arguments of a function, and are also used to enclose an index for reading the value of an array element (sadly, array elements cannot be directly written to in Thyme, only read).
examples:
_Func3(3.14);
scene.my.variable5 = scene.my.Array2(1);
This is not allowed: scene.my.Array2(1) = scene.my.variable5, although there are some work-arounds for writing to array elements.
User avatar
Xray
 
Posts: 500
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: Diference ?

Postby Skrubs » Mon Sep 17, 2018 3:01 am

Arguments ?
can you tell a list of a arguments ? if not show me the ones you know
Skrubs
 
Posts: 16
Joined: Tue Mar 06, 2018 7:36 pm

Re: Diference ?

Postby FRA32 » Mon Sep 24, 2018 12:55 pm

[] Describes arrays, or "multi variables" in other words.
pos = [0,0]

{} contains literal code that is executed when algodoo is told to do so.
Angle = {5}; <-Executes "5" everytime angle is needed, which just returns said number.
(e)=>{...}; <- executes the stuff in the {} whenever the event function is triggered by Algodoo.

() resembles mathematical paranthesis, i.e. (x+3)*5 = x*5+15, index arrays and parameters.
pos(0) would give you the X-Value of the position.
colorHSVA(3) would give you the A-Value of the color.
(e)=>{} allows algodoo to give you the "e-information" that the event generated.
math.vec.len(vel) passes the vel as a paremeter to the len function in algodoo.
FRA32
 
Posts: 227
Joined: Wed Dec 03, 2014 9:51 pm

Re: Diference ?

Postby Xray » Sun Oct 21, 2018 8:40 am

@FRA32 -- I already explained all that to him. Didn't you read my message before repeating everything that I said? :?
User avatar
Xray
 
Posts: 500
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: Diference ?

Postby FRA32 » Sun Oct 21, 2018 9:52 am

I did in fact read it, but wanted to present the answer in the way I understand it, along with more elaborate examples. I very much recognize your answer as informative aswell, but considering that Skrubs very likely never used a coding language before, many examples, along with explanations, can be very usefull. :thumbup:
FRA32
 
Posts: 227
Joined: Wed Dec 03, 2014 9:51 pm

Re: Diference ?

Postby Xray » Sat Nov 03, 2018 7:37 am

No problem! You are correct that sometimes another person might have a different way to describe a technical subject which may help the student to understand it better.

Thanks for your input! :thumbup:
User avatar
Xray
 
Posts: 500
Joined: Sun Jun 17, 2012 6:12 am
Location: USA


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 6 guests

cron