A fun little date to message script.

I searched for this tutorial and I couldn't find it, so I'm posting it myself. This isn't really that advanced and it's not a plugin, but it's a fun thing for your game. I was reminded earlier last night that we aren't supposed to grave dig old threads anyway, so here is the same thing that's probably already been posted before (maybe not, idk. did I beat you to it?) in fresh thread for your safe commenting.


It's been posted before that you can call the text box by script with $gameMessage.add(); I just learned this, this morning working on a game.


This is what I used it for.


One thing about javascript is that it can read the client side system clock. This is a well known fact from web design. So here's an example of the time and date with your message.


whattime.gif



PHP:
var d = new Date();
var h = d.getHours();
var p = h < 12 ? "AM" : "PM";
if(p==="PM") h-=12;
if(h===0)h=12;
var m = d.getMinutes();
if(m<10) m = "0"+m;
var mo = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][d.getMonth()];
$gameMessage.add("What time is it?\\!\nThe time is "+h+":"+m+" "+p+", and the date is "+mo+" "+d.getDate()+" "+d.getFullYear()+", LOL!");


Called by event script, also the escaped slash bang is an MV enter pause; the slash n is a new line. Basic, but fun stuff.
That is pretty neat...
"Bang" refers to the exclamation point?
@Tigersong a "!" is a bang, correct.

I don't know where I picked up calling it that either. I think it's script speak, but it could also be Twitter lingo. I can't remember.

Original thread: https://forums.rpgmakerweb.com/threads/a-fun-little-date-to-message-script.73877/