[SOLVED] messaging system issues

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
Fleeples
Newbie
Posts: 24
Joined: Thu Apr 25, 2013 2:13 pm
Projects: If!Girl
Contact:

[SOLVED] messaging system issues

#1 Post by Fleeples »

Hi, I've been using this messaging system in my visual novel to create a process where the player can check their phone for messages. I coped the text as directed into a file named messages.rpy in the game directory. I've then altered the code so that the trigger for viewing the messages is clicking the phone in the corner of the screen, using an imagemap. Therefore, I've implemented the code thusly:

Code: Select all

scene bg street day
with dissolve
$ result = renpy.imagemap("phone", "pmap", [
                           (712, 2, 774, 60, "check"),
                          ])

if result == "check":
    $ show_messages()
    

"It's been a long day."
"It's not that I object to school, per se. Really. I get why it's necessary. I do. But it's a lot less fun when you know all the answers. Every time I get asked a question, I can figure it out if I have so much as an inkling in the right direction. And that wears pretty thin."
"What I need is to \understand.\ And school can't teach you that. They try, and some of them want to, but mostly they're there so you can pass exams and go on in life. Sure, you pick up stuff along the way, but school as a format is pro-knowledge, anti-understanding."
"Even though I've not said a word of this to Alicia, I can hear her in my head: 'First world problems, much?'"
$ add_message("Tonight" "Mum" "Faith - I have an appointment tonight so I might not be in when you get back. Dinner is in the oven, can you put it on at about 5:30?")
[Dialogue Continues]
So I've got the messages appearing halfway through the dialogue, being able to be checked at any time by pressing the messages. Formerley I was getting an error about the statement needing at least 3 arguments and only one being stated, and I had no idea what that was about. Now I have no idea what I've changed but instead am just getting a complete frozen screen and the game refusing to move on to the next dialogue option, going completely blank in the box.

Anyone got any ideas?
Last edited by Fleeples on Tue May 07, 2013 1:26 pm, edited 1 time in total.

apricotorange
Veteran
Posts: 479
Joined: Tue Jun 05, 2012 2:01 am
Contact:

Re: Game stops moving on when messaging system is implemente

#2 Post by apricotorange »

That isn't the right way to make a phone icon in the corner which the player can click any time... you need something more like this:

Code: Select all

# Put this code somewhere outside the main script file
screen phone_icon:
  button action ui.callsinnewcontext("do_show_messages"):
    add "phone"
label do_show_message:
  $ show_messages()
  return

Code: Select all

  # Put this where you want to show the phone icon
  show screen phone_icon
Also, you're missing commas in your calls to add_message().

User avatar
Fleeples
Newbie
Posts: 24
Joined: Thu Apr 25, 2013 2:13 pm
Projects: If!Girl
Contact:

Re: Game stops moving on when messaging system is implemente

#3 Post by Fleeples »

Thank you for the info, but I'm now getting a different error. :(

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 138, in script
ScriptError: could not find label 'do_show_messages'.

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

Full traceback:
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\execution.py", line 288, in run
    node.execute()
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\ast.py", line 453, in execute
    renpy.exports.say(who, what, interact=self.interact)
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\exports.py", line 757, in say
    who(what, interact=interact)
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\character.py", line 795, in __call__
    self.do_display(who, what, cb_args=self.cb_args, **display_args)
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\character.py", line 671, in do_display
    **display_args)
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\character.py", line 474, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\ui.py", line 237, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\display\core.py", line 1853, in interact
    repeat, rv = self.interact_core(preloads=preloads, **kwargs)
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\display\core.py", line 2392, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\display\layout.py", line 749, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\display\layout.py", line 749, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\display\layout.py", line 749, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\display\screen.py", line 319, in event
    rv = self.child.event(ev, x, y, st)
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\display\layout.py", line 749, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\display\behavior.py", line 625, in event
    rv = run(self.clicked)
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\display\behavior.py", line 211, in run
    return var(*args, **kwargs)
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\curry.py", line 38, in __call__
    **dict(self.kwargs.items() + kwargs.items()))
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\game.py", line 369, in call_in_new_context
    renpy.execution.run_context(False)
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\execution.py", line 509, in run_context
    context.run()
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\execution.py", line 271, in run
    node = renpy.game.script.lookup(self.current)
  File "C:\Users\Hannah\Desktop\renpy-6.15.4-sdk\renpy\script.py", line 537, in lookup
    raise ScriptError("could not find label '%s'." % str(label))
