Certain name reactions??

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
LazyLycanthrope
Newbie
Posts: 13
Joined: Sat Feb 03, 2018 11:17 pm
Contact:

Certain name reactions??

#1 Post by LazyLycanthrope » Wed Feb 28, 2018 7:43 pm

Uh, I need help on how to make a certain name have different kinds of outcomes like, if the MC's name is Violet, then the name colour turns purple??
And I need a way to have a character react to a certain name? Because I've been trying to put 'if name' and all that stuff but nothing has been working :/

User avatar
wyverngem
Miko-Class Veteran
Posts: 613
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Re: Certain name reactions??

#2 Post by wyverngem » Wed Feb 28, 2018 9:21 pm

Code: Select all

default mc_name = "Violet"
default name_color = "#FFF"
define mc = Character("[mc_name]", who_color=name_color)

label start:
    if mc_name == "Violet":
        $ name_color = "8300FF"
        "Your name is [mc_name]. That's like the color purple right?"
    else:
        "It's nice to meet you [mc_name]."
I haven't tested the name_color, but it should work for you.
Last edited by wyverngem on Thu Mar 01, 2018 12:27 am, edited 1 time in total.

LazyLycanthrope
Newbie
Posts: 13
Joined: Sat Feb 03, 2018 11:17 pm
Contact:

Re: Certain name reactions??

#3 Post by LazyLycanthrope » Wed Feb 28, 2018 10:53 pm

wyverngem wrote:
Wed Feb 28, 2018 9:21 pm

Code: Select all

default mc_name = "Violet"
default name_color = "#FFF"
define mc = Character("[mc_name]", color=name_color)

label start:
    if mc_name == Violet:
        $ name_color = "8300FF"
        "Your name is [mc_name]. That's like the color purple right?"
    else:
        "It's nice to meet you [mc_name]."
I haven't tested the name_color, but it should work for you.
I tried it out, but it didn't seem to work. :(

User avatar
trooper6
Lemma-Class Veteran
Posts: 3706
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Certain name reactions??

#4 Post by trooper6 » Wed Feb 28, 2018 11:19 pm

Should be who_color not color. If you want to change the color of the text, that would be what_color.
Also, if that doesn't work, post your code.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

LazyLycanthrope
Newbie
Posts: 13
Joined: Sat Feb 03, 2018 11:17 pm
Contact:

Re: Certain name reactions??

#5 Post by LazyLycanthrope » Wed Feb 28, 2018 11:33 pm

trooper6 wrote:
Wed Feb 28, 2018 11:19 pm
Should be who_color not color. If you want to change the color of the text, that would be what_color.
Also, if that doesn't work, post your code.

Code: Select all

default name = "Wyvern"
default name_color = "#585858"
define mc = Character("[name]", color="who_color")
I actually have Wyvern as the default name, but I just need certain reactions to certain names the player uses.
It keeps saying that "who_color" is invalid.

User avatar
Milkymalk
Miko-Class Veteran
Posts: 747
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Certain name reactions??

#6 Post by Milkymalk » Wed Feb 28, 2018 11:54 pm

Try:

Code: Select all

default name = "Wyvern"
default name_color = "#585858"
define mc = Character(name, who_color=name_color)
name and name_color are variables (containers for data). Anything inside " " is data (string data, to be exact). So if you write "name", the computer understands exactly that - "name". If you write name without " ", the computer understands whatever the content of the variable name is.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

LazyLycanthrope
Newbie
Posts: 13
Joined: Sat Feb 03, 2018 11:17 pm
Contact:

Re: Certain name reactions??

#7 Post by LazyLycanthrope » Thu Mar 01, 2018 12:05 am

Milkymalk wrote:
Wed Feb 28, 2018 11:54 pm
Try:

Code: Select all

default name = "Wyvern"
default name_color = "#585858"
define mc = Character(name, who_color=name_color)
name and name_color are variables (containers for data). Anything inside " " is data (string data, to be exact). So if you write "name", the computer understands exactly that - "name". If you write name without " ", the computer understands whatever the content of the variable name is.
Okay, I've tried out the code, but it seems to have said 'invalid syntax' ?

User avatar
Milkymalk
Miko-Class Veteran
Posts: 747
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Certain name reactions??

#8 Post by Milkymalk » Thu Mar 01, 2018 12:15 am

Are you sure the 'invalid syntax' is in these lines? What does the error message say?
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

User avatar
wyverngem
Miko-Class Veteran
Posts: 613
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Re: Certain name reactions??

#9 Post by wyverngem » Thu Mar 01, 2018 12:25 am

Can you post the full error log please? I was a little tired when I replied sorry. @trooper6 This is the error I get when I have the code as this:

Code: Select all

init: 
    $ nameColor = "#FFFFFF"
default mc_name = "Violet"

define v = Character("[mc_name]", who_color=nameColor)

label start:
    v "I I work"
    if mc_name == "Violet":
        $ name_color = "#8300F"
        v"Your name is [mc_name]. That's like the color purple right?"
    else:
        v "It's nice to meet you [mc_name]."
Silly me this code works fine with the right number of hex digit colors. The only issues is that I'm seeing the same thing. No error, but it doesn't change the color.

If it's written like this the error goes like this:

Code: Select all

default nameColor = "#FFFFF"
default mc_name = "Violet"

define v = Character("[mc_name]", who_color=nameColor)

label start:
    v "I I work"
    if mc_name == "Violet":
        $ name_color = "#8300F"
        v"Your name is [mc_name]. That's like the color purple right?"
    else:
        v "It's nice to meet you [mc_name]."

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 4, in script
    define v = Character("[mc_name]", who_color=nameColor)
  File "game/script.rpy", line 4, in <module>
    define v = Character("[mc_name]", who_color=nameColor)
