ideas please

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

ideas please

Postby hiltropper » Thu Jan 13, 2011 6:30 pm

hello again :mrgreen:
would be really nice if someone had any ideas to make my code more precise.
it is a code for a battery that can be saved as phunlet without any problems (but needs a special laser to work right).
nothing wrong about everything but the discharge timer.code:
Code: Select all
(e)=>{
    textcolor = [sim.time, textcolor(1), textcolor(2), textcolor(3)];
    sim.time > (math.toint(textcolor(0)) + 0.97) ? {textcolor = [textcolor(0), (textcolor(1) - 1), textcolor(2), textcolor(3)]} : {textcolor = [textcolor(0), textcolor(1), textcolor(2), textcolor(3)]};
    textcolor(1) <= 0 ? {textcolor = [textcolor(0), 0, textcolor(2), textcolor(3)]} : {textcolor = [textcolor(0), textcolor(1), textcolor(2), textcolor(3)]}
}

as you can see , i use the sim.time and the integer sim.time +0.97 , every second the battery discharges 1. now whats the problem : low cpu notebook : 0.97 is right . high cpu pc : 0.99 is right ,at 0.97 the step is much more than 1.the timer depends on the fps .
no problem ,if you really want to change the value everytime you add another geom and the frames go low...
i don't expect another code ,i know them. if it were possible ,i would like my code corrected. ;)
any ideas?
thanks.
yup yup
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
hiltropper
 
Posts: 85
Joined: Mon Dec 20, 2010 12:02 pm
Location: Germany

Re: ideas please

Postby Kilinich » Tue Feb 08, 2011 2:54 pm

:crazy:
it's really hard to understand what's the problem and what you need...
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: ideas please

Postby TC42 » Tue Feb 08, 2011 10:45 pm

I have no idea what you are talking about... but I can guess :D
So you have sim.time + 0.97, so that on your PC, it discharges 1 every second. The problem is that the timer depends on the fps. If I'm right... you can set the system frame rate from inside algodoo
(devious and possibly evil? Yes. Will I download a scene that does that? Nope.)
So what you need to do is adjust the integer added to sim.time depending on the frame rate... Kilinich (or gradyfitz)do you have any ideas how to read the frame-rate?

Other than that, I suggest that you make it automatically increase the sim.frequency when you open the scene.
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: ideas please

Postby hiltropper » Wed Feb 09, 2011 6:43 pm

tc42 you are right.
sorry for that cryptic post i guess i had no time when i did it.
Other than that, I suggest that you make it automatically increase the sim.frequency when you open the scene.

is that possible if my cpu is to weak to do that? i mean this actually is the problem ,the script is the same but the faster the cpu the faster it discharges...
yup yup
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
hiltropper
 
Posts: 85
Joined: Mon Dec 20, 2010 12:02 pm
Location: Germany

Re: ideas please

Postby TC42 » Wed Feb 09, 2011 10:11 pm

Yes, increasing the sim.frequency will cause more lag, but results in a more accurate simulation. If you're using laser, then I suggest that you discharge the batteries mechanicle-scriptedly (spelling??) using a box/circle on a hinge that collides with something else (which has the discharge code in the oncollide menu) when the hinge is running. This way, the discharge rate will be more stable on PCs of varying power.
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: ideas please

Postby Someone Else » Wed Feb 09, 2011 10:48 pm

Presonally, I (or davidz40 for that matter) would use an alternating collider. This is the code I would probably use:
Code: Select all
collideWater = !collideWater

The coded geom should be a circle, hinged between two boxes. It should overlap both boxes. More overlap = more reliability, but more unwanted vibration.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: ideas please

Postby hiltropper » Sat Feb 12, 2011 1:07 pm

thanks so far if i get new results i will report it here.
yup yup
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
hiltropper
 
Posts: 85
Joined: Mon Dec 20, 2010 12:02 pm
Location: Germany


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 2 guests