ScriptError: could not find label 'do_show_messages'.

Windows-post2008Server-6.2.9200
Ren'Py 6.15.4.320
If!Girl 0.0
(I'm just really confused now.)

Also, I'm sorry, but I don't understand where I'm supposed to be putting commas? :(

apricotorange
Veteran
Posts: 479
Joined: Tue Jun 05, 2012 2:01 am
Contact:

Re: Game stops moving on when messaging system is implemente

#4 Post by apricotorange »

Oh, oops, typo :( The label is supposed to be "label do_show_messages:".

About the commas: instead of what you wrote, you want something like the following:

Code: Select all

$ add_message("Tonight", "Mum", "Faith - I have an appointment tonight so I might not be in when you get back. Dinner is in the oven, can you put it on at about 5:30?")

User avatar
Fleeples
Newbie
Posts: 24
Joined: Thu Apr 25, 2013 2:13 pm
Projects: If!Girl
Contact:

Re: Game stops moving on when messaging system is implemente

#5 Post by Fleeples »

Hey, thanks so much, that's solved my error problem - but I'm not convinced your advice about using a screen instead of an imagemap was correct, because now the screen shows up if I click anywhere on the screen...

apricotorange
Veteran
Posts: 479
Joined: Tue Jun 05, 2012 2:01 am
Contact:

Re: Game stops moving on when messaging system is implemente

#6 Post by apricotorange »

If you're using an image big enough to cover the whole screen, the button will cover the whole screen...

User avatar
Fleeples
Newbie
Posts: 24
Joined: Thu Apr 25, 2013 2:13 pm
Projects: If!Girl
Contact:

Re: Game stops moving on when messaging system is implemente

#7 Post by Fleeples »

apricotorange wrote:If you're using an image big enough to cover the whole screen, the button will cover the whole screen...
Derp, yeah, I worked that out after I posted it. (*facepalm* This is why I shouldn't code late at night.) Thank you so much for your help in this. I really appreciate it. <3

(Now I'm just trying to work out how to get rid of the screen that appears behind the button... Pretty sure this should be easy and I am thick.)

apricotorange
Veteran
Posts: 479
Joined: Tue Jun 05, 2012 2:01 am
Contact:

Re: Game stops moving on when messaging system is implemente

#8 Post by apricotorange »

"background None"? Or use an imagemap statement instead of a button? (I'm assuming you're talking about the background of the button.)

User avatar
Fleeples
Newbie
Posts: 24
Joined: Thu Apr 25, 2013 2:13 pm
Projects: If!Girl
Contact:

Re: Game stops moving on when messaging system is implemente

#9 Post by Fleeples »

apricotorange wrote:"background None"? Or use an imagemap statement instead of a button? (I'm assuming you're talking about the background of the button.)
Yeah, I've tried that, but no matter how many guides I read I can't for the life of me work out /where/ I'm supposed to put that. In the main file after "show screen phone_icon" ? Or somewhere in the other file?

Sorry I'm so thick. :S

apricotorange
Veteran
Posts: 479
Joined: Tue Jun 05, 2012 2:01 am
Contact:

Re: Game stops moving on when messaging system is implemente

#10 Post by apricotorange »

Code: Select all

screen phone_icon:
  button background None action ui.callsinnewcontext("do_show_messages"):
    add "phone"

User avatar
Fleeples
Newbie
Posts: 24
Joined: Thu Apr 25, 2013 2:13 pm
Projects: If!Girl
Contact:

Re: Game stops moving on when messaging system is implemente

#11 Post by Fleeples »

Thank you! (Derp. Did not think of putting it there at all for some reason.)

Post Reply

Who is online

Users browsing this forum: Google [Bot]