Constantly getting "Line is indented" error

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.
Message
Author
kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Constantly getting "Line is indented" error

#16 Post by kivik »

You need to read the explanation I offered and the code to work out how it works :)

It doesn't know what time of day it is, just displays stuff according to your day, and your time of day variables!

User avatar
margaretcatter
Regular
Posts: 44
Joined: Fri May 18, 2018 7:16 pm
Projects: Kathelm Princess X Princess | Hurricane Like Me
itch: margaretcatter
Location: New York/LA
Contact:

Re: Constantly getting "Line is indented" error

#17 Post by margaretcatter »

So in the end I ended up doing this to get it set to Saturday Night.

Code: Select all


define day_of_week = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
define time_of_day = ["Morning", "Afternoon", "Evening", "Night"]
default day = 1
default tod = 2

default dow = day_of_week[day]
default time_now = time_of_day[tod]

#####

    def advance_time(_time = 1):
        global tod, time_now, time_of_day, day
        new_days = (tod + _time) // 4 # // returns floored divisions, in other ways how many times the divider goes into the value, ignoring remainders

        tod = (tod + _time) % 4
        time_now = time_of_day[tod]

        advance_day(new_days) # add new days


    def advance_day(_day = 1):
        global day, dow, day_of_week
        day += _day
        dow = day_of_week[day % 7]

Though I'm still unsure of how % is division and not subtraction.

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Constantly getting "Line is indented" error

#18 Post by kivik »

margaretcatter wrote: Tue May 22, 2018 12:28 am Though I'm still unsure of how % is division and not subtraction.
kivik wrote: the simplest way is to use the mod operator %: e.g. 12 % 7 = 5

What the mod operator does is, it returns the remainder of your first value after being divided by the second value. e.g. with 1 % 7, 7 goes into 1 exactly 0 times, with 1 as a remainder. 12 % 7: 7 goes into 12 exactly 1 time, with a remainder 5.
I'd strongly advice you actually read the explanations. I don't know if it's a language barrier thing, and therefore you're struggling to understand (you need to tell us if that's the case).

However so far you're showing lots of signs that you don't actually read and follow anything (making up your own code from working examples), and it'd mean your code will fail to work time after time and you'll be wasting everybody's time on the forum fixing very basic issues and errors that you wouldn't be making had you read the explanations and tried to learn.

Post Reply

Who is online

Users browsing this forum: No registered users