Gouvernathor / renpy-ChromaGlitch

A way to display images (or other displayables) with a DDLC-like glitch effect offsetting slices of the image laterally and optionally adding chromatic aberration effects on the glitched slices.
51 stars 3 forks source link

Syntax Error in renpy 7 #3

Open vera-vee opened 2 years ago

vera-vee commented 2 years ago

Moving glitch.rpy into project folder and attempting to launch game presents a syntax error. I am unsure how to fix this, or if additional syntax errors present themselves after this line, since it stops trying to run upon reaching this issue.

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.

File "game/glitch.rpy", line 13: invalid syntax
        def __init__(self, child, *args, randomkey=None, **kwargs):
                                                  ^

Ren'Py Version: Ren'Py 7.4.6.1693
Tue Sep 13 12:57:29 2022
Gouvernathor commented 2 years ago

Ah, yes, that's because it's PY3 argument syntax, it works in renpy 8+ only. I'll leave this issue open while renpy 7 still exists.

vera-vee commented 2 years ago

Aha! My apologies, then! Thanks for the heads up. It's probably worth updating, anyhow. Have a good one!

Gouvernathor commented 2 years ago

As a fix, you can have def __init__(self, child, *args, **kwargs) then randomkey=kwargs.pop("randomkey", None). I won't add it in the code because I find that py2 code ugly, but it should work the same.

Puru-Ai commented 2 years ago

As a fix, you can have def __init__(self, child, *args, **kwargs) then randomkey=kwargs.pop("randomkey", None). I won't add it in the code because I find that py2 code ugly, but it should work the same.

I just tried this and still get a syntax error.

Gouvernathor commented 2 years ago

Can you post the exact syntax error you get ?

Puru-Ai commented 2 years ago
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.

File "game/glitch.rpy", line 13: invalid syntax
        def __init__(self, child, *args, **kwargs) randomkey=kwargs.pop("randomkey", None):
                                                            ^

Ren'Py Version: Ren'Py 7.5.3.22090809
Fri Oct 21 18:20:10 2022

