Imagemap Saving 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.
Post Reply
Message
Author
User avatar
Morhighan
Miko-Class Veteran
Posts: 975
Joined: Sun Jun 27, 2010 12:54 pm
Completed: AIdol, When Our Journey Ends, Forgotten Not Lost
Organization: MysteryCorgi
Tumblr: MysteryCorgi
Deviantart: MysteryCorgi
Soundcloud: MysteryCorgi
itch: MysteryCorgi
Location: USA
Contact:

Imagemap Saving error

#1 Post by Morhighan »

I was testing out my game, which I just programmed to have an imagemap main menu. The imagemap works perfectly.
Imagemap code:

Code: Select all

init -2 python:

    layout.imagemap_main_menu("ground.jpg", "hover.jpg",
        [ (576, 289, 721, 360, "Start Game"),
          (591, 402, 733, 457, "Load Game"),
          (606, 508, 772, 544, "Quit") ]
          )

label main_menu:

    jump main_menu_screen
However, once I am inside the game, and perform a "right click," however, I get this message:

Code: Select all

I'm sorry, but an exception occured while executing your Ren'Py
script.

TypeError: 'str' object is not callable

While running game code:
 - script at line 38 of C:\Users\Morgana\Desktop\Darker than You Know/game/script.rpy
 - python at line 194 of renpy-6.10.2/common/00library.rpy.
 - script at line 328 of renpy-6.10.2/common/_layout/classic_load_save.rpym
Thank you for any assistance you might provide!

Also, for visual reference, this is what the menu looks like:
Image

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Imagemap Saving error

#2 Post by Aleema »

I don't think that's how main menu imagemaps work. You shouldn't have to do this part:

Code: Select all

label main_menu:

    jump main_menu_screen
Just the imagemap. What's around line 38 of your script.rpy?

User avatar
Morhighan
Miko-Class Veteran
Posts: 975
Joined: Sun Jun 27, 2010 12:54 pm
Completed: AIdol, When Our Journey Ends, Forgotten Not Lost
Organization: MysteryCorgi
Tumblr: MysteryCorgi
Deviantart: MysteryCorgi
Soundcloud: MysteryCorgi
itch: MysteryCorgi
Location: USA
Contact:

Re: Imagemap Saving error

#3 Post by Morhighan »

Thank you, I'll check that. It seemed to have worked with it, so I'll see how it operates without it.

Line 38 is the beginning of the novel, basically.

User avatar
azureXtwilight
Megane Procrastinator
Posts: 4118
Joined: Fri Mar 28, 2008 4:54 am
Completed: Fantasia series (ROT and ROTA), Doppleganger: Dawn of The Inverted Soul, a2 (a due), Time Labyrinth
Projects: At Regime's End
Organization: Memento-Mori VNs, Team Sleepyhead
Location: Yogyakarta, Indonesia.
Contact:

Re: Imagemap Saving error

#4 Post by azureXtwilight »

Uhh, the imagemap main menu should be in the options.rpy, did you put it in script.rpy?
Image

User avatar
Morhighan
Miko-Class Veteran
Posts: 975
Joined: Sun Jun 27, 2010 12:54 pm
Completed: AIdol, When Our Journey Ends, Forgotten Not Lost
Organization: MysteryCorgi
Tumblr: MysteryCorgi
Deviantart: MysteryCorgi
Soundcloud: MysteryCorgi
itch: MysteryCorgi
Location: USA
Contact:

Re: Imagemap Saving error

#5 Post by Morhighan »

It's in the options.rpy area, thank you though for checking. Since I changed it over to imagemap, the saving function has been obsolete.

User avatar
Morhighan
Miko-Class Veteran
Posts: 975
Joined: Sun Jun 27, 2010 12:54 pm
Completed: AIdol, When Our Journey Ends, Forgotten Not Lost
Organization: MysteryCorgi
Tumblr: MysteryCorgi
Deviantart: MysteryCorgi
Soundcloud: MysteryCorgi
itch: MysteryCorgi
Location: USA
Contact:

Re: Imagemap Saving error

#6 Post by Morhighan »

Sorry for the double post...
Anyway, I removed the imagemap only to discover that the save function still didn't work, with or without. I can't enter the "right click" menu jump, and that is the problem, I think.

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: Imagemap Saving error

#7 Post by Jake »

Morhighan wrote: Anyway, I removed the imagemap only to discover that the save function still didn't work, with or without. I can't enter the "right click" menu jump, and that is the problem, I think.
The error message you're getting:
Morhighan wrote:

Code: Select all

TypeError: 'str' object is not callable
suggests that Ren'Py is trying to call a function, but the thing it thinks is a function isn't a function, it's a string.

Here is an example of one way that can happen, from the interactive Python prompt:

Code: Select all

>>> abs(-5)
5
>>> abs = "some string"
>>> abs
'some string'
>>> abs(-5)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: 'str' object is not callable
Normally, 'abs' is a function which returns the absolute value of a number. However, if you don't know this and you create a variable called 'abs' in your game, you'll overwrite the function, meaning that if any code anywhere else in your game tries to use the 'abs' function, it'll actually try and call the variable you created, which won't work.

Another way you can do it is to pass a string variable to some part of Ren'Py which isn't expecting a string:

Code: Select all

    $ myString = "some text"
    
    show mySprite at myString
- this doesn't work and gives the same error.


Similar problems have been reported before, and the ones which have been solved have had the same cause: someone's overwriting a pre-defined Python name for one of their variables, giving variables names like "str".

There's no really easy way to find a big list of all the names you should avoid, and IMO it's one of the very annoying things about Python, that it doesn't warn you when you accidentally overwrite a function or whatever, but it's a working-as-designed problem. If you post the full traceback you're getting then it might be possible to track down the name you've likely overwritten in this case, but as a general rule, give your variables longer, more-descriptive names (it's a good idea anyway!) and you're less likely to overwrite Python pre-defined items.
Server error: user 'Jake' not found

User avatar
Morhighan
Miko-Class Veteran
Posts: 975
Joined: Sun Jun 27, 2010 12:54 pm
Completed: AIdol, When Our Journey Ends, Forgotten Not Lost
Organization: MysteryCorgi
Tumblr: MysteryCorgi
Deviantart: MysteryCorgi
Soundcloud: MysteryCorgi
itch: MysteryCorgi
Location: USA
Contact:

Re: Imagemap Saving error

#8 Post by Morhighan »

Thank you. I've been trying to check over the variables (I haven't done too many) to see what I might have done. Thank you!

Post Reply

Who is online

Users browsing this forum: alyoshaslab, Bing [Bot]