Nepkana

Villager
Member
Joined
Aug 12, 2022
Messages
6
Reaction score
1
First Language
english
Primarily Uses
RMMV
Heyo~

I'm new here so please forgive me if do anything wrong.
(Baby's first post)



Context-

I'm making an AM/PM clock in RPGMMV and I been having a really hard time making the AM and PM show up. Because its just a variable ranging from from 1 to 2

1 being: AM

2 being: PM

The clock:

Capture.PNG

Yes I know its a plugin (SRDHud-maker) but~ you can just put straight up JavaScript in it.
(Even says on his website) I already have put JavaScript into it by setting up the clock by
putting this in the text prompt;

2.PNG


What i need help with-

Now this works fine but~ the (player) doesn't know when it's 2:00am or 2:00am Because its just a number. That's where the JavaScript if statement comes in. So I need to convert this below into JavaScript so I can add it on.

3.PNG

or

3.PNG
(Comment is just example in the event)
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,459
Reaction score
3,536
First Language
English
Primarily Uses
RMMV
One obvious answer is to simply use a 24-hour clock. That's pretty universally understood, and requires 0 extra effort on your part.

If you really want to stick to the 12-hour A.M. and P.M., you can put it into a variable where you have your comments. Use the Script event command
Code:
$gameVariables.setValue(X, "text");
where X is the ID of the variable and text is A.M., P.M., whatever.
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
658
Reaction score
368
First Language
German
Primarily Uses
Alternatively, since you are already using javascript, you can use the ? : operator:

($gameVariables.value(10) === 1 ? "AM" : "PM")
 
  • Like
Reactions: Bex

Nepkana

Villager
Member
Joined
Aug 12, 2022
Messages
6
Reaction score
1
First Language
english
Primarily Uses
RMMV
Thanks for the reply

But I did some digging around and found a to display Text instead of number. By redefining the variable as a word then, to keep it working I, made made another variable (Being a 24 hour clock)

So put this in a separate text prompt:

Code:
${$gameVariables.value(13)}

3.PNG
(the "14" is 24hour Clock)


The only problem is now is this makes it needlessly complicated because, I need to do this with other variables. So i have to make 2 variables for 1 variable just into text but~

I will try this out
$gameVariables.setValue(X, "text");

And Thanks again :awink:
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,459
Reaction score
3,536
First Language
English
Primarily Uses
RMMV
You really only need two variables for hours and minutes.

If hours == 12
--hours plus minutes plus "P.M."
Else if hours > 12
-- (hours minus 12) plus minutes plus "P.M."
Else
--hours plus minutes plus "A.M."
 

Nepkana

Villager
Member
Joined
Aug 12, 2022
Messages
6
Reaction score
1
First Language
english
Primarily Uses
RMMV
You really only need two variables for hours and minutes.

If hours == 12
--hours plus minutes plus "P.M."
Else if hours > 12
-- (hours minus 12) plus minutes plus "P.M."
Else
--hours plus minutes plus "A.M."
Yeah Good point.

But I ended up stacking another system on the am and pm variable . For the weather and light cycle meaning, I would have to recode it as well.

I was more worried about the status levels I'm making. Ie

It would say super smart instead of just a boring old 7 in your stat menu.

Because I would have to make two variables, one that's just a "word" and the other one counting your exp and changing the "word."
 

Nepkana

Villager
Member
Joined
Aug 12, 2022
Messages
6
Reaction score
1
First Language
english
Primarily Uses
RMMV
You really only need two variables for hours and minutes.

If hours == 12
--hours plus minutes plus "P.M."
Else if hours > 12
-- (hours minus 12) plus minutes plus "P.M."
Else
--hours plus minutes plus "A.M."
Sorry to bug you again but, I'm still having problems trying to figure out what this means?
(this part)
--hours plus minutes plus "P.M."

Sorry I'm very new to code

(is "hours plus minutes" mean literally adding them together like: var 1 (hours) + var 2 (mins) by a var controller?)

Here is what i got.
2.PNG
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,459
Reaction score
3,536
First Language
English
Primarily Uses
RMMV
(is "hours plus minutes" mean literally adding them together like: var 1 (hours) + var 2 (mins) by a var controller?)
No. It has nothing to do with code. It is exactly what you already said you knew how to do, displaying the number for hours, then the number for minutes, then the text "A.M." or "P.M."

I don't know why you have anything in an event, all of that should be doable directly within the HUDMaker box where you're displaying the time.

I've never used the plugin, but based on what you showed in your first post:
Code:
Time: ${if ($gameVariables.value(10)==12 || $gameVariables.value(10)<12) $gameVariables.value(10).toString().padStart(2, '0') else ($gameVariables.value(10)-12).toString().padStart(2, '0')}:${$gameVariables.value(9).toString().padStart(2, '0')} ${$gameVariables.value(10)>11 ? "P.M." : "A.M."}

Try that.
 
Last edited:

Latest Threads

Latest Profile Posts

So, yeah. It's there.

Clarn Hold
(No storylines)
There was a tutorial on how to draw anime eyes. Just draw Among Us. So I tried.
Screenshot_107.jpg
DamageActor3_7.png added!
index.php

Making a "characters first appearance" drawing for my game. Now I just have to finish the sprite art animation for her grand entrance.​

Forum statistics

Threads
125,540
Messages
1,171,821
Members
164,614
Latest member
guymelul
Top