Trying again... New Ren'Py - Old code

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
Nio
Regular
Posts: 160
Joined: Mon Jan 03, 2005 4:37 am
Projects: ??????
Location: In his own little world.
Contact:

Trying again... New Ren'Py - Old code

#1 Post by Nio »

I know the title is not descriptive, but I have a handful of problems and questions.

I was working on a Ren'Py shell (something with general features that I can use for several games) a while ago, but had to stop. Now coming back several months later and installing the latest Ren'Py I'm having a lot of problems that didnt' exist before. My assumption is that my code is out of date. I seem to have forgotten all that I learned.

Any help would be great.

Main Menu: (main_menu.rpy)
I have a splash that fades between a couple logo screens then it goes to a custom menu.
--The menu pops up and then fades in. Which is an odd thing.
--The "Extra" button gives an error - ( global name '_button_factory' is not defined ) (gallery.rpy - a script from renpy.org)
--The preference/setting button call doesn't work. What is the intra_jump for that now?


In-Game
--When I right click in the game it takes me to a broken version of my custom menu. I have now idea why.
- I figured this out.

In-Game Menu (button_game_menu.rpy)
I have an in game menu that is below the text box. When starting a new game it works fine (so far).
--When I load a saved game the in-game (text box) menu does not show. - It would seem this was because I was using an old save. Using a new save seems to have fixed that.

Sub-Game Menu (When you right click in the game - Custom in main_menu.rpy)
--When clicking on New Game it doesn't ask "Are you sure..." it just starts a new game.

Gallery
--The return button goes into the game instead of where you last were.

I attached some of the files.

Things I want to add to the game:
--A player name prompt so that I can place the player name in the game text.
--Custom menus. I have the main menu and sub menu (game menu), but still trying to add custom yesno_prompt, settings, load/save etc.
--Blinking (animated eyes). This would be best as a separate file (just the eyes) that overlay and is aligned based off the character image (not the game screen 0,0).
--Flapping mouth with text. Same as above. - I see there is a tut for this on Ren'Py. I'll give that a shot.


Again, thanks for any help or advice. I'll continue to try and figure this out and I'm sure I'll have heaps of more questions soon.
Attachments
gallery.rpy
(8.52 KiB) Downloaded 49 times
button_game_menu.rpy
(1.39 KiB) Downloaded 55 times
options.rpy
(9.44 KiB) Downloaded 56 times
main_menu.rpy
(2 KiB) Downloaded 59 times
Last edited by Nio on Wed Sep 03, 2008 9:22 pm, edited 9 times in total.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Trying again... New Ren'Py - Old code

#2 Post by PyTom »

If you call layout.compat() before the theme call, everything will work as it did long ago. The interface was rewritten and simplified a while back, but it does require some changes to code.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Nio
Regular
Posts: 160
Joined: Mon Jan 03, 2005 4:37 am
Projects: ??????
Location: In his own little world.
Contact:

Re: Trying again... New Ren'Py - Old code

#3 Post by Nio »

PyTom wrote:If you call layout.compat() before the theme call, everything will work as it did long ago. The interface was rewritten and simplified a while back, but it does require some changes to code.
Ah, well that might have something to do with it. That certainly fixed the call for the gallery... But I still have the other problems. I updated my first post with the current problems that I still have.

As always, thanks for your help.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Trying again... New Ren'Py - Old code

#4 Post by PyTom »

Can you email a full version of your game over to pytom@bishoujo.us? It's easier for me to debug the thing if I can run it.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Nio
Regular
Posts: 160
Joined: Mon Jan 03, 2005 4:37 am
Projects: ??????
Location: In his own little world.
Contact:

Re: Trying again... New Ren'Py - Old code

#5 Post by Nio »

PyTom wrote:Can you email a full version of your game over to pytom@bishoujo.us? It's easier for me to debug the thing if I can run it.
I updated my OP... again.

-__- I don't want to take up your precious time... you are too kind.