NameError: name 'nameColor' is not defined
I really thought you could change it based on the name.

LazyLycanthrope
Newbie
Posts: 13
Joined: Sat Feb 03, 2018 11:17 pm
Contact:

Re: Certain name reactions??

#10 Post by LazyLycanthrope » Thu Mar 01, 2018 12:54 am

wyverngem wrote:
Thu Mar 01, 2018 12:25 am
Can you post the full error log please? I was a little tired when I replied sorry. @trooper6 This is the error I get when I have the code as this:

Code: Select all

init: 
    $ nameColor = "#FFFFFF"
default mc_name = "Violet"

define v = Character("[mc_name]", who_color=nameColor)

label start:
    v "I I work"
    if mc_name == "Violet":
        $ name_color = "#8300F"
        v"Your name is [mc_name]. That's like the color purple right?"
    else:
        v "It's nice to meet you [mc_name]."
Silly me this code works fine with the right number of hex digit colors. The only issues is that I'm seeing the same thing. No error, but it doesn't change the color.

If it's written like this the error goes like this:

Code: Select all

default nameColor = "#FFFFF"
default mc_name = "Violet"

define v = Character("[mc_name]", who_color=nameColor)

label start:
    v "I I work"
    if mc_name == "Violet":
        $ name_color = "#8300F"
        v"Your name is [mc_name]. That's like the color purple right?"
    else:
        v "It's nice to meet you [mc_name]."

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 4, in script
    define v = Character("[mc_name]", who_color=nameColor)
  File "game/script.rpy", line 4, in <module>
    define v = Character("[mc_name]", who_color=nameColor)
NameError: name 'nameColor' is not defined
I really thought you could change it based on the name.
here's the full error log

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 37, in script
    if name == "Violet":
  File "game/script.rpy", line 37, in <module>
    if name == "Violet":
NameError: name 'name' is not defined

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 37, in script
    if name == "Violet":
  File "C:\Users\wolfe\Downloads\renpy-6.99.12.4-sdk\renpy\ast.py", line 1702, in execute
    if renpy.python.py_eval(condition):
  File "C:\Users\wolfe\Downloads\renpy-6.99.12.4-sdk\renpy\python.py", line 1843, in py_eval
    return py_eval_bytecode(code, globals, locals)
  File "C:\Users\wolfe\Downloads\renpy-6.99.12.4-sdk\renpy\python.py", line 1836, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "game/script.rpy", line 37, in <module>
    if name == "Violet":
NameError: name 'name' is not defined

Windows-8-6.2.9200
Ren'Py 6.99.14.1.3218
Wed Feb 28 20:52:05 2018

User avatar
78909087
Veteran
Posts: 277
Joined: Sat Aug 16, 2014 2:33 pm
Completed: Dungeons and Don't Do It, Wake Up
Projects: Lethe
IRC Nick: Pacermist
Contact:

Re: Certain name reactions??

#11 Post by 78909087 » Thu Mar 01, 2018 8:06 am

That last error shows that the code is referring to an undefined variable "name".
In the code that has been posted, the variables are all called mc_name. Try changing the "name" variable in line 37 to mc_name and see if it works.
I am not friends with the sun.
Image

LazyLycanthrope
Newbie
Posts: 13
Joined: Sat Feb 03, 2018 11:17 pm
Contact:

Re: Certain name reactions??

#12 Post by LazyLycanthrope » Thu Mar 01, 2018 11:23 am

78909087 wrote:
Thu Mar 01, 2018 8:06 am
That last error shows that the code is referring to an undefined variable "name".
In the code that has been posted, the variables are all called mc_name. Try changing the "name" variable in line 37 to mc_name and see if it works.
I tried changing those, but it didn't seem to be the problem?
This is the error log

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/script.rpy", line 48: invalid syntax
        $ name_color = "#013ADF"
         ^
    

Ren'Py Version: Ren'Py 6.99.14.1.3218
Thu Mar 01 07:21:50 2018

User avatar
78909087
Veteran
Posts: 277
Joined: Sat Aug 16, 2014 2:33 pm
Completed: Dungeons and Don't Do It, Wake Up
Projects: Lethe
IRC Nick: Pacermist
Contact:

Re: Certain name reactions??

#13 Post by 78909087 » Thu Mar 01, 2018 11:28 am

Could you PM me your code? I'll have a look through it.
I am not friends with the sun.
Image

User avatar
Milkymalk
Miko-Class Veteran
Posts: 747
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Certain name reactions??

#14 Post by Milkymalk » Thu Mar 01, 2018 3:47 pm

Code: Select all

File "game/script.rpy", line 48: invalid syntax
        $ name_color = "#013ADF"
         ^
Is this by chance inside a python block? You only need a $ in front of a line of code if it's outside of a python block and it's not a renpy script keyword.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

LazyLycanthrope
Newbie
Posts: 13
Joined: Sat Feb 03, 2018 11:17 pm
Contact:

Re: Certain name reactions??

#15 Post by LazyLycanthrope » Thu Mar 01, 2018 6:02 pm

Milkymalk wrote:
Thu Mar 01, 2018 3:47 pm

Code: Select all

File "game/script.rpy", line 48: invalid syntax
        $ name_color = "#013ADF"
         ^
Is this by chance inside a python block? You only need a $ in front of a line of code if it's outside of a python block and it's not a renpy script keyword.
Yeah, it is, but I removed the $ and it still showed up with an error

Post Reply

Who is online

Users browsing this forum: No registered users