Good idea but I suggest to do not delete just put into an expired folder.Wildeblood wrote:I want an "expires" property on the email object
Email System (Release)
Moderators: winston, another_commander
- Norby
- ---- E L I T E ----
- Posts: 2577
- Joined: Mon May 20, 2013 9:53 pm
- Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
- Contact:
Re: Email System (Beta)
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Email System (Beta)
Just thinking about the expiry data idea, I can see there are a couple of options for what to do with the email when it expires: delete it, move it, or how about this: when the email expires, the content of the email is hidden (replaced with "This email has expired" or some user supplied text), and any response options are also hidden? What do you think?
- Diziet Sma
- ---- E L I T E ----
- Posts: 6312
- Joined: Mon Apr 06, 2009 12:20 pm
- Location: Aboard the Pitviper S.E. "Blackwidow"
Re: Email System (Beta)
Treat it the way Gmail handles spam, perhaps? After xx days in the 'junk' folder, it's auto-deleted.
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Email System (Beta)
My preference for the user experience, ignoring difficulty of implementation, would be to display the expires field if it exists and have an option, "save this email", to delete that. However, I cannot over-emphasize there's no need to implement any functionality yet, just ensure an email object with an expires property won't be rejected by the createEmail function as malformed.phkb wrote:Just thinking about the expiry data idea, I can see there are a couple of options for what to do with the email when it expires: delete it, move it, or how about this: when the email expires, the content of the email is hidden (replaced with "This email has expired" or some user supplied text), and any response options are also hidden? What do you think?
The most important thing to work on, IMHO, is properly storing and validating those callback functions. Telling OXP authors that their script has to re-establish those links on every start-up just won't fly. It's too complicated. It won't be people like me who couldn't be bothered using such a feature that cause you grief, it will be the enthusiastic, well-intentioned, but can't-follow-instructions people who come whinging.
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Email System (Beta)
OK, I think I've figured out a way to store a function and recall it from saved data. This might be obvious but do you think I should allow for parameters in the callback function, or just leave it as a parameter-less function call?
Re: Email System (Beta)
I think the most forward flexibility would come from making the callback function take a single parameter, which is an object. You can then add extra keys to that object as needed without requiring OXPs to count them, do anything with them, etc.phkb wrote:OK, I think I've figured out a way to store a function and recall it from saved data. This might be obvious but do you think I should allow for parameters in the callback function, or just leave it as a parameter-less function call?
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Email System (Beta)
This is what is concerning me...
None of that should be necessary.
Put the introductory message into this._emails where you first define it.
And just do this to save and reload the whole database:
Code: Select all
this._emails = [];
Code: Select all
this.startUp = function() {
this._hudHidden = false;
this.$restoreSavedData();
}
Code: Select all
this.startUpComplete = function() {
var p = player.ship;
if (missionVariables.EmailSystem_Welcome != "yes") {
this.$createEmail({sender:"MailNET",
subject:"Welcome to your inbox!",
sentDate:global.clock.seconds - 100,
emailBody:"MailNET is proud to welcome you to your new inbox..."});
var p = player.ship;
missionVariables.EmailSystem_Welcome = "yes";
}
if(p && p.isValid) {
this.$initInterface(system.mainStation);
this.$initInterface(p.dockedStation);
}
}
Code: Select all
this.$restoreSavedData = function() {
var iTotal = 0;
iTotal = missionVariables.EmailSystem_TotalEmails;
if (iTotal != null || iTotal > 0) {
for (var i = 0; i < iTotal; i++) {
var msg = new EmailMsg;
msg.ReadData(missionVariables["EmailSystem_Email" + (i + 1).toString()]);
this._emails.push(msg);
}
}
if (this._emails) this._maxEmails = this._emails.length;
}
Code: Select all
this.playerWillSaveGame = function() {
missionVariables.EmailSystem_TotalEmails = this._emails.length;
for (var i = 0; i < this._emails.length; i++) {
missionVariables["EmailSystem_Email" + (i + 1).toString()] = this._emails[i].StoreData();
}
if (this._emails.length < this._maxEmails) {
// clear out any old emails
for (var i = this._emails.length; i < this._maxEmails; i++) {
missionVariables["EmailSystem_Email" + (i + 1).toString()] = "";
}
}
this._max_Emails = this._emails.length;
}
Put the introductory message into this._emails where you first define it.
Code: Select all
this._emails = [{sender:"MailNET",
subject:"Welcome to your inbox!",
sentDate:global.clock.seconds - 100,
emailBody:"MailNET is proud to welcome you to your new inbox..."}
];
Code: Select all
this.startUpComplete = function() {
if (missionVariables.EmailSystem_emails) {
this._emails = JSON.parse(missionVariables.EmailSystem_emails);
}
if(player.ship.docked) {
this.$initInterface(player.ship.dockedStation);
}
}
Code: Select all
this.playerWillSaveGame = function () {
missionVariables.EmailSystem_emails = JSON.stringify(this._emails);
}
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Email System (Beta)
The problem I had with the JSON.parse was that I'm storing a specific local object type, "EmailMsg" into the array of emails. I'm using this local object to provide additional functions related to individual emails (things like "InboxDisplay", which returns a formatted line for the inbox). When JSON.parse puts the data back into the array, they go in as a general object, without the additional functions.
Anyway, I'm moving to the code you suggested, but it wasn't quite as simple as the JSON functions lead me to believe.
Anyway, I'm moving to the code you suggested, but it wasn't quite as simple as the JSON functions lead me to believe.
- Norby
- ---- E L I T E ----
- Posts: 2577
- Joined: Mon May 20, 2013 9:53 pm
- Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
- Contact:
Re: Email System (Beta)
I would like to read the content after expired, so just put this expired message into the begin of the email. The response options can be replaced by a single "Send a late response" which mean that was not interested before but would like to get a similar thing next time.phkb wrote:"This email has expired"
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Email System (Beta)
There's lot of ways the expiry option can be implemented, and I'm not sure which ones will stick. Here's what I'm doing at the moment:
Added the following properties:
expiryDate : sets the expiry date to a specific time (in seconds)
expiryDays : set expiry date number of days in future
expiryHours : set expiry date number of hours in future
expiryMinutes : set expiry date number of minutes in future.
expirySeconds : set expiry date number of seconds in future
expiryText : text to display in header after email expires
If you just set the expiry date, the email will be deleted after the expiry date passes. If you supply the expiryText, the email stays but with the text in the header. I'm still uncertain what to do with any response options after the expiry date passes. Hide them, display them anyway. I'm leaning toward displaying them, and leaving it up to oxp authors to work out that the player responded after the expiry date.
You can combine the days, hours, minutes and seconds properties. So if you want the email to expire in 2 minutes and30 seconds, use expiryMinutes:2, expirySeconds :30.
Added the following properties:
expiryDate : sets the expiry date to a specific time (in seconds)
expiryDays : set expiry date number of days in future
expiryHours : set expiry date number of hours in future
expiryMinutes : set expiry date number of minutes in future.
expirySeconds : set expiry date number of seconds in future
expiryText : text to display in header after email expires
If you just set the expiry date, the email will be deleted after the expiry date passes. If you supply the expiryText, the email stays but with the text in the header. I'm still uncertain what to do with any response options after the expiry date passes. Hide them, display them anyway. I'm leaning toward displaying them, and leaving it up to oxp authors to work out that the player responded after the expiry date.
You can combine the days, hours, minutes and seconds properties. So if you want the email to expire in 2 minutes and30 seconds, use expiryMinutes:2, expirySeconds :30.
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Email System (Beta)
I've almost finished the next version. Quick one for those who have downloaded this (and there are only 6 of you, according to the stats on box.com): the saved data methodology for all the emails has changed, which means when you install the next version you will loose any saved emails. I'm happy to put in conversion code, but as there are so few of you, and at the moment the possible emails you would have are just of the confirmation type, I'm thinking it's not critical, and it keeps the code cleaner not to have to look at the old way of doing things.
More on the expiry functionality:
The "allowExpiryCancel" option allows you to control whether the the player will have the option of stopping an email from expiring.
The "expiryOptions" gives you the opportunity to add response options that will only be available if the email expires.
I think with those options the system is pretty flexible: you can create an email that will expire and be deleted, or just switch over to an expired state, with options that are only available when expired.
Here's an example of what it looks like now:In this example, the email will expire in 2:30 minutes, the player won't have the option to cancel the expiry, and option 3 only becomes available when the email expires.
Another question: do you think "Logs" is the place to put this functionality? Does it make more sense in "Ship Systems"? Open to suggestions here.
More on the expiry functionality:
The "allowExpiryCancel" option allows you to control whether the the player will have the option of stopping an email from expiring.
The "expiryOptions" gives you the opportunity to add response options that will only be available if the email expires.
I think with those options the system is pretty flexible: you can create an email that will expire and be deleted, or just switch over to an expired state, with options that are only available when expired.
Here's an example of what it looks like now:
Code: Select all
w = worldScripts.EmailSystem;
w.$createEmail(
{sender:"The Chaser", // senders name or email address
subject:"Something for you do look at...", // subject line
sentDate:global.clock.seconds, // the time the email was sent
emailBody:"Would you like to play a game?", // body text of the email
expiryMinutes:2,
expirySeconds:30,
allowExpiryCancel:false,
expiryText:"This email has expired",
expiryOptions:"3",
responseOption1:{displayText:"Yes", replyText:"Sure. Why not?", worldScriptsName:"EmailSystemDemo", callbackFunction:"$AcceptChallenge", functionParam:"mydata"},
responseOption2:{displayText:"No", replyText:"Sorry. Too busy right now.", worldScriptsName:"EmailSystemDemo", callbackFunction:"$DeclineChallenge"}
responseOption3:{displayText:"Too late", replyText:"Sorry I didn't respond to your email in time. Can I still join in?", worldScriptsName:"EmailSystemDemo", callbackFunction:"$TooLate"}}
});
Another question: do you think "Logs" is the place to put this functionality? Does it make more sense in "Ship Systems"? Open to suggestions here.
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Email System (Beta)
Yes, no. Not a ship system since it's only available at stations. (Although, if you went back to the purchased equipment, I wouldn't stand by that assertion.)phkb wrote:Another question: do you think "Logs" is the place to put this functionality? Does it make more sense in "Ship Systems"? Open to suggestions here.
- Norby
- ---- E L I T E ----
- Posts: 2577
- Joined: Mon May 20, 2013 9:53 pm
- Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
- Contact:
Re: Email System (Beta)
Category names in Interfaces are flexible, there are no strict rules here. I think "Activity" is better than "Logs" due to todo will be here, but a brand new category is good also.
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Email System (Beta)
Version 1.1.0 has been uploaded, link is in the first post. As previously noted, if you have the old version, and install this one, any email history will be lost as a new save methodology is in place. Gone also is the need to reconnect emails to their originating worldScript. Now you can pass the worldscript name and function name, and the email system will store this and call the correct procedure when executed.
New in this version is the expiry system, details as noted in previous posts.
As always, feedback is most welcome.
New in this version is the expiry system, details as noted in previous posts.
As always, feedback is most welcome.
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Email System (Beta)
Updated version now available at same link.Wildeblood wrote:I made this version of my Autotrade Report Screen plug-in so Autotrade can send you email reports of its activities.
Last edited by Wildeblood on Sun Feb 08, 2015 4:43 pm, edited 1 time in total.