I have emailed a link to the zip from my site. You will see that it is currently using all copyrighted work from another date sim. Many of the buttons are place-holders and some are used more than once. I know where they go (or are supposed to go), you'll probably have to look at the code to see where it's supposed to go.

The game text is just "blah blah" text.

Yes, I'm making excuses.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Trying again... New Ren'Py - Old code

#6 Post by PyTom »

Nio wrote: --The "Extra" button gives an error - ( global name '_button_factory' is not defined ) (gallery.rpy - a script from renpy.org)
This was fixed by upgrading to an updated version of new_gallery.rpy.
Sub-Game Menu (When you right click in the game - Custom in main_menu.rpy)
--When clicking on New Game it doesn't ask "Are you sure..." it just starts a new game.
Hm... you really shouldn't call "New Game" from inside the game. If you really want to, you should have something like:

Code: Select all

label new_game_prompt:
    if layout.yesno_prompt(None, u"Are you sure you want to start a new game?\nThis will lose unsaved progress."):
        ui.jumpsoutofcontext("start")()
    else:
        return
and to invoke this, have the appropriate imagebutton call ui.callsinnewcontext("new_game_prompt")

--The return button goes into the game instead of where you last were.
You intra-jumped to gallery, instead of just having the menu go to it.

I attached some of the files.
--A player name prompt so that I can place the player name in the game text.
You can use renpy.input to prompt for the player's name, and then a DynamicCharacter to use that name. (You can find an example of this in the demo, in demo_ui.rpy.)
--Custom menus. I have the main menu and sub menu (game menu), but still trying to add custom yesno_prompt, settings, load/save etc.
You'll want to read the section on this in the reference manual:

http://www.renpy.org/wiki/renpy/doc/ref ... ew_Layouts

Using layout.compat was a bit of a red herring, as one of the big advantages of the new layout system is that it makes it easier to define your own menus and things.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Nio
Regular
Posts: 160
Joined: Mon Jan 03, 2005 4:37 am
Projects: ??????
Location: In his own little world.
Contact:

Re: Trying again... New Ren'Py - Old code

#7 Post by Nio »

PyTom wrote: This was fixed by upgrading to an updated version of new_gallery.rpy.
This actually fixed that problem: layout.compat()
PyTom wrote: Hm... you really shouldn't call "New Game" from inside the game. If you really want to, you should have something like:

Code: Select all

label new_game_prompt:
    if layout.yesno_prompt(None, u"Are you sure you want to start a new game?\nThis will lose unsaved progress."):
        ui.jumpsoutofcontext("start")()
    else:
        return
and to invoke this, have the appropriate imagebutton call ui.callsinnewcontext("new_game_prompt")
I'm getting this error with that: AttributeError: Layout instance has no attribute 'yesno_prompt'.
I do have a yesno_prompt but it does't seem to work nor does it seem to be using the one you provided.
PyTom wrote: You intra-jumped to gallery, instead of just having the menu go to it.
Hm... it works with load game and prefs. Would that be a ui. command? Those don't seem to allow for transitions.
PyTom wrote: I attached some of the files.
PyTom wrote: You can use renpy.input to prompt for the player's name, and then a DynamicCharacter to use that name. (You can find an example of this in the demo, in demo_ui.rpy.)
I'm not up to this point yet. Will I be able to control where this entry is positioned? IE This would be a screen that shows up during a new game -- "Please enter your name"
PyTom wrote: You'll want to read the section on this in the reference manual:

http://www.renpy.org/wiki/renpy/doc/ref ... ew_Layouts

Using layout.compat was a bit of a red herring, as one of the big advantages of the new layout system is that it makes it easier to define your own menus and things.
I'm actually getting this with the other post by replacing the interface buttons with images etc. So that should work for my needs. It's not the layout of those screens (which seems you can actually change), it's just that I would like to use images for all the elements etc. A custom menu layout was the more imporatant thing and I already have that, thanks to you and everyone here.

