Physion

  • Increase font size
  • Default font size
  • Decrease font size
Welcome, Guest
Username Password: Remember me

How to set counter value on start of simulation?
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: How to set counter value on start of simulation?

Re: How to set counter value on start of simulation? 6 years, 8 months ago #104

  • Lynxx
  • OFFLINE
  • Gold Boarder
  • Java/C#-Developer
  • Posts: 223
admin wrote:

 
...
circ.OnContact = "this.Brush = other.Brush;";
...
 

i found out circ.setOnContact("..."); works too.

And finally what is the name for onUpdate-Object in world ?
I don't understand what you mean by that. Could you rephrase?

circ.setOnUpdate("...") or circ.onUpdate = "...";
but i thought they must be registered with world, like "world.started.connect(item4.onStart)";

BTW: I noticed, even after deleting objects, the functions in them are still beeing executed! I did a generator object with name "mother" and the created circles call "mother.onUpdate()" and after starting/stopping a few times i noticed the object creating even speed up after deleting all created objects. Only saving/reloading removed the objects completly.

And BTW: The Code-Tag here in the Forum should used a "<PRE>"
(preformatted)-tag.
Thanks for bringing that up. I hadn't realize that there was an option for prettier code formatting in my forum administration. Now it should be much better


Edit: Got some quote-tags wrong
Infinity is vast, especially near end.
bye, Lynxx
Last Edit: 6 years, 8 months ago by Lynxx.

Re: How to set counter value on start of simulation? 6 years, 8 months ago #113

  • Lynxx
  • OFFLINE
  • Gold Boarder
  • Java/C#-Developer
  • Posts: 223
Why doesn't this work in onUpdate ?
 
if (this.onStart == null) {
this.onStart = function() { this.Text = "STARTED!"; }
world.started.connect(this.onStart);
}
if (this.onStop == null) {
this.onStop = function() { this.Text = "STOPPED!"; }
world.stopped.connect(this.onStop);
}


Edit: Found out item4.Text = "STARTED!"; works, seems there is no "this" in onStart/onStop;

2nd Edit: Got another question, how to remove connected Events ?
I tried disconnect but get Error: Function.prototype.disconnect: failed to disconnect from PhysicsWorld::started(), and is it possible to check if a function is connected to started/stopped ?
Infinity is vast, especially near end.
bye, Lynxx
Last Edit: 6 years, 8 months ago by Lynxx.

Re: How to set counter value on start of simulation? 6 years, 8 months ago #123

  • Dimitris
  • OFFLINE
  • Administrator
  • Posts: 218
Hello Lynxx,

BTW: I noticed, even after deleting objects, the functions in them are still beeing executed! I did a generator object with name "mother" and the created circles call "mother.onUpdate()" and after starting/stopping a few times i noticed the object creating even speed up after deleting all created objects. Only saving/reloading removed the objects completly.
Okay I took a look in the code to find out that this is yet another bug. This is happening due to the undo/redo functionality. You see when you delete an object it is not actually deleted it simply becomes inactive. The reason of this bug is that I forgot to check if a body is active before executing its "OnUpdate" property... Thanks for the bug report!

This bug was fixed in Version 1.01



You can remove the connections just like you add them:

Connect:
 
item4.onStart = function() { item4.Text = "STARTED!"; }
item4.onStop = function() { item4.Text = "STOPPED!"; }
 
world.started.connect(item4.onStart);
world.stopped.connect(item4.onStop);
 


Disconnect:
 
world.started.disconnect(item4.onStart);
world.stopped.disconnect(item4.onStop);
 


It should work (at least it works for me!)
Last Edit: 6 years, 7 months ago by Dimitris.

Re: How to set counter value on start of simulation? 6 years, 8 months ago #133

  • Lynxx
  • OFFLINE
  • Gold Boarder
  • Java/C#-Developer
  • Posts: 223
admin wrote:

You can remove the connections just like you add them:
...
Disconnect:
 
world.started.disconnect(item4.onStart);
 


It should work (at least it works for me!)


Not fully, see my Bug report.
Infinity is vast, especially near end.
bye, Lynxx
  • Page:
  • 1
  • 2
Moderators: Glenn555
Time to create page: 0.14 seconds