[SOLVED]Get syntax error. Why?

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
User avatar
Loopaz
Newbie
Posts: 13
Joined: Thu Apr 12, 2018 4:03 am
Completed: ..asking still the same questions!
Projects: Your choice VN
Location: Poland
Contact:

[SOLVED]Get syntax error. Why?

#1 Post by Loopaz »

Hello!
It is propably simple question.
I am making money system to my game.
I get syntax error after first else statement and dont understand why i get it.
Regards Loopaz

Code: Select all

init python:
    from random import randint

    wallets = (pockets, wallet_tiny, wallet_small, wallet_medium, wallet_big, wallet_huge)
    banknotes = (500,200,100,50,20,10)
    coins = (5,2,1,0.5,0.2,0.1)
    shopping_list = []


    class Money():
        def __init__(self, account, amount, ):
            self.account = account
            self.wallet = []
            self.amount = amount
            wallet_size() = pockets

        def wallet_size():
            if wallet_size() is pockets:
                max_banknotes = 50
                max_coins = 50
                # if self.player_luck == 0:
                #     lost = self.wallet.pop(self.wallet[randint(0,len(self.wallet))])
                #     cr "You have lost " + lost +" because lack of wallet"
            elif wallet_size() is wallet_tiny:
                max_banknotes = 10
                max_coins = 10
            elif wallet_size() is wallet_small:
                max_banknotes = 15
                max_coins = 10
            elif wallet_size() is wallet_medium:
                max_banknotes = 25
                max_coins = 20
            elif wallet_size() is wallet_big:
                max_banknotes = 35
                max_coins = 30
            elif wallet_size() is wallet_huge:
                max_banknotes = 45
                max_coins = 45
            else:
                cr 'wallet_size error!'

        def account_check():
            return account

        def wallet_check():
            for count in self.wallet:
                wallet_amount += count
            return wallet_amount

        def wallet_banknotes():
            sort(self.wallet)
            for banknote_amount in self.wallet:
                while banknote_amount >= 10:
                    banknotes_amount += banknote_amount
            return banknotes_amount

        def wallet_coins():
            sort(self.wallet)
            for coin_amount in self.wallet:
                while coin_amount < 10:
                    coins_amount += coin_amount
            return coins_amount

        def account_to_wallet(amount):
            if amount % 10 == 0 and amount <= account and account >= 10 and banknotes_count <= max_banknotes:
                for banknote_item in banknotes:
                    while amount >= banknote_item and account >= 10 and banknotes_count <= max_banknotes:
                        amount -= banknote_item
                        self.wallet.append(banknote_item)
                        account -= banknote_item
                        banknotes_count += 1
                cr "Bankonotes amount in the wallet [banknotes_count]" 
                cr "Amount money in the wallet" + wallet_check()
                bank "Your account " + account_check() 
                
                cr "Money amount in the wallet" + wallet_amount = 
            elif amount % 10 != 0:
                bank "The amount of whitdraft is not a multiplication of 10"
            elif account < 10:
                bank "You dont have enough money to make transaction"
            elif banknotes_count < max_banknotes:
                cr "The amount of banknotes will not fit to this wallet"
            elif amount > account:
                bank "You don't have this amount on your account. The amount is too high"
            else:
                cr "amount_to_wallet error!"

        def wallet_to_account(amount):
            if amount % 10 == 0 and amount <= wallet_banknotes():
                for banknote_item in banknotes:
                    while amount >= self.wallet and self.wallet >= 10 and amount <= wallet_banknotes():
                        amount -= banknote_item
                        self.wallet.remove(banknote_item)
                        account += banknote_item
                        banknotes_count -= 1
            elif amount > wallet_banknotes():
                cr "You don't have soo much in wallet"
            elif amount % 10 != 0:
                bank "Amount must be an multiplication of 10"
            else:
                cr " wallet_to_account error! "

        def full_cost():
            # for price in shopping_list_prices()
                # full_price += price 
            pass

        def shopping_list_prices():
            # for item in shopping_list:
            pass
Last edited by Loopaz on Fri Feb 19, 2021 12:44 pm, edited 1 time in total.
"I know that I know nothing" :shock:
"Who ask not stray" :roll:
Bad english talker :|
I don't expect miracle. I expect profesionals :3
or do something right or do not do it at all

User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: Get syntax error. Why?

#2 Post by RicharDann »

You're trying to run a say statement from an init python block. You need to use renpy.say(), the statement equivalent function instead for it to work in python.
Instead of:

Code: Select all

cr 'wallet_size error!'
Use:

Code: Select all

renpy.say(cr, "wallet_size error!")
The most important step is always the next one.

User avatar
Loopaz
Newbie
Posts: 13
Joined: Thu Apr 12, 2018 4:03 am
Completed: ..asking still the same questions!
Projects: Your choice VN
Location: Poland
Contact:

Re: Get syntax error. Why?

#3 Post by Loopaz »

funny thing is when i delete whole else statement the code chcecker jump to another error, but i dont understand whay i have it ><
"I know that I know nothing" :shock:
"Who ask not stray" :roll:
Bad english talker :|
I don't expect miracle. I expect profesionals :3
or do something right or do not do it at all

User avatar
Loopaz
Newbie
Posts: 13
Joined: Thu Apr 12, 2018 4:03 am
Completed: ..asking still the same questions!
Projects: Your choice VN
Location: Poland
Contact:

Re: Get syntax error. Why?

#4 Post by Loopaz »

oh thats my lack of knowledge. Thank you mr!
"I know that I know nothing" :shock:
"Who ask not stray" :roll:
Bad english talker :|
I don't expect miracle. I expect profesionals :3
or do something right or do not do it at all

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]