What do these things do

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

What do these things do

Postby pnvv » Tue Dec 15, 2015 3:25 am

I hope someone with more knowledge of Thyme can help me with this. I was digging into someone's code and I came across this weird thing which I don't know what it is. I thought they were local vars but they must not be because they dont have the _ in front of them.

Here's a picture for better understanding :D
Image
Image

(/)(°,,,°)(/)
User avatar
pnvv
 
Posts: 670
Joined: Tue Aug 26, 2014 11:46 pm
Location: Disunited States of America

Re: What do these things do

Postby faytree » Tue Dec 15, 2015 6:10 am

pnvv wrote:I hope someone with more knowledge of Thyme can help me with this. I was digging into someone's code and I came across this weird thing which I don't know what it is. I thought they were local vars but they must not be because they dont have the _ in front of them.

Here's a picture for better understanding :D
Image


Maybe those are variables, some guys did that..
waiting for semester break to come...
User avatar
faytree
 
Posts: 947
Joined: Mon Nov 05, 2012 1:37 pm
Location: Selangor, Malaysia

Re: What do these things do

Postby electronicboy » Tue Dec 15, 2015 5:04 pm

They'll be local vars, Basically, only variables starting with _ are serialised upon saving, here we have := which sorta also forces the variable to be created if it doesn't exist, hence removing the need to serialise them into the scene file;
When asking for help, READ THE STICKIES!
electronicboy
 
Posts: 1694
Joined: Mon Aug 31, 2009 6:18 pm

Re: What do these things do

Postby pnvv » Tue Dec 15, 2015 7:37 pm

electronicboy wrote:They'll be local vars, Basically, only variables starting with _ are serialised upon saving, here we have := which sorta also forces the variable to be created if it doesn't exist, hence removing the need to serialise them into the scene file;

Ah, ok. I get it now, thanks guys.
Image

(/)(°,,,°)(/)
User avatar
pnvv
 
Posts: 670
Joined: Tue Aug 26, 2014 11:46 pm
Location: Disunited States of America

Re: What do these things do

Postby FRA32 » Wed Dec 16, 2015 6:06 pm

Global variables are usually prefixed with _ to make them permanent. Local var's are created by writing any word or name in front of an '=', they will then be usable until scope they've been created in expires.
FRA32
 
Posts: 229
Joined: Wed Dec 03, 2014 9:51 pm

Re: What do these things do

Postby Kilinich » Thu Dec 17, 2015 9:33 am

FRA32 wrote:Global variables are usually prefixed with _ to make them permanent. Local var's are created by writing any word or name in front of an '=', they will then be usable until scope they've been created in expires.


Don't confuse people! _ is just serialized and saved with scene variables, it's not related with scope. Local variables creates inside { } with := and they not visible outside. Also you could create variabls in object's scope, for example inside box object event e.this.a := 1 (will be removed after reload) or e.this._a := 1 (will be saved with scene).
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: What do these things do

Postby FRA32 » Thu Dec 17, 2015 8:51 pm

Yeah, like I said, _ makes it permanent(saved by scene), while without _ it is local and this way only temporary, and also not accessible everywhere. Of course I don't want to confuse people but I am coding java in my freetime, so excuse if I use the incorrect words :)
FRA32
 
Posts: 229
Joined: Wed Dec 03, 2014 9:51 pm

Re: What do these things do

Postby Kilinich » Fri Dec 18, 2015 2:30 am

FRA32 wrote:Yeah, like I said, _ makes it permanent(saved by scene), while without _ it is local and this way only temporary, and also not accessible everywhere. Of course I don't want to confuse people but I am coding java in my freetime, so excuse if I use the incorrect words :)

You still misunderstand or incorrectly describe. Variables with _ is local too. There is no difference between code {a:=1; b:=1, a+b} and {_a:=1; _b:=1, _a+_b}. The only difference is _variable in object will be serialized and saved.
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


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 17 guests