Changing Box text on collide.

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

Changing Box text on collide.

Postby Gameman » Sun Dec 06, 2009 3:04 am

This should be an easy fix. I need the boxes text to change when it hits something.

Code: Select all
on collide = (e)=>{this.text = "o"}
Image
Next Contest: Cannons!
I would appreciate it if someone would create an avatar for me that matches my signature.
User avatar
Gameman
 
Posts: 18
Joined: Tue Dec 01, 2009 10:26 pm

Re: Changing Box text on collide.

Postby RicH » Sun Dec 06, 2009 3:13 am

It should be:
Code: Select all
(e)=>{e.this.text = "o"}
Last edited by RicH on Mon Dec 07, 2009 12:41 pm, edited 1 time in total.
Millions of voices suddenly cried out in terror, and were suddenly silenced. Something terrible has happened.
User avatar
RicH
[Funniest Person 2010]
 
Posts: 2043
Joined: Tue Sep 01, 2009 9:01 am

Re: Changing Box text on collide.

Postby standardtoaster » Sun Dec 06, 2009 3:29 am

To make sure that you don't mess up because I have a feeling that you will copy/paste RicH's code and complain.
Code: Select all
(e)=>{e.this.text = "o"}

That will work. Not meaning to diss you or anything, RicH, but I just know that most people that are starting scripting will copy and paste a script that is like yours, one that has something not related to scripting ie. [b], and then complain. :)
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Changing Box text on collide.

Postby Gameman » Sun Dec 06, 2009 4:46 am

ok thanks guys! but what if I want the box to increase its numeral value? So if its hit 3 times it displays a value of "3".

again I failed to create a proper script.
Code: Select all
(e)=>{e.this.text = lol; lol = lol + 1 }
Image
Next Contest: Cannons!
I would appreciate it if someone would create an avatar for me that matches my signature.
User avatar
Gameman
 
Posts: 18
Joined: Tue Dec 01, 2009 10:26 pm

Re: Changing Box text on collide.

Postby standardtoaster » Sun Dec 06, 2009 5:00 am

Easy. For this we will take use of the controllerAcc.
Code: Select all
e.this.text = "" + e.this.controllerAcc; e.this.controllerAcc = e.this.controllerAcc + 1

Make sure the controllerAcc is set to zero when you start.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Changing Box text on collide.

Postby Gameman » Sun Dec 06, 2009 5:29 am

Ah, thanks! I wonder if you can do this with a variable.
Image
Next Contest: Cannons!
I would appreciate it if someone would create an avatar for me that matches my signature.
User avatar
Gameman
 
Posts: 18
Joined: Tue Dec 01, 2009 10:26 pm

Re: Changing Box text on collide.

Postby standardtoaster » Sun Dec 06, 2009 6:12 am

You can. It's the same principle.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Changing Box text on collide.

Postby KarateBrot » Sun Dec 06, 2009 5:09 pm

it didn't work with your variable maybe because you didn't declare it. before using a self made variable you have to declare it in the console.
so open the console and type in scene.my.lol := 0
type in scene.my. in front of it because otherwise the variable won't be saved to your scene and only to your config file. so if you upload this scene to phunbox it will not work for other people. only for you. so everytime you make variables use scene.my.blabla variables.
Last edited by KarateBrot on Sun Dec 06, 2009 6:10 pm, edited 1 time in total.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Changing Box text on collide.

Postby standardtoaster » Sun Dec 06, 2009 5:40 pm

Why would he have to use scene.my.lol := 0 instead of scene.my.lol = 0?
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Changing Box text on collide.

Postby KarateBrot » Sun Dec 06, 2009 6:10 pm

just for declaring the variable. := is the declaring sign. sometimes if you declare a variable with = it won't work and the variable won't be saved to the scene. := is bomb-proof
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Changing Box text on collide.

Postby standardtoaster » Sun Dec 06, 2009 8:18 pm

Weird. I have never had that happen to me. I'll keep it in mind though.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Changing Box text on collide.

Postby KarateBrot » Sun Dec 06, 2009 8:25 pm

it happened to me twice or thrice.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Changing Box text on collide.

Postby RicH » Mon Dec 07, 2009 12:41 pm

Well, I got accustomed to vBulletin and it worked that way in their code tags. Hmm, guess it doesn't work that way here.
Millions of voices suddenly cried out in terror, and were suddenly silenced. Something terrible has happened.
User avatar
RicH
[Funniest Person 2010]
 
Posts: 2043
Joined: Tue Sep 01, 2009 9:01 am


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 2 guests

cron