Sorry, again, for all the questions. I'm more of an artist type then a coder. I'm trying though.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Trying again... New Ren'Py - Old code

#8 Post by PyTom »

Nio wrote: This actually fixed that problem: layout.compat()
Sort of. It did, but at the same time, it forces you to use the old way of doing things, which in turn means that some of the things that exist in the new code don't exist for you. (And not everything that exists in the new way exists in the old way, unfortunately.)

Code: Select all

label new_game_prompt:
    if layout.yesno_prompt(None, u"Are you sure you want to start a new game?\nThis will lose unsaved progress."):
        ui.jumpsoutofcontext("start")()
    else:
        return
and to invoke this, have the appropriate imagebutton call ui.callsinnewcontext("new_game_prompt")
I'm getting this error with that: AttributeError: Layout instance has no attribute 'yesno_prompt'.
I do have a yesno_prompt but it does't seem to work nor does it seem to be using the one you provided.
That's a problem of the oldschool way of doing things... there isn't a good way to do yes/no prompts.
Hm... it works with load game and prefs. Would that be a ui. command? Those don't seem to allow for transitions.
You can use renpy.transition to invoke a transition here. Basically:
label gallery:
$ renpy.transition(dissolve)
...
I'm not up to this point yet. Will I be able to control where this entry is positioned? IE This would be a screen that shows up during a new game -- "Please enter your name"
If renpy.input doesn't give you enough control, you can always use ui.text and ui.input. Something like:

Code: Select all

label prompt_for_name:
    $ ui.text("Please enter your name:", xalign=0.5, yalign=0.4)
    $ ui.input('', xalign=0.5, yaling=0.5)
    $ name = ui.interact()
    if name == '':
        $ name = 'Guy Shy'
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Nio
Regular
Posts: 160
Joined: Mon Jan 03, 2005 4:37 am
Projects: ??????
Location: In his own little world.
Contact:

Re: Trying again... New Ren'Py - Old code

#9 Post by Nio »

PyTom wrote:
Nio wrote: This actually fixed that problem: layout.compat()
Sort of. It did, but at the same time, it forces you to use the old way of doing things, which in turn means that some of the things that exist in the new code don't exist for you. (And not everything that exists in the new way exists in the old way, unfortunately.)
This has me a little concerned. Does this only affect the custom menu features? I'm not really sure what I should do about it. What would I lose switching to the new way? Here I thought I was making some progress. >.<

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Trying again... New Ren'Py - Old code

#10 Post by PyTom »

Hm... The problem is, some of your old code may not work. I've sent you an updated version that works new-style, and frankly I think it will make sense to bite the bullet and upgrade, as layout.compat isn't really maintained, at least until people go and send me bug reports.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Nio
Regular
Posts: 160
Joined: Mon Jan 03, 2005 4:37 am
Projects: ??????
Location: In his own little world.
Contact:

Re: Trying again... New Ren'Py - Old code

#11 Post by Nio »

I noticed that layout.compat was gone from what you emailed. I'm currently trying to move over the additions I made since then.

But as usual I messed something up as now I can't access the Prefs again... ><

I added the new_game_prompt that you posted earlier and the custom image buttons (the init 1 python stuff) that we were talking about in the other post.

Now I get this error from any pref button.

AttributeError: 'NoneType' object has no attribute 'get'

>< I think I owe PyTom some advil. :P

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Trying again... New Ren'Py - Old code

#12 Post by PyTom »

Can you send me the full traceback, and the relevant bits of code? I'll look at them in the morning.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Nio
Regular
Posts: 160
Joined: Mon Jan 03, 2005 4:37 am
Projects: ??????
Location: In his own little world.
Contact:

Re: Trying again... New Ren'Py - Old code

#13 Post by Nio »

Code: Select all

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

AttributeError: 'NoneType' object has no attribute 'get'

