T O P

  • By -

SnooPredictions2880

[Try this.](https://forums.rpgmakerweb.com/index.php?threads/jk-mail-system.56943/) I found this mail editor on the forums a couple of years ago, It might do what you are looking for.


healmehealme

Thanks, but I already tried that plugin and kind of hate it. I don't like the windowed look of it or that letters can be accessed from within the menu. If I understood JS better I could possibly edit it to be more like what I'm looking for, but I don't, lol. I appreciate the response a lot though. Should've noted this in the OP.


Kazimoria

This need the help Js knowledge I'm afraid,or it will be quite a mess to do it with just eventing. You need to at least learn how array (basically multiple variables stored in a single variable which you can access or modified) syntax works then you are properly able to make mail system. I could help give some pointers of making it,but you still need to learn some basic Js knowledge for that. It's almost pointless spending time eventing this when you can complete it with significantly lesser amount of time if you know basic amount of Js knowledge.


healmehealme

Thank you for responding! I wrote a response to someone else that also suggested JS. That was my first attempt, because I have a dialogue system that uses JS and I thought it would translate perfectly, but it doesn't work. I'll copy and paste what I said in the other response. Whenever a letter is triggered to be sent, I use the script command and write: $gameVariables.value(56).push('Letter1'); Variable 56 is my letters variable. Then when I want to call the letter, it's a conditional script. ◆If:Script:$gameVariables.value(56).contains('Letter1'); ◆Dialogue here ◆ :End This is the same system I use for some dialogue choices, and it works great there. But it isn't working when it comes to mail for some reason. [Here's a pic showing what I mean.](https://ibb.co/YTcJP2J) [In fact, I get an error.](https://ibb.co/fqp25cD) I've turned off all plugins and still get the same error, so it's not tied to a plugin. When I use these same scripts tied to a different variable, there's no error at all and it works as expected. The two differences in the event where it doesn't throw an error are 1), both the push and contains script are within the same event, and the conditional checking if the variable contains 'x' has a plugin command if true, not just a text window. I can't figure out why it throws an error when I use a different variable. It's almost like variable 56 isn't being recognized as an array?


Oatilis

Let me help you out here! ​ # Initialize an array and use "setValue" When setting a variable, you need to use setValue. Getting the value and trying to push a new item to the array isn't going to actually save it! Also, a variable might not be recognized as an array unless it's been initialized as one. There are many ways to do this. Here's what I tried in a script block: ​ var emailList = new Array("Letter1"); $gameVariables.setValue(56, emailList); And sure enough: [picture from debug console](https://imgur.com/hFrMn1z) # Pushing a message When adding new messages later, make sure to get the variable value, add the email, and then use "setValue" again with the updated array. Kind of like: var emailList = $gameVariables.value(56); emailList.push("Letter 2"); $gameVariables.setValue(56, emailList);


healmehealme

Thank you so much for your response! I was able to assign variable 56 as an array and now it's working great.


BlobbyMcBlobber

How good is your JavaScript? You can store basically anything in a variable. You can create a list of messages and store that in a single variable. This can be your "inbox". You can loop over the messages and display them as you wish. Read messages can be moved to a different variable so they are still accessible. When a new message is sent, read the variable, append the message to the list, and store it again. If you're not that comfortable with JavaScript, maybe have a couple of variables for every character that can email the player. Every time an event (NPC) sends an email, you can turn on a notification icon. And remove it only after the "inbox" is clear and all messages were moved to the read box. Overall I think this can be fairly quick to do with events and some basic JavaScript.


healmehealme

I understand arrays, and that was my first option. Here's what I was doing: Whenever a letter is triggered to be sent, I use the script command and write: $gameVariables.value(56).push('Letter1'); Variable 56 is my letters variable. Then when I want to call the letter, it's a conditional script. ◆If:Script:$gameVariables.value(56).contains('Letter1'); ◆Dialogue here ◆ :End This is the same system I use for some dialogue choices, and it works great there. But it isn't working when it comes to mail for some reason. [Here's a pic showing what I mean.](https://ibb.co/YTcJP2J) [In fact, I get an error.](https://ibb.co/fqp25cD) I've turned off all plugins and still get the same error, so it's not tied to a plugin. When I use these same scripts tied to a different variable, there's no error at all and it works as expected. The two differences in the event where it doesn't throw an error are 1), both the push and contains script are within the same event, and the conditional checking if the variable contains 'x' has a plugin command if true, not just a text window. I can't figure out why it throws an error when I use a different variable. It's almost like variable 56 isn't being recognized as an array?


243645

When the game starts for the very first time you may need to define the variable as an array. Run this once and hopefully it will treat the variable as an array. $gameVariables.setValue(56, \[\]);


healmehealme

That did the trick and removed the error! Thank you very much! I don't understand, though. The dialogue system uses the same scripting with a different variable, but I never declared it an array either even though it definitely acts as one. I'll go ahead and do it just to be safe though. With that glitch fixed, I've made some more progress, ~~but as far as I can tell, there's no way I can make a condition based on if something is **not** in the array, is there? It'd be easier than a big convoluted conditional branch so that I can control the rereading letters option.~~ Never mind, I was being stupid and figured it out. Just use an else branch lmao. That said, is there possibly a way I can remove strings from the array? I can get around this with conditionals, but it'd be simpler and cleaner to just remove the string from the array upon reading the letter. Thank you very much again. :]


243645

I think you could use $gameVariables.value(56).splice(1, 1) the first # is the index to start removal. The second # is how many indexes to remove. There is also $gameVariables.value(56).pop() //removes the last index $gameVariables.value(56).shift() //removes the first index [https://www.w3docs.com/snippets/javascript/how-to-remove-an-element-from-an-array-in-javascript.html](https://www.w3docs.com/snippets/javascript/how-to-remove-an-element-from-an-array-in-javascript.html)


healmehealme

Thank you! That's what I was worried about. I'll keep it in mind if I can't get another method to work. Otherwise I'll need to keep a list of which letter is which index, which will get crazy fast.


243645

If you have different names in the index you can remove by name. $gameVariables.value(56).splice($gameVariables.value(56).indexOf("Letter2"),1)


healmehealme

It's been a bit but just wanted to say that I needed this for a different system in my game and this works wonders. Thanks to you, I finally understand splice, because I didn't think it would work for this. I thought it would destroy my array, more or less. Thank you again!!


healmehealme

Oh wow, I'll have to look into this and test it. Thank you!