SyntaxError: invalid syntax (<none>, line 1)

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
Yuvan raj
Regular
Posts: 38
Joined: Wed Feb 17, 2021 11:24 am
Contact:

SyntaxError: invalid syntax (<none>, line 1)

#1 Post by Yuvan raj »

Hello, I'm trying to declare an image which has an idle and active modes and I'm using a conditionswitch to change the image from idle to active. and vice versa. But I also want the image to be random. The images are 4 different arrows. and each time I want a different random arrow. Like this
Image

This is the code I'm using

Code: Select all

    
label fightvariables:
    
    $ RandomFirst = renpy.random.randint(0, 3)
    
    if RandomFirst == 0:
        $ arrow_one = arrow_down
        $ ArrowOne = ArrowDown
    elif RandomFirst == 1:
        $ arrow_one = arrow_up
        $ ArrowOne = ArrowUp
    elif RandomFirst == 2:
        $ arrow_one = arrow_right
        $ ArrowOne = ArrowRight
    elif RandomFirst == 3:
        $ arrow_one = arrow_left
        $ ArrowOne = ArrowLeft
    return    

label Beforefighting:

    call fightvariables

    image ArrowOne = ConditionSwitch (
        "[ArrowOne]Active == True", "fighting/arrows/[arrow_one]_active.png",
        "True", "fighting/arrows/[arrow_one]_idle.png")

But I'm getting an error

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/fight.rpy", line 5, in script
    image ArrowOne = ConditionSwitch (
  File "game/fight.rpy", line 5, in script
    image ArrowOne = ConditionSwitch (
  File "game/fight.rpy", line 7, in <module>
    "True", "fighting/arrows/[arrow_one]_idle.png")
SyntaxError: invalid syntax (<none>, line 1)

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

Full traceback:
  File "renpy/bootstrap.py", line 326, in bootstrap
    renpy.main.main()
  File "renpy/main.py", line 515, in main
    renpy.game.context().run(node)
  File "game/fight.rpy", line 5, in script
    image ArrowOne = ConditionSwitch (
  File "game/fight.rpy", line 5, in script
    image ArrowOne = ConditionSwitch (
  File "renpy/ast.py", line 1021, in execute
    img = renpy.python.py_eval_bytecode(self.code.bytecode)
  File "renpy/python.py", line 2242, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "game/fight.rpy", line 7, in <module>
    "True", "fighting/arrows/[arrow_one]_idle.png")
  File "renpy/display/layout.py", line 1472, in ConditionSwitch
    code = renpy.python.py_compile(cond, 'eval')
  File "renpy/python.py", line 835, in py_compile
    raise e
SyntaxError: invalid syntax (<none>, line 1)

Windows-8.1-6.3.9600
Ren'Py 7.4.4.1439
conditionswitch 1.0
Fri May  7 16:14:26 2021
I'm close to giving up on this minigame. If you guys can find out what i'm doing wrong I would be really grateful. Thank you!

Shie
Regular
Posts: 41
Joined: Sun Apr 14, 2019 4:12 am
itch: shie
Discord: shie_3769
Contact:

Re: SyntaxError: invalid syntax (<none>, line 1)

#2 Post by Shie »

What values variables arrow_up(and others) have?

Yuvan raj
Regular
Posts: 38
Joined: Wed Feb 17, 2021 11:24 am
Contact:

Re: SyntaxError: invalid syntax (<none>, line 1)

#3 Post by Yuvan raj »

Shie wrote: Fri May 07, 2021 11:41 am What values variables arrow_up(and others) have?
They are just text. The images names are 'arrow_down_idle.png' and 'arrow_down_active.png'. The word 'down' is replaced with 'up, left and right'.

Also I should have used a different name for the image variable (not Arrow down)

This should be the name

Code: Select all

Image First_Arrow = ConditionSwitch( ...same as above...)

Shie
Regular
Posts: 41
Joined: Sun Apr 14, 2019 4:12 am
itch: shie
Discord: shie_3769
Contact:

Re: SyntaxError: invalid syntax (<none>, line 1)

#4 Post by Shie »

Ok, i tride to play around and seems that you cant use [] in condition string ("[ArrowOne]Active == True")
+ you defining image in label and i think you'd want to show it instead

Post Reply

Who is online

Users browsing this forum: No registered users