While running game code:
 - script at line 664 of renpy-6.6.3/common/00library.rpy
 - python at line 664 of renpy-6.6.3/common/00library.rpy.
 - script at line 79 of renpy-6.6.3/common/_layout/classic_preferences.rpym
 - python at line 121 of renpy-6.6.3/common/00layout.rpy.

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

  File "C:\Program Files\renpy-6.6.3\renpy\bootstrap.py", line 212, in bootstrap
  File "C:\Program Files\renpy-6.6.3\renpy\main.py", line 303, in main
  File "C:\Program Files\renpy-6.6.3\renpy\main.py", line 92, in run
  File "C:\Program Files\renpy-6.6.3\renpy\execution.py", line 199, in run
  File "C:\Program Files\renpy-6.6.3\renpy\ast.py", line 554, in execute
  File "C:\Program Files\renpy-6.6.3\renpy\python.py", line 880, in py_exec_bytecode
  File "renpy-6.6.3/common/00library.rpy", line 664, in <module>
  File "C:\Program Files\renpy-6.6.3\renpy\game.py", line 272, in call_in_new_context
  File "C:\Program Files\renpy-6.6.3\renpy\execution.py", line 199, in run
  File "C:\Program Files\renpy-6.6.3\renpy\ast.py", line 554, in execute
  File "C:\Program Files\renpy-6.6.3\renpy\python.py", line 880, in py_exec_bytecode
  File "renpy-6.6.3/common/_layout/classic_preferences.rpym", line 80, in <module>
  File "renpy-6.6.3/common/_layout/classic_preferences_common.rpym", line 52, in _prefs_screen_run
  File "renpy-6.6.3/common/_layout/classic_preferences_common.rpym", line 120, in render
  File "renpy-6.6.3/common/00layout.rpy", line 121, in button
  File "C:\Program Files\renpy-6.6.3\renpy\ui.py", line 313, in button
  File "C:\Program Files\renpy-6.6.3\renpy\display\behavior.py", line 311, in __init__
  File "C:\Program Files\renpy-6.6.3\renpy\display\layout.py", line 641, in __init__
  File "C:\Program Files\renpy-6.6.3\renpy\display\layout.py", line 94, in __init__
  File "C:\Program Files\renpy-6.6.3\renpy\display\core.py", line 93, in __init__
  File "C:\Program Files\renpy-6.6.3\renpy\style.py", line 581, in __init__
  File "C:\Program Files\renpy-6.6.3\renpy\style.py", line 390, in build_style
AttributeError: 'NoneType' object has no attribute 'get'

While running game code:

Ren'Py Version: Ren'Py 6.6.3a
Attached are pretty much the only things I changed that you sent me.

As a side note when you click "no" on the prompt to quit the game it starts a new game. ><
Attachments
custom_menus.rpy
(532 Bytes) Downloaded 49 times
main_menu.rpy
(2.5 KiB) Downloaded 51 times

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Trying again... New Ren'Py - Old code

#14 Post by PyTom »

I'm not able to repeat this crash, using the files you gave. Is there some sequence of input I need to give?

To fix the problem with the quit prompt, you need to change:

ui.jumps("_quit_prompt")

to

ui.calls_in_new_context("_quit_prompt")

in main_menu.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Nio
Regular
Posts: 160
Joined: Mon Jan 03, 2005 4:37 am
Projects: ??????
Location: In his own little world.
Contact:

Re: Trying again... New Ren'Py - Old code

#15 Post by Nio »

Alright, that worked. Thanks again!

So I still have the problem with the prefs buttons not working.

I also have a bug with the menu that is below the text box in the game. It doesn't show when you load a game or when you start a new game from the sub-menu, which you advised against, but it might be the same issue. I have it forced to true after the start label.

Code: Select all

    # Show Button Game Menu and set window view
    $ show_button_menu = True
    $ _window_during_transitions = True

Post Reply

Who is online

Users browsing this forum: achiuachoo, henne, Semrush [Bot]