Syntax Errors?

A place to discuss things that aren't specific to any one creator or game.
Forum rules
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
Post Reply
Message
Author
SaladDressing
Newbie
Posts: 8
Joined: Mon Sep 17, 2018 1:43 pm
Contact:

Syntax Errors?

#1 Post by SaladDressing » Mon Sep 24, 2018 3:23 pm

Hello,
I am currently coding blackjack and am trying to sum up the two first random cards and display the score.

Code: Select all

label yes:
    "Great, let's start the game"
    $ firstCard = renpy.random.choice(["vAce", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "vJ", "vQ", "vK"])
    show expression firstCard:
        yalign 0.9
        xalign 0.37
    $ secondCard = renpy.random.choice(["vAce", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "vJ", "vQ", "vK"])
    show expression secondCard at center:
        yalign 0.9
    $ firstCardOpp = renpy.random.choice(["vAce", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "vJ", "vQ", "vK"])
    show expression firstCardOpp:
        yalign 0.0
        xalign 0.37
    $ secondCardOpp = renpy.random.choice(["vAce", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "vJ", "vQ", "vK"])
    show expression secondCardOpp at center:
        yalign 0.0
    if firstCard = vAce:
        "Please select either 11 or 1."
        menu:
            "11":
                $ amountFirstCard = 11
                jump amountFirstCard
            "1":
                $ amountFirstCard = 1
                jump amountFirstCard
    $ amountFirstCard = cardWorth.get("[firstCard]")
    if SecondCard = vAce:
        "Please select an amount"
        menu:
            "11":
                $ amountSecondCard = 11
                jump firstRound
            "1":
                $ amountSecondCard = 11
                jump FirstRound
    $ amountSecondCard = cardWorth.get("[secondCard]")
now at

Code: Select all

if FirstCard = vAce:
an error occurs which tells me the syntax isn't right??
Am I just stupid or am I blind? The same occurs again at

Code: Select all

if SecondCard = vAce:
And then I have the problem that I can't sum those two variables up to another variable. I tried this:

Code: Select all

$ amountFirstRound = amountFirstCard + amountSecondCard
Well guess what it doesn't work.
I searched python wiki an ren'py wiki but I can't find a mistake.
Thx for any help
SaladDressing

User avatar
Donmai
Eileen-Class Veteran
Posts: 1762
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question
Projects: Slumberland
Location: Brazil
Contact:

Re: Syntax Errors?

#2 Post by Donmai » Mon Sep 24, 2018 4:56 pm

You should try

Code: Select all

if FirstCard == vAce:
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

SaladDressing
Newbie
Posts: 8
Joined: Mon Sep 17, 2018 1:43 pm
Contact:

Re: Syntax Errors?

#3 Post by SaladDressing » Tue Sep 25, 2018 11:35 am

Donmai wrote:
Mon Sep 24, 2018 4:56 pm
You should try

Code: Select all

if FirstCard == vAce:
WhenI do this the same error occurs again :c

drKlauz
Regular
Posts: 67
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: Syntax Errors?

#4 Post by drKlauz » Tue Sep 25, 2018 12:24 pm

Code: Select all

if FirstCard=="vAce":
"vAce" - string
vAce - variable name, which do not exist in your code
== - is equal
= - assignment

P.S.: This question probably belong to viewforum.php?f=8

SaladDressing
Newbie
Posts: 8
Joined: Mon Sep 17, 2018 1:43 pm
Contact:

Re: Syntax Errors?

#5 Post by SaladDressing » Thu Sep 27, 2018 12:57 am

drKlauz wrote:
Tue Sep 25, 2018 12:24 pm

Code: Select all

if FirstCard=="vAce":
"vAce" - string
vAce - variable name, which do not exist in your code
== - is equal
= - assignment

P.S.: This question probably belong to viewforum.php?f=8
Thanks that worked out for me!
What about the addititon of the two variables?

drKlauz
Regular
Posts: 67
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: Syntax Errors?

#6 Post by drKlauz » Thu Sep 27, 2018 1:59 am

$a=b+c

It might be useful to check https://www.codecademy.com/learn/learn-python
And how to use Python in RenPy https://www.renpy.org/doc/html/python.html

SaladDressing
Newbie
Posts: 8
Joined: Mon Sep 17, 2018 1:43 pm
Contact:

Re: Syntax Errors?

#7 Post by SaladDressing » Wed Oct 03, 2018 4:02 am

drKlauz wrote:
Thu Sep 27, 2018 1:59 am
$a=b+c

It might be useful to check https://www.codecademy.com/learn/learn-python
And how to use Python in RenPy https://www.renpy.org/doc/html/python.html
I checked it and It's the same as it is in my script.

Code: Select all

$ amountFirstRound = amountFirstCard + amountSecondCard
Well that doesn't work and I have no idea why.

SaladDressing
Newbie
Posts: 8
Joined: Mon Sep 17, 2018 1:43 pm
Contact:

Re: Syntax Errors?

#8 Post by SaladDressing » Wed Oct 03, 2018 4:29 am

I figured out that the problem is the string

Code: Select all

$ amountFirstCard = cardWorth.get([firstCard])
cardWorth is a dictionary I created to assign a value to each Card

Code: Select all

$ cardWorth = {"v2": "2", "v3": "3", "v4": "4", "v5": "5", "v6": "6", "v7": "7", "v8": "8", "v9": "9", "v10": "10", "vJ": "10", "vQ": "10", "vQ": "10"}
$ firstCard = renpy.random.choice(["vAce", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "vJ", "vQ", "vK"])
show expression firstCard:
    yalign 0.9
    xalign 0.37
$ secondCard = renpy.random.choice(["vAce", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "vJ", "vQ", "vK"])
show expression secondCard at center:
    yalign 0.9
if firstCard=="vAce":
        "Please select either 11 or 1."
        menu:
            "11":
                $ amountFirstCard = 11
                jump amountFirstCard
            "1":
                $ amountFirstCard = 1
                jump amountFirstCard
$ amountFirstCard = cardWorth.get("[firstCard]")
"[amountFirstCard]" 
Here it shows me "None". I can't find the mistake. Any help?

Post Reply

Who is online

Users browsing this forum: No registered users