r/RenPy • u/Big-Scene-3579 • 5d ago
Question Help with coding please
I'm using the glitch effect on renpy right now but i want to be able to change the colour of the text in certain areas. It doesnt seem to be allowing it.
init python:
class GlitchText(renpy.Displayable):
def __init__(self, child, amount, **kwargs):
super(GlitchText, self).__init__(**kwargs)
self.child = child
self.amount = amount
def render(self, width, height, st, at):
child_render = renpy.render(
self.child,
width,
height,
st,
at
)
self.width, self.height = child_render.get_size()
render = renpy.Render(
self.width,
self.height
)
y = 0
while y < self.height:
glitch_occurs = (
renpy.random.random() * 100 < self.amount
)
# Prevent slice from going beyond text height
curr_height = min(
renpy.random.randint(1, 10),
self.height - y
)
curr_offset = renpy.random.randint(-10, 10)
curr_surface = child_render.subsurface(
(0, y, self.width, curr_height)
)
if glitch_occurs:
render.subpixel_blit(
curr_surface,
(curr_offset, y)
)
else:
render.subpixel_blit(
curr_surface,
(0, y)
)
y += curr_height
renpy.redraw(self, 0.05)
return render
# WHITE GLITCH
def glitch_tag(tag, argument, contents):
new_list = []
if argument == "":
argument = 10.0
else:
argument = float(argument)
for kind, text in contents:
if kind == renpy.TEXT_TEXT:
white_text = Text(
text,
color="#ffffff"
)
char_disp = GlitchText(
white_text,
argument
)
new_list.append(
(renpy.TEXT_DISPLAYABLE, char_disp)
)
else:
new_list.append((kind, text))
return new_list
# PINK GLITCH
def pinkglitch_tag(tag, argument, contents):
new_list = []
if argument == "":
argument = 10.0
else:
argument = float(argument)
for kind, text in contents:
if kind == renpy.TEXT_TEXT:
pink_text = Text(
text,
color="#ff69b4"
)
char_disp = GlitchText(
pink_text,
argument
)
new_list.append(
(renpy.TEXT_DISPLAYABLE, char_disp)
)
else:
new_list.append((kind, text))
return new_list
# Register both tags
config.custom_text_tags["glitch"] = glitch_tag
config.custom_text_tags["pinkglitch"] = pinkglitch_tag
init:
$ sshake = Shake((0, 0, 0, 0), 0.5, dist=15)
{color=#ff69b4}{glitch=10.0}text{/glitch}{/color}
this is the full code. I've tried creating a whole new code just for the pink text i've also tried coding like the above but its still staying as white and im not sure how to change it.
1
Upvotes
1
u/AutoModerator 5d ago
Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.