Image not found!?

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
Xerneas363
Newbie
Posts: 3
Joined: Thu Apr 26, 2018 2:09 pm
Contact:

Image not found!?

#1 Post by Xerneas363 »

Hello, I was minding my own business drawing for my game. I put the images in the image folder. To test, I made this script:

Code: Select all

# The script of the game goes in this file.

# Declare characters used by this game. The color argument colorizes the
# name of the character.

define m = Character("May")


# The game starts here.

label start:

    # Show a background. This uses a placeholder by default, but you can
    # add a file (named either "bg room.png" or "bg room.jpg") to the
    # images directory to show it.

    scene bg room

    # This shows a character sprite. A placeholder is used, but you can
    # replace it by adding a file named "eileen happy.png" to the images
    # directory.
  
    image may happy = "mayhappy.png"
    
    show image mayhappy.png

    # These display lines of dialogue.

    m "You've created a new Ren'Py game."

    m "Once you add a story, pictures, and music, you can release it to the world!"

    # This ends the game.

    return
But, there is a traceback and I don't know why!! Please respond asap, my development team can't wait much longer. It's been 3 days.

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 25, in script
    show image mayhappy.png
  File "game/script.rpy", line 25, in <module>
    show image mayhappy.png
NameError: name 'mayhappy' is not defined

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

Full traceback:
  File "game/script.rpy", line 25, in script
    show image mayhappy.png
  File "C:\Users\LeiLoni\Downloads\renpy-6.99.14.3-sdk\renpy\ast.py", line 1131, in execute
    show_imspec(self.imspec, atl=getattr(self, "atl", None))
  File "C:\Users\LeiLoni\Downloads\renpy-6.99.14.3-sdk\renpy\ast.py", line 1087, in show_imspec
    expression = renpy.python.py_eval(expression)
  File "C:\Users\LeiLoni\Downloads\renpy-6.99.14.3-sdk\renpy\python.py", line 1919, in py_eval
    return py_eval_bytecode(code, globals, locals)
  File "C:\Users\LeiLoni\Downloads\renpy-6.99.14.3-sdk\renpy\python.py", line 1912, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "game/script.rpy", line 25, in <module>
    show image mayhappy.png
NameError: name 'mayhappy' is not defined

Windows-8-6.2.9200
Ren'Py 6.99.14.3.3347
Life's Mysteries 1.0
Thu Apr 26 11:15:19 2018

User avatar
Pattikou
Newbie
Posts: 2
Joined: Thu Apr 12, 2018 3:57 pm
Tumblr: Pattiko
Deviantart: Pattikou
Location: Europe
Contact:

Re: Image not found!?

#2 Post by Pattikou »

I'm still a beginner at using ren'py but I think you can replace

Code: Select all

    image may happy = "mayhappy.png"
    
    show image mayhappy.png
with just

Code: Select all

show mayhappy

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Image not found!?

#3 Post by Imperf3kt »

Theres a few things wrong with this. I don't have the time to go over it all properly, so I'll give you the rushed version:

Define images outside any labels.

Code: Select all

image may happy = "mayhappy.png"
label start:
    e "indent four spaces"
You don't need to define images if you don't want to. The following all work the same way.

Code: Select all

.   show mayhappy
    show "mayhappy.png"

Code: Select all

image may happy = "mayhappy.png"
label start:
    show may happy
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Post Reply

Who is online

Users browsing this forum: No registered users