I have some code on renpy with atl. But it don't works properly. If I use calc and get value of -50.0 + ( 300.0 * math.tan( 32.7 ) ) and put it in renpy - it works well. But I want for renpy to calc it. Sorry for my English.
And how can I print calc result to console? If I use python.print(...) I get error.
How to do math properly?
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.
- rururubell
- Newbie
- Posts: 13
- Joined: Mon Sep 30, 2019 4:00 am
- Deviantart: rururubell
- Contact:
How to do math properly?
Sorry for my English!
Re: How to do math properly?
Be sure to import math.
Use a function that return the value instead of putting the formula directly.
As for console outputs:
https://www.renpy.org/doc/html/develope ... oper-tools
Probably is the renpy.log() thing you're searching about.
(you look knowledgeable enough to do this on your own).
Use a function that return the value instead of putting the formula directly.
Code: Select all
init python:
import math
def uncanny_math(a,b,c):
return a+ ( b * math.tan( c ) )
###
xpos (whatever) ypos uncanny_math(-50.0, 300.0, 32.7)
https://www.renpy.org/doc/html/develope ... oper-tools
Probably is the renpy.log() thing you're searching about.
(you look knowledgeable enough to do this on your own).
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.
10 ? "RENPY"
20 GOTO 10
RUN
10 ? "RENPY"
20 GOTO 10
RUN
- rururubell
- Newbie
- Posts: 13
- Joined: Mon Sep 30, 2019 4:00 am
- Deviantart: rururubell
- Contact:
Re: How to do math properly?
A try to make a function but this didn't work too. -50 + ( 300 * tan( 32.7) ) should be 142 I'm a right or not? If I put this walue, all works well, but not this code. And if I uncomment renpy.log(...) line, I get a error.
My code:
My code:
Sorry for my English!
Re: How to do math properly?
Python return a value of 967 for such operation. The math.tan argument must be expressed in radians, so math.tan(32.7) return 3.3915861586637797. Multiply by 300 and subtract 50 ('-50 +' means 'add a negative of 50' so equal subtracting) and you'll go near 1000.
For renpy.log() you should first define the config.log. https://www.renpy.org/doc/html/config.h ... config.log
define config.log = "logtext.txt"
and you should add it to the function, not the transform.
For such kind of math operations you can simply install python and use the python shell, so you can verify what python return and do all experiments.
(don't use screenshots to report code, there are visually impaired people around. Copy/paste it. One of the best coder I met in my life was a blind guy)
For renpy.log() you should first define the config.log. https://www.renpy.org/doc/html/config.h ... config.log
define config.log = "logtext.txt"
and you should add it to the function, not the transform.
Code: Select all
define config.log = "mylog.txt"
init python:
def func(x):
y = x*2
renpy.log(str(y))
return y
(don't use screenshots to report code, there are visually impaired people around. Copy/paste it. One of the best coder I met in my life was a blind guy)
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.
10 ? "RENPY"
20 GOTO 10
RUN
10 ? "RENPY"
20 GOTO 10
RUN
- rururubell
- Newbie
- Posts: 13
- Joined: Mon Sep 30, 2019 4:00 am
- Deviantart: rururubell
- Contact:
Re: How to do math properly?
Oh, this was my problem, I forgot about radians. But how to get grads? I use math.degrees() math.radians() but don't get normal results. For example tan in xcalc get me 0.641 and that's value what I need. In python I get:
194.323 if I use math.degrees( math.tan( 32.7 ) )
36.783 if I use math.degrees( math.tan( math.radians( 32.7 ) ) )
Sorry for my English!
- rururubell
- Newbie
- Posts: 13
- Joined: Mon Sep 30, 2019 4:00 am
- Deviantart: rururubell
- Contact:
Re: How to do math properly?
Oh, thank's a lot! I get properly value after all, when I use math.tan( math.radians( 32.7 ) ). Now all works well, thanks again!
Sorry for my English!
Who is online
Users browsing this forum: Bing [Bot], Google [Bot]