`

Gouvernathor commented 2 years ago

I suggest you read some basic python language information befre going too deep in game programming. The kwargs.pop line goes in the next line.

TreeBobber1 commented 2 years ago

For me replacing the argument with the kwargs.pop line wasn't enough to make glitch.rpy work. At first I got this error

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.

File "game/glitch.rpy", line 60: invalid syntax
                             )
                              ^

Ren'Py Version: Ren'Py 7.5.2.22081402
Tue Nov  1 11:45:45 2022

I removed an additional comma which solved that error but then that was followed by this one

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script_common.rpy", line 3629, in script
    show bg clubroom day at glitch
  File "game/glitch.rpy", line 15, in __init__
    super().__init__()
TypeError: super() takes at least 1 argument (0 given)

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script_common.rpy", line 3629, in script
    show bg clubroom day at glitch
  File "renpy/ast.py", line 1408, in execute
    show_imspec(self.imspec, atl=getattr(self, "atl", None))
  File "renpy/ast.py", line 1378, in show_imspec
    atl=atl)
  File "renpy/exports.py", line 698, in show
    img = i(img)
  File "game/glitch.rpy", line 15, in __init__
    super().__init__()
TypeError: super() takes at least 1 argument (0 given)

Windows-10-10.0.19041 AMD64
Ren'Py 7.5.2.22081402
Tue Nov  1 11:48:16 2022
TreeBobber1 commented 2 years ago

With additional comma I mean the one here

            return Fixed(Transform(child, alpha=.0),
                         *lizt,
                         fit_first=True,
                         crop_relative=crop or False,
                         crop=crop and (0, 0, 1.0, 1.0), <- This one here
                         )
Gouvernathor commented 2 years ago

Yes, good catch, you need super(glitch, self). in that case. (See why I left out py2 ?)

TreeBobber1 commented 2 years ago

Well, good news, that fixed that error. Bad news, new one popped up

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script_common.rpy", line 3633, in script
    pause 1.0
  File "renpy/common/000statements.rpy", line 453, in execute_pause
    renpy.pause(delay)
  File "game/glitch.rpy", line 25, in render
    *self.args, **self.kwargs),
  File "game/glitch.rpy", line 36, in glitch
    theights = sorted(randomobj.randint(0, cheight) for k in range(min(cheight, randomobj.randint(10, 20)))) # y coordinates demarcating all the strips
  File "game/glitch.rpy", line 36, in <genexpr>
    theights = sorted(randomobj.randint(0, cheight) for k in range(min(cheight, randomobj.randint(10, 20)))) # y coordinates demarcating all the strips
ValueError: non-integer stop for randrange()

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script_common.rpy", line 3633, in script
    pause 1.0
  File "renpy/ast.py", line 2232, in execute
    self.call("execute")
  File "renpy/ast.py", line 2220, in call
    return renpy.statements.call(method, parsed, *args, **kwargs)
  File "renpy/statements.py", line 281, in call
    return method(parsed, *args, **kwargs)
  File "renpy/common/000statements.rpy", line 453, in execute_pause
    renpy.pause(delay)
  File "renpy/exports.py", line 1533, in pause
    rv = renpy.ui.interact(mouse='pause', type='pause', roll_forward=roll_forward, pause=delay)
  File "renpy/ui.py", line 299, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "renpy/display/core.py", line 3377, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, **kwargs) # type: ignore
  File "renpy/display/core.py", line 3906, in interact_core
    self.draw_screen(root_widget, fullscreen_video, (not fullscreen_video) or video_frame_drawn)
  File "renpy/display/core.py", line 2605, in draw_screen
    renpy.config.screen_height,
  File "render.pyx", line 495, in renpy.display.render.render_screen
  File "render.pyx", line 266, in renpy.display.render.render
  File "renpy/display/layout.py", line 884, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 170, in renpy.display.render.render
  File "render.pyx", line 266, in renpy.display.render.render
  File "renpy/display/layout.py", line 884, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 170, in renpy.display.render.render
  File "render.pyx", line 266, in renpy.display.render.render
  File "renpy/display/layout.py", line 884, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 170, in renpy.display.render.render
  File "render.pyx", line 266, in renpy.display.render.render
  File "renpy/display/transform.py", line 747, in render
    return transform_render(self, width, height, st, at)
  File "accelerator.pyx", line 187, in renpy.display.accelerator.transform_render
  File "render.pyx", line 266, in renpy.display.render.render
  File "game/glitch.rpy", line 25, in render
    *self.args, **self.kwargs),
  File "game/glitch.rpy", line 36, in glitch
    theights = sorted(randomobj.randint(0, cheight) for k in range(min(cheight, randomobj.randint(10, 20)))) # y coordinates demarcating all the strips
  File "renpy/revertable.py", line 281, in revertable_sorted
    return RevertableList(sorted(*args, **kwargs))
  File "game/glitch.rpy", line 36, in <genexpr>
    theights = sorted(randomobj.randint(0, cheight) for k in range(min(cheight, randomobj.randint(10, 20)))) # y coordinates demarcating all the strips
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/random.py", line 244, in randint
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/random.py", line 200, in randrange
ValueError: non-integer stop for randrange()

Windows-10-10.0.19041 AMD64
Ren'Py 7.5.2.22081402
Tue Nov  1 13:13:49 2022
Gouvernathor commented 2 years ago

Ah, that's because of the round. But it should be fixed in 7.5.3, check again after updating (otherwise you need to wrap the round calls in int).

TreeBobber1 commented 2 years ago

The cast to int did it. Thanks!

Kl1novich commented 1 year ago

Im sorry, but...

[code] I'm sorry, but errors were detected in your script. Please correct the errors listed below, and try again.

File "game/mods/FMG/effects/GlitchEffect/glitch.rpy", line 8: invalid syntax def init(self, child, *, randomkey=NotSet, chroma=True, minbandheight=1, offset=30, nslices=None, **properties): ^

Ren'Py Version: Ren'Py 7.4.11.2266 Mon Apr 3 03:28:44 2023 [/code]

Gouvernathor commented 1 year ago

Read the messages above. This is only going to get worse with the latest updates I made, as I don't care about py2 support. Please upgrade to renpy 8.

Kl1novich commented 1 year ago

I make mod for ES(Everlasting summer) and can't update game to new versions renpy. I understand, you don't like py2, but if you help sovle my problem, i create video for russian/ukrainian people who wants use your glitch effect for ES. (People will not write with the same problem as me.)

P.s: I run Renpy 8.0.3 and it work.

Kl1novich commented 1 year ago

I tried to transfer the game and it seems to have done. I am not a master of renpai and python, but somehow I transferred the game to a new version. Now I have another problem.

image

After solving the problems, I will put in a master game with a new engine.

P.s: problem in line 38 because i tried get glitch effect on sprite(image)

Gouvernathor commented 1 year ago

It seems you passed a string where you weren't supposed to. Not really sure though. In any case it's a different problem, so open it in another issue with the full traceback.