function... function?
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
- Kia
- Eileen-Class Veteran
- Posts: 1040
- Joined: Fri Aug 01, 2014 7:49 am
- Deviantart: KiaAzad
- Discord: Kia#6810
- Contact:
Re: function... function?
can you tell me the name of this screen please?
Re: function... function?
Code: Select all
screen tim1:
timer 0.1 repeat True action If(prcnt > 99,true=SetVariable('prcnt', 0),false=SetVariable('prcnt', prcnt+1))
timer 0.1 repeat True action [SetVariable('prcnt', rndmzr(prcnt1)), SetVariable('prcnt2', rndmzr(prcnt2)), SetVariable('prcnt3', rndmzr(prcnt3))]
timer 0.1 repeat True action Execute(rndmzr)
Code: Select all
timer 0.1 repeat True action Execute(rndmzr)
Code: Select all
timer 0.1 repeat True action [SetVariable('prcnt', rndmzr(prcnt1)), SetVariable('prcnt2', rndmzr(prcnt2)), SetVariable('prcnt3', rndmzr(prcnt3))]
Besides calling a function that takes no arguments with an argument, you're doing it directly on screen without a wrapper and that's wrong by definition.
- Kia
- Eileen-Class Veteran
- Posts: 1040
- Joined: Fri Aug 01, 2014 7:49 am
- Deviantart: KiaAzad
- Discord: Kia#6810
- Contact:
Re: function... function?
I thinks you got a little confused here. that line has # at it's beginning and that means it's a comment so it gets ignored in compiling. (I kept it because it was working)
I Isolated your Execute in a new project and it's not working either.
I Isolated your Execute in a new project and it's not working either.
Code: Select all
define prcnt = 100
screen testis:
text "{size=100}[prcnt]" xalign 0.5 yalign 0.82
screen tim1:
timer 0.1 repeat True action Execute(rndmzr)
init python:
class Execute(Action):
def __init__(self, func, *args, **kwargs):
self.func = func
self.args = args
self.kwargs = kwargs
def __call__(self):
self.func(*self.args, **self.kwargs)
import random
def rndmzr():
prcnt=store.prcnt
if prcnt> 99:
prcnt= 0
else:
b = random.randint(-1, 3)
prcnt += b
label start:
"You've created a new Ren'Py game."
show screen testis
show screen tim1
"Once you add a story, pictures, and music, you can release it to the world!"
return
Re: function... function?
Everything's working.
You just don't have anything that would update the screens because this isn't a proper game. It's counting/executing just like it's supposed to. If you want to see the progress, add renpy.restart_interaction() to your function.
You just don't have anything that would update the screens because this isn't a proper game. It's counting/executing just like it's supposed to. If you want to see the progress, add renpy.restart_interaction() to your function.
- Kia
- Eileen-Class Veteran
- Posts: 1040
- Joined: Fri Aug 01, 2014 7:49 am
- Deviantart: KiaAzad
- Discord: Kia#6810
- Contact:
Re: function... function?
still nothing happening. I'll go back to my last working code and try to use curry ^_^
thanks
thanks
Re: function... function?
Code: Select all
define x = 100
screen testing:
timer 0.1 repeat True action Execute(my_func)
text "{size=100}[x]" align(0.5, 0.5)
init python:
class Execute(Action):
def __init__(self, func, *args, **kwargs):
self.func = func
self.args = args
self.kwargs = kwargs
def __call__(self):
self.func(*self.args, **self.kwargs)
def my_func():
if store.x > 99:
store.x = 0
else:
store.x += renpy.random.randint(-1, 3)
renpy.restart_interaction()
label start:
show screen testing
"You've created a new Ren'Py game."
"Once you add a story, pictures, and music, you can release it to the world!"
return
Re: function... function?
This was poor advice from my part:b3vad wrote:Code: Select all
init python: def rndmzr(): prcnt=store.prcnt if prcnt> 99: prcnt= 0 else: b = random.randint(-1, 3) prcnt += b
Code: Select all
def my_func():
x = store.x
if x > 99:
x = 0
else:
x += renpy.random.randint(-1, 3)
store.x = x
Code: Select all
def my_func():
global x
if x > 99:
x = 0
else:
x += renpy.random.randint(-1, 3)
Last edited by xela on Tue Aug 12, 2014 9:25 am, edited 1 time in total.
- Kia
- Eileen-Class Veteran
- Posts: 1040
- Joined: Fri Aug 01, 2014 7:49 am
- Deviantart: KiaAzad
- Discord: Kia#6810
- Contact:
Re: function... function?
yes the global did the trick ^_^ thank you xela
Who is online
Users browsing this forum: Donmai, Google [Bot]