Basic Message System
Forum rules
Do not post questions here!
This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Do not post questions here!
This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
-
- Regular
- Posts: 91
- Joined: Mon Jul 31, 2017 8:33 am
- Deviantart: LedianWithACamera
- Contact:
Re: Basic Message System
[Resolved, deleted because unanswered and largely unimportant, stupid mistake on my part.]
Last edited by TheChatotMaestro on Mon Sep 11, 2017 9:59 pm, edited 1 time in total.
-
- Regular
- Posts: 91
- Joined: Mon Jul 31, 2017 8:33 am
- Deviantart: LedianWithACamera
- Contact:
Re: Basic Message System
I kept trying, and nothing fixed it... I'm so sorry if repeated posting is annoying, I just really like the idea of this system, and really want to try it out in my game. Anyone ever had this issue? (Using latest version of Ren'Py, so that's probably the source of a lot of problems since this code's kinda old.)
-
- Regular
- Posts: 91
- Joined: Mon Jul 31, 2017 8:33 am
- Deviantart: LedianWithACamera
- Contact:
Re: Basic Message System
Fixed my earlier problem lol, revisited this after ages, but now I'm getting this...
The block in question:
Anyone understand?
(Deleting previous messages so as not to be spammy. )
Code: Select all
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.
File "game/messages.rpy", line 148: u'text' is not a keyword argument or valid child for the label statement.
text ("Messages: %d (%d unread)") % (message_count(), new_message_count())
^
Ren'Py Version: Ren'Py 6.99.12.4.2187
Code: Select all
screen mailbox:
tag menu
modal True
default current_message = None
$ available_drafts = [i for i in contacts if i.draft_label]
frame:
style_group "mailbox"
vbox:
label "Inbox":
if new_message_count() > 0:
text ("Messages: %d (%d unread)") % (message_count(), new_message_count())
else:
text ("Messages: %d") % message_count()
side "c r":
area (0,0,800,93)
viewport id "message_list":
draggable True mousewheel True
vbox:
for i in mail:
if i.view:
if not i.read:
textbutton ("*NEW* " + i.sender + " - " + i.subject) action [SetScreenVariable("current_message",i), i.mark_read] xfill True
else:
textbutton (i.sender + " - " + i.subject) action SetScreenVariable("current_message",i) xfill True
vbar value YScrollValue("message_list")
hbox:
null height 20
side "c r":
area (0,0,800,380)
viewport id "view_message":
draggable True mousewheel True
vbox:
if current_message:
text ("From: " + current_message.sender)
text ("Subject: " + current_message.subject)
text current_message.body
vbar value YScrollValue("view_message")
use mailbox_commands
(Deleting previous messages so as not to be spammy. )
-
- Regular
- Posts: 91
- Joined: Mon Jul 31, 2017 8:33 am
- Deviantart: LedianWithACamera
- Contact:
Re: Basic Message System
And like magic, I complain about my problems on the forum and fix them 20 minutes later.
This was kinda tricky, though, so here's what I changed it to:
Dunno if it does exactly the same thing, but I'm not getting an error message anymore!
This was kinda tricky, though, so here's what I changed it to:
Code: Select all
screen mailbox:
tag menu
modal True
default current_message = None
$ available_drafts = [i for i in contacts if i.draft_label]
frame:
style_group "mailbox"
vbox:
label "Inbox"
if new_message_count() > 0:
text "New Messages: [new_messages]"
else:
text "No New Messages"
side "c r":
area (0,0,800,93)
viewport id "message_list":
draggable True mousewheel True
vbox:
for i in mail:
if i.view:
if not i.read:
textbutton ("*NEW* " + i.sender + " - " + i.subject) action [SetScreenVariable("current_message",i), i.mark_read] xfill True
else:
textbutton (i.sender + " - " + i.subject) action SetScreenVariable("current_message",i) xfill True
vbar value YScrollValue("message_list")
hbox:
null height 20
side "c r":
area (0,0,800,380)
viewport id "view_message":
draggable True mousewheel True
vbox:
if current_message:
text ("From: " + current_message.sender)
text ("Subject: " + current_message.subject)
text current_message.body
vbar value YScrollValue("view_message")
use mailbox_commands
-
- Newbie
- Posts: 1
- Joined: Tue Sep 19, 2017 8:57 am
- Contact:
Re: Basic Message System
Is there a more permanent solution to this? I've got the code working as a receive only system, but this reply system looks really cool, and I'd love to be able to use it. But I can't figure out what's wrong to create the issue in the post quoted.LyannaCore wrote: ↑Wed Jun 21, 2017 2:03 pm I realize this systems is a bit old now, so it's probably just something that has changed with Renpy updates, but trying to use it messes up my existing menus.
With the messages.rpy included and integrated as required, they are aligned to the left and have no change when moused over:
.
Without the message framework, it looks like this:
The beginning of my script code is like this while using the messages.rpy framework:Any ideas what the issue could be?Code: Select all
label start: ## Message Stuff ## $ mail = [] $ mail_queue = [] # for message delay $ contacts = [] # for draft feature scene black with fade show screen mailbox_overlay "Where would you like to start?" menu: "Intro": jump start1 "Waking up": jump wake1 "Laundry": $ pcfirstname = "Lyanna" $ pclastname = "Core" jump laundryservice "Ship Paperwork": $ pcfirstname = "Lyanna" $ pclastname = "Core" $ laundrychoice = 1 jump creation1 "Ship Start": $ pcfirstname = "Lyanna" $ pclastname = "Core" jump shipstart1 "System Map": $ pcfirstname = "Lyanna" $ pclastname = "Core" jump system_map
Re: Basic Message System
How can we customize the textbutton appearance? the box that displays the name and subject.
-
- Regular
- Posts: 91
- Joined: Mon Jul 31, 2017 8:33 am
- Deviantart: LedianWithACamera
- Contact:
Re: Basic Message System
had too many tabs open, put this in the wrong thread >M<
Re: Basic Message System
gonna use this, thanks
- wyverngem
- Miko-Class Veteran
- Posts: 615
- 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: Basic Message System
Code: Select all
While running game code:
File "game/script.rpy", line 43, in <module>
$ deliver_all()
File "game/messages.rpy", line 82, in deliver_all
mail.extend(mail_queue)
UnboundLocalError: local variable 'mail_queue' referenced before assignment
Windows-8-6.2.9200
Ren'Py 7.0.0.196
- Potato0095
- Regular
- Posts: 84
- Joined: Sun May 08, 2016 8:40 pm
- Projects: LoveCraft
- itch: potato95
- Location: Brazil
- Contact:
Re: Basic Message System
Well, it seems we are not getting an answer here. I tested early today, Ren'Py v 7.1.3.1092. At first the game crashed, so I went in a full debug attempt.
I removed the "default choice menu" under the updated one, the game did start, enhance the "DID".
The first line in my script is a menu with 2 choices. Neither appeared. I had similar bugs with menus since I started using this system, so I thought it was the same. I removed the messages.rpy from my game folder.
The game started ok, I clicked start and the choices appeared.
This system is old (2013) and (if I'm not mistaken) didn't receive any official updates for the new GUI Ren'Py system, so it's old AND outdated. I'd recommend using a new one, made / edited by littanana. They tweaked Cute Demon Crashers' code to have a reply system (it has images too!). The last update was on Aug 2018 (if I'm not mistaken), so it's almost up to date (the last Ren'Py stable release is from Nov 2018) with Ren'Py. I didn't test yet though.
viewtopic.php?t=40245
The codes from littanana look like this on the script:
I removed the "default choice menu" under the updated one, the game did start, enhance the "DID".
Code: Select all
# else:
# this is the default choice menu
# screen choice(items):
# style_prefix "choice"
# vbox:
# for i in items:
# textbutton i.caption action i.action
# window:
# style "menu_window"
# xalign 0.5
# ypos 405
# yanchor 0.5
# vbox:
# style "menu"
# spacin 2
# for caption, action, chosen in items:
# if action:
# button:
# action action
# style "choice_button"
# text caption style "menu_choice"
# else:
# text caption style "menu_caption"
# for i in items:
# textbutton i.caption action i.action
The game started ok, I clicked start and the choices appeared.
This system is old (2013) and (if I'm not mistaken) didn't receive any official updates for the new GUI Ren'Py system, so it's old AND outdated. I'd recommend using a new one, made / edited by littanana. They tweaked Cute Demon Crashers' code to have a reply system (it has images too!). The last update was on Aug 2018 (if I'm not mistaken), so it's almost up to date (the last Ren'Py stable release is from Nov 2018) with Ren'Py. I didn't test yet though.
viewtopic.php?t=40245
The codes from littanana look like this on the script:
Code: Select all
call message_img("nadia", "it works with images too!","images/pic1.png") # Message with picture included
call message("nadia", "the text box changes depending on how much content there is. dont put too big images or its gonna look weeeeiiiird") # Message without picture
call message("nadia", "you can also do menus here")
"There are two types of lies: Lies that hurt, and lies that don't."
- Potato0095
- Regular
- Posts: 84
- Joined: Sun May 08, 2016 8:40 pm
- Projects: LoveCraft
- itch: potato95
- Location: Brazil
- Contact:
Re: Basic Message System
It seems that 6.99 accepted "screen choice(items)" inside "screen choice". Ren'Py 7 doesn't. If anyone is willing to debug the code...
Code: Select all
screen choice:
if reply_screen or draft_screen:
# this is the menu for message replies and drafts
frame:
style_group "mailbox"
vbox:
label "Draft"
if reply_screen:
text ("To: " + current_message.sender)
text ("Subject: Re: " + current_message.subject)
else:
text ("To: " + contact.name)
text ("Subject: " + message_title)
null height 30
for caption, action, chosen in items:
if action:
button:
action action
style "menu_choice_button" xalign 0.5
text caption text_align 0.5
else:
text caption style "menu_caption"
else:
# this is the default choice menu
screen choice(items):
style_prefix "choice"
vbox:
for i in items:
textbutton i.caption action i.action
window:
style "menu_window"
xalign 0.5
ypos 405
yanchor 0.5
vbox:
style "menu"
spacin 2
for caption, action, chosen in items:
if action:
button:
action action
style "choice_button"
text caption style "menu_choice"
else:
text caption style "menu_caption"
for i in items:
textbutton i.caption action i.action
"There are two types of lies: Lies that hurt, and lies that don't."
- wyverngem
- Miko-Class Veteran
- Posts: 615
- 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: Basic Message System
wyverngem wrote: ↑Mon Aug 13, 2018 2:55 pmAnyone else getting this error?Code: Select all
While running game code: File "game/script.rpy", line 43, in <module> $ deliver_all() File "game/messages.rpy", line 82, in deliver_all mail.extend(mail_queue) UnboundLocalError: local variable 'mail_queue' referenced before assignment Windows-8-6.2.9200 Ren'Py 7.0.0.196
Marked it as a global mail_queue and it seems to fix the deliver_all.
Code: Select all
def deliver_all():
global mail_queue
mail.extend(mail_queue)
mail_queue = list()
- parttimestorier
- Veteran
- Posts: 429
- Joined: Thu Feb 09, 2017 10:29 pm
- Completed: No Other Medicine, Well Met By Moonlight, RE:BURN, The Light at the End of the Ocean, Take A Hike!, Wizard School Woes
- Projects: Seeds of Dreams
- itch: janetitor
- Location: Canada
- Contact:
Re: Basic Message System
I've been playing around with this code today and it's really cool - thanks for sharing it, saguaro! But I'm wondering about how to make something work in it, and I'd appreciate if anyone else who has some more experience could help me out.
I think it would be really cool if I could set it up so that once you've read a certain message, another one pops up right away, without the player needing to exit the overlay and click through dialogue to make a new one arrive. I attempted to set that up by putting this part right after the start label, when all the other messages are set up:
And then this in the mailbox screen part of messages.rpy:
Ideally, I want it to work so that once you've read the "TPS Reports" message, then the "Message Delay!" message delivers. But for some reason, right now it just delivers the "Message Delay!" message as soon as I open the mailbox, before I've read the "TPS Reports" message, even though I have that if statement in there.
Does anyone have any ideas for how I could make that work? I'd also love to make a new message get delivered once a specific other message has been deleted, if that would be possible.
I think it would be really cool if I could set it up so that once you've read a certain message, another one pops up right away, without the player needing to exit the overlay and click through dialogue to make a new one arrive. I attempted to set that up by putting this part right after the start label, when all the other messages are set up:
Code: Select all
$ add_message("Message Delay!", "Eileen", "This is a delayed message.", delay=True)
Code: Select all
if check("TPS Reports"):
$ deliver_next()
Does anyone have any ideas for how I could make that work? I'd also love to make a new message get delivered once a specific other message has been deleted, if that would be possible.
- parttimestorier
- Veteran
- Posts: 429
- Joined: Thu Feb 09, 2017 10:29 pm
- Completed: No Other Medicine, Well Met By Moonlight, RE:BURN, The Light at the End of the Ocean, Take A Hike!, Wizard School Woes
- Projects: Seeds of Dreams
- itch: janetitor
- Location: Canada
- Contact:
Re: Basic Message System
In case anyone else who uses this code is interested, I've figured out one of the things I wanted to do, which was to check whether the player has deleted a message, similar to how you can check whether they've read one. Underneath the part of messages.rpy with "def check(subject)", which defines how to check whether a message has been read, I've added this:
Technically, I think this will return True if the message simply isn't viewable in the inbox for any reason, so it would also return True for messages that just haven't been delivered yet. But now I can add this to the tutorial code:
And Eileen will say "Yep!" to both questions if you read "TPS Reports" and then deleted it. So, that's a step towards solving one of my problems! I'm still struggling to find a way to deliver new messages based on what's been read and/or deleted without requiring the player to exit the mailbox screen first, but if I figure anything out that might be helpful to other people, I'll post that as well.
Code: Select all
def delcheck(subject):
for item in mail:
if item.subject == subject:
if item.view:
return False
else:
return True
Code: Select all
e "Did you read the first Test Message?"
if check("TPS Reports"):
e "Yep!"
else:
e "Nope!"
e "Did you also delete it?"
if delcheck("TPS Reports"):
e "Yep!"
else:
e "Nope!"
Re: Basic Message System
is there a way to check if an email can be reply ?
Who is online
Users browsing this forum: Google [Bot]