Ren'Py syntax error: request help

petertavy

Newbie
Aug 21, 2020
82
18
I am trying to write a function to do time travel. I put the following into
the file script.rpy just before label start:


global hour #4

# Define time travel function
def back_time(): #4
if hour > 7: #8
$ hour -= 1 #12

# Add key to 'back_time', this case is 'h' on keyboard
config.keymap["back_time"] = ["h"] #4


and I get a syntax error. The report puts a red mark between the $ and the hour
Further down the file I find:

$ hour += 1 #4

which is accepted. Please what is wrong? Thank you.

When I preview, the indentation of
the lines has disappeared. So I have added comments: # 8 means indented 8 spaces
(no tabs)
 

Meaning Less

Engaged Member
Sep 13, 2016
3,540
7,087
You probably don't need to use "$" since you are defining a python function above with def.

$ is a renpy thing, not needed when using python directly.
 

petertavy

Newbie
Aug 21, 2020
82
18
You probably don't need to use "$" since you are defining a python function above with def.

$ is a renpy thing, not needed when using python directly.
Thank you. I removed the dollar & the syntax error has gone. Then I realised that "h" is a bad choice
of keyboard letter & changed it to "t" . Now typing "t" produces no visible error, but also no visible
change in the time. Please any ideas?