Code: Select all
if current_message and current_message.reply_label:
textbutton "Reply" action current_message.reply
else:
textbutton "Reply" action None
Code: Select all
if current_message and current_message.reply_label:
textbutton "Reply" action current_message.reply
else:
textbutton "Reply" action None
Is there a way to change just the frame of the background to an image? Just the frame to an image.saguaro wrote: ↑Fri Feb 08, 2013 5:12 pm This is a basic in-game message system that uses screens and a little Python. It tracks the read status of messages and includes "mark all read", delete, and restore functions. It also has reply and draft features that use Ren'Py's built-in menus.
Updates:
05/20/14 v 1.2
- Added a simple draft feature that allows player to send messages to names on a contact list (same setup as replies)
- Incorporated message delay based on xavimat's contributions
- Refactored code and put updated choice screen in messages.rpy
screenshot0005.png screenshot0006.png
Include the following after your start label:The syntax for adding messages is add_message(subject line, sender name, message body). Include these anywhere in the script after the mail list is defined.Code: Select all
label start: $ mail = [] $ mail_queue = [] # for message delay $ contacts = [] # for draft feature
Delayed messages can be delivered like so:Code: Select all
$ add_message("Welcome to Ren'Py!", "Eileen", "This is a test message.") $ add_message("Delayed message test", "Eileen", "This is a delayed message.", delay=True)
Check to see if messages have been read based on the message title:Code: Select all
$ deliver_next() $ deliver_all()
If a message is reply-able, the syntax will be add_message(subject line, sender name, message body, reply_label).Code: Select all
if check("TPS Reports"): e "Yep!" else: e "Nope!"
You will need to create the reply label. The template is:Code: Select all
$ add_message("I'm so mad!", "Fred", "You were mean to me. You better apologize!", "fred_reply")
The player can "draft messages" to people on a contact list. To add people to the list:Code: Select all
label fred_reply(current_message): menu: "I won't apologize, Fred. You smell like old socks and I hate you!": # whatever happens $ current_message.can_reply = False "You're right. I'm sorry, Fred. Let's be friends.": # whatever happens $ current_message.can_reply = False "Don't reply yet.": pass return
The template for drafts is:Code: Select all
$ fredo = Contact("Fred", "fred_draft") # to change the draft message, do something like $ fredo.draft = "fred_draft2" # if you don't want Fred on the list anymore (sorry Fred) $ fredo.delete()
Additional Features:Code: Select all
label fred_draft(contact, message_title="Listen, Fred..."): menu: "You're my very best friend! Let's get tacos!": $ contact.draft_label = None # must include this line for each option $ add_message("Taco Time", "Fred", "Yay tacos!!!") "I don't think we should be friends anymore.": $ contact.draft_label = None $ add_message(":(", "Fred", "WHYYYYYYYYYYYY") "Discard draft.": pass return
* Adding a sound effect when messages are received - by xavimat
* Adding time delay to replies - by xavimat
messages.rpy contains everything you need, including the modified choice screen. script.rpy has a demo. Drop all three scripts into a new project to test it out.
Code: Select all
screen mailbox_commands:
hbox:
if available_drafts:
textbutton "New Draft" action Show("contacts", _layer="scrmenu2") ######## HERE
Code: Select all
screen contacts:
modal True
frame:
style_group "mailbox"
xsize 200
vbox:
label "Contacts"
for name in contacts:
if name.draft_label:
textbutton name.name action [name.draft, Hide("contacts")] ###### HERE
Code: Select all
class Contact(store.object):
def __init__(self, name, draft_label):
self.name = name
self.draft_label = draft_label
self.add_contact()
def add_contact(self):
contacts.append(self)
def draft(self):
global draft_screen
draft_screen = True
renpy.call_in_new_context(self.draft_label,contact=self) ###### HERE
draft_screen = False
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:
Code: Select all
# updated choice screen
screen choice:
if reply_screen or draft_screen:
# this is the menu for message replies and drafts
frame:
style_group "mailbox"
vbox:
label "Ecrire"
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:#boutton choix réponse
action action
style "choice_button" xalign 0.5
text caption text_align 0.5
else:
text caption style "menu_caption"
else:
# this is the default choice menu
window:
style "choice" ####################### # PREVIOUSLY "menu_widow"
xalign 0.5
yalign 0.5
vbox:
style "menu"
xalign 0.5 ####################### # ADDED THIS VALUES
yalign 0.5
yanchor 0.5
spacing gui.choice_spacing ####################### # PREVIOUSLY "spacing 2"
for caption, action, chosen in items:
if action:
button:
action action
style "choice_button" xalign 0.5 ####################### # PREVIOUSLY "menu_choice_button"
text caption style "menu_choice" xalign 0.5
else:
text caption style "menu_caption" xalign 0.5
Users browsing this forum: No registered users