Re: Email System (Beta)
Posted: Thu Jan 29, 2015 11:01 am
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
For information and discussion about Oolite.
https://bb.oolite.space/
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
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?
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?
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;
}
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);
}
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"
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"}}
});
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.
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.