Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
[SOLVED] Calling methods every n seconds in scene.update()
-
@Splefix said:
@themusicman Haha brother, God just helped me figure that out myself! Thank you very much though for your answer! God bless you abundantly and may peace be with you!!!
Nice meeting you brother!
You're very welcome matey...
-
@JonB Concerning your question above: Can you show me how to update the text? This is my first time using the scene module.
Also, say I have two args, and the function is out of the MyScene class: How would I tackle this?
-
see my example, the .text attribute is used to update text.
note, you probably want to set the anchor_point=(0,0) for left justification, unless you want the text centered.Lambdas accept multiple args
lambda arg1,arg2:some_function(arg1, arg2) -
If you do a lot of these types of things, I (once again) promote the scripter, which works with views and scenes, for example like this:
from scene import * from scripter import * class MyScene (Scene): def setup(self): self.ship = SpriteNode('spc:PlayerShip1Orange') self.ship.position = self.size / 2 self.add_child(self.ship) self.do_a_thing_every_second() @script def do_a_thing_every_second(self): while(True): print('do the thing') yield 1.0 run(MyScene())
-
@mikael Hi friend, I am having trouble with importing scripter? It says that this is invalid syntax:
from scripter import *
-
@Splefix, as an unfortunate barrier to entry, you need to download
scripter.py
from the link and place it in your site-packages. -
@mikael Hey sorry man, I am new to Pythonista, especially concerning the installation you are talking about. Can you please help me install scripter? If it isn’t too much trouble. I haven’t worked with github before either.
-
@Splefix, do you have stash installed? If not, recommend that you install it anyway. (Google for ”pythonista stash” for instructions).
When you have it, start stash, then:
StaSh v0.7.0 on python 3.6.1 Warning: you are running StaSh in python3. Some commands may not work correctly in python3. Please help us improving StaSh by reporting bugs on github. Tip: Bring a background job to foreground with fg JOB_ID [~/Documents]$ cd site-packages [site-packages]$ wget https://raw.githubusercontent.com/mikaelho/scripter/master/scripter.py
-
@mikael Hey man, I did that, but now I get the following error:
- Name 'script' is not defined
This concerns the following code:
@script def do_a_thing_every_second(self): if self.auto_amount >= 1: while(True): spawn_bubble(self, False) yield 1.0
-
@Splefix, do you have the file in site-packages and still have the import statement at the top? Import statement with the asterisk and not just
import scripter
? -
Yes, but it is okay. I will just use the time module instead. Thank you all for your help. God bless you all in Jesus Christ’s MIGHTY NAME!!!!