Indentation Mismatch 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
User avatar
IrinaLazareva
Veteran
Posts: 228
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy, Эра Тёмных Небес
Organization: IKG
Location: St.Petersburg, Russia
Contact:

Re: Indentation Mismatch error

#16 Post by IrinaLazareva » Thu Feb 22, 2018 8:02 am

JimmyFrost wrote:
Thu Feb 22, 2018 5:41 am
Should the indentation be deeper?
Yes.

Perhaps , a problem in line

Code: Select all

       def __init__(self, Actor"", Active=True, Atk=0, Def=0, Mat=0, Mdf=0, HP=0, MP=0, SP=0, magic_set[], demon_set[], personality""):
Presumably, there isn't enough '=' sign (for Actor, magic_set, demon_set and personality).
I'm not sure, but try:

Code: Select all

init python:
    """Characters built specifically to fight battles in-game. . .
    Args:
        Actor(str):name of character
        Active(bool):
        Atk(int):
        Def(int):
        Mat(int):
        Mdf(int):
        HP(int):
        MP(int):
        SP(int):
        magic_set(dict):
        demon_set(dict):
        personality(str):
    """
    class Actor(object):

       def __init__(self, Actor="", Active=True, Atk=0, Def=0, Mat=0, Mdf=0, HP=0, MP=0, SP=0, magic_set=[], demon_set=[], personality=""):
            self.Actor = Actor
            self.Active = Active
            self.Atk = Atk
            self.Def = Def
            self.Mat = Mat
            self.Mdf = Mdf
            self.HP = HP
            self.MP = MP
            self.SP = SP
            self.magic_set = magic_set
            self.demon_set = demon_set
            self.personality = personality
            self.status  = [self.Atk, self.Def, self.Mat, self.Mdf, self.HP, self.MP, self.SP]
       
       def magic_register(self, magic_name):
           self.magic_set.append(magic_name)
       def demon_register(self, demon_name):
           self.demon_set.append(demon_name)
           
       def normalize_status(self):
           print "Normalizing status. Please wait. . ."
           for index, value in enumerate(self.status):
               if value <= 0:
                   self.status[index] = 0
               return self.status
There is a light at the end of the tunnel, just pray it's not a train.

JimmyFrost
Regular
Posts: 30
Joined: Fri May 01, 2015 9:46 am
Projects: TOWER
Location: United States
Contact:

Re: Indentation Mismatch error

#17 Post by JimmyFrost » Thu Feb 22, 2018 6:42 pm

Hey! the indentation problem's fixed. Now it crops up with syntax on line 19. Maybe I should move to a new topic?
File "game/timerproto.rpy", line 19: invalid syntax
def __init__(self, Actor"", Active=True, Atk=0, Def=0, Mat=0, Mdf=0, HP=0, MP=0, SP=0, magic_set[], demon_set[], personality""):
"If hard work hasn't hurt anyone, then why is there worker's comp?"

irredeemable
Regular
Posts: 78
Joined: Thu Feb 08, 2018 7:57 am
Contact:

Re: Indentation Mismatch error

#18 Post by irredeemable » Thu Feb 22, 2018 7:03 pm

JimmyFrost wrote:
Thu Feb 22, 2018 6:42 pm
Hey! the indentation problem's fixed. Now it crops up with syntax on line 19. Maybe I should move to a new topic?
File "game/timerproto.rpy", line 19: invalid syntax
def __init__(self, Actor"", Active=True, Atk=0, Def=0, Mat=0, Mdf=0, HP=0, MP=0, SP=0, magic_set[], demon_set[], personality""):
In the line as quoted here you're missing a lot of equals signs. Also, while this isn't relevant to your error, you shouldn't set default parameters to empty lists. It's an idiosyncrasy of Python, but if you do it like that every instance of Actor that wasn't initialized with a value for that variable will end up sharing the same list. Instead, set the default to None then check for None in __init__, setting it to an empty list as necessary at that time.

JimmyFrost
Regular
Posts: 30
Joined: Fri May 01, 2015 9:46 am
Projects: TOWER
Location: United States
Contact:

Re: Indentation Mismatch error

#19 Post by JimmyFrost » Thu Feb 22, 2018 7:56 pm

irredeemable, you are a godsend. Thank you very much.
"If hard work hasn't hurt anyone, then why is there worker's comp?"

mikwee
Newbie
Posts: 1
Joined: Sun Jun 17, 2018 11:53 am
Github: yanshufbareshet
Contact:

Re: Indentation Mismatch error

#20 Post by mikwee » Sun Jun 17, 2018 11:57 am

It also happen to me when I tried to create an input text box.

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

Re: Indentation Mismatch error

#21 Post by kivik » Sun Jun 17, 2018 12:33 pm

You def needs to be one indentation down from the class line:

Code: Select all

init python:
    class ClassName:
        def functions(self):

Post Reply

Who is online

Users browsing this forum: No registered users