Im using the shake from the cookbook https://www.renpy.org/wiki/renpy/doc/co ... ke_effect
and Im getting this error
It's an old project so I dont feel like creating a new transformation and apply it in all cases. Any way to salvage this old code?
Shake not working
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.
- neometalero
- Veteran
- Posts: 202
- Joined: Sun Oct 23, 2016 3:51 am
- Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
- Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
- Deviantart: neometalero
- Contact:
Re: Shake not working
Not tested, but try to convert the result of calculation to integer, likeneometalero wrote: ↑Sat Apr 13, 2024 7:18 pm ...It's an old project so I dont feel like creating a new transformation and apply it in all cases. Any way to salvage this old code?
Code: Select all
nx = xpos + int(self.dist * (renpy.random.random() * 2 - 1))
- neometalero
- Veteran
- Posts: 202
- Joined: Sun Oct 23, 2016 3:51 am
- Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
- Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
- Deviantart: neometalero
- Contact:
Re: Shake not working
I got the same error doing that. Is looking for a position type not an intAlex wrote: ↑Sun Apr 14, 2024 5:03 amNot tested, but try to convert the result of calculation to integer, likeneometalero wrote: ↑Sat Apr 13, 2024 7:18 pm ...It's an old project so I dont feel like creating a new transformation and apply it in all cases. Any way to salvage this old code?Code: Select all
nx = xpos + int(self.dist * (renpy.random.random() * 2 - 1))
Re: Shake not working
Hm, just tested and the original code worked for me in 8.1.0.
What version of Ren'Py do you use? Could you provide the part of the code where you using this shake effect?
Upd: original code worked in 8.2.1 (no errors).
Re: Shake not working
Upd: this should work...neometalero wrote: ↑Sun Apr 14, 2024 7:11 pm ...I got the same error doing that. Is looking for a position type not an int
Code: Select all
init:
python:
import math
class Shaker(object):
anchors = {
'top' : 0.0,
'center' : 0.5,
'bottom' : 1.0,
'left' : 0.0,
'right' : 1.0,
}
def __init__(self, start, child, dist):
if start is None:
start = child.get_placement()
#
self.start = [ self.anchors.get(i, i) for i in start ] # central position
self.dist = dist # maximum distance, in pixels, from the starting point
self.child = child
def __call__(self, t, sizes):
# Float to integer... turns floating point numbers to
# integers.
def fti(x, r):
if x is None:
x = 0
if isinstance(x, float):
return int(x * r)
elif isinstance(x, position): # <-- position type
return int(x.relative * r + x.absolute)
else:
return x
xpos, ypos, xanchor, yanchor = [ fti(a, b) for a, b in zip(self.start, sizes) ]
xpos = xpos - xanchor
ypos = ypos - yanchor
nx = xpos + (1.0-t) * self.dist * (renpy.random.random()*2-1)
ny = ypos + (1.0-t) * self.dist * (renpy.random.random()*2-1)
return (int(nx), int(ny), 0, 0)
def _Shake(start, time, child=None, dist=100.0, **properties):
move = Shaker(start, child, dist=dist)
return renpy.display.layout.Motion(move,
time,
child,
add_sizes=True,
**properties)
Shake = renpy.curry(_Shake)
#
#
image test_img:
Solid("#ccc")
xysize(100, 100)
image test_img_2:
Solid("#c00")
xysize(100, 100)
transform test_pos_tr():
#anchor (50, 50)
#ypos position (0, 0.50)
#xpos position (0, 0.50)
#align(0.5, 0.5)
#pos(int(config.screen_width*0.5), int(config.screen_height*0.5))
pos(0.5, 0.5)
#pos(960, 540)
anchor (0.5, 0.5)
label start:
"..."
show test_img_2 at truecenter
show test_img at test_pos_tr
"... ..."
show test_img at test_pos_tr, Shake(None, 1.5, dist=70) # None to use current position
"?!"
Who is online
Users browsing this forum: Bing [Bot], geoWaffle, giorgi1111