• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Time and Date on the Screen

295
Posts
5
Years
  • Age 28
  • Seen Aug 15, 2022
i added it but i get still the same error, I don't know why...
Oh, has it something to do with unreal time System?

Oh! 'getHour' is a code of Ego13 and this variable you don't call will give you a error. 'Unreal time System' is a difference calculation, it work and don't give a error, just change calculation time.

Ok, if you don't know how to add script when you read my post above, this is a example script you will need add and you can change this if you want:

Code:
    hourreal = pbGetTimeNow.hour
    minreal = pbGetTimeNow.min

    @sprites["newsprite"] = Sprite.new(@viewport)
    @sprites["newsprite"].bitmap = Bitmap.new(Graphics.width, Graphics.height)
    @sprites["newsprite"].bitmap.clear
    
    pbSetSystemFont(@sprites["newsprite"].bitmap)
    textposition = []
    textposition.push([_INTL("{1} - {2} - {3}",Time.now.day.to_i,Time.now.month.to_i,Time.now.year.to_i),5,7,0,Color.new(198,228,61),Color.new(158,180,57)])
    if hourreal >= 10
      if minreal >= 10
        textposition.push([_INTL("{1}:{2}",Time.now.hour.to_i,Time.now.min.to_i),167,7,2,Color.new(246,211,105),Color.new(212,183,96)])
      else 
        textposition.push([_INTL("{1}:0{2}",Time.now.hour.to_i,Time.now.min.to_i),167,7,2,Color.new(246,211,105),Color.new(212,183,96)])
      end
    else
      if minreal >= 10
        textposition.push([_INTL("0{1}:{2}",Time.now.hour.to_i,Time.now.min.to_i),167,7,2,Color.new(246,211,105),Color.new(212,183,96)])
      else
        textposition.push([_INTL("0{1}:0{2}",Time.now.hour.to_i,Time.now.min.to_i),167,7,2,Color.new(246,211,105),Color.new(212,183,96)])
      end
    end
    pbDrawTextPositions(@sprites["newsprite"].bitmap,textposition)
 
Last edited:
31
Posts
6
Years
Oh! 'getHour' is a code of Ego13 and this variable you don't call will give you a error. 'Unreal time System' is a difference calculation, it work and don't give a error, just change calculation time.

Ok, if you don't know how to add script when you read my post above, this is a example script you will need add and you can change this if you want:

Code:
    hourreal = pbGetTimeNow.hour
    minreal = pbGetTimeNow.min

    @sprites["newsprite"] = Sprite.new(@viewport)
    @sprites["newsprite"].bitmap = Bitmap.new(Graphics.width, Graphics.height)
    @sprites["newsprite"].bitmap.clear
    
    pbSetSystemFont(@sprites["newsprite"].bitmap)
    textposition = []
    textposition.push([_INTL("{1} - {2} - {3}",Time.now.day.to_i,Time.now.month.to_i,Time.now.year.to_i),5,7,0,Color.new(198,228,61),Color.new(158,180,57)])
    if hourreal >= 10
      if minreal >= 10
        textposition.push([_INTL("{1}:{2}",Time.now.hour.to_i,Time.now.min.to_i),167,7,2,Color.new(246,211,105),Color.new(212,183,96)])
      else 
        textposition.push([_INTL("{1}:0{2}",Time.now.hour.to_i,Time.now.min.to_i),167,7,2,Color.new(246,211,105),Color.new(212,183,96)])
      end
    else
      if minreal >= 10
        textposition.push([_INTL("0{1}:{2}",Time.now.hour.to_i,Time.now.min.to_i),167,7,2,Color.new(246,211,105),Color.new(212,183,96)])
      else
        textposition.push([_INTL("0{1}:0{2}",Time.now.hour.to_i,Time.now.min.to_i),167,7,2,Color.new(246,211,105),Color.new(212,183,96)])
      end
    end
    pbDrawTextPositions(@sprites["newsprite"].bitmap,textposition)

oh i get this error on this line:
pbDrawTextPositions(@clock["clock"].bitmap,textPositions)hourreal = pbGetTimeNow.hour

it says it has a SyntaxError...
 
295
Posts
5
Years
  • Age 28
  • Seen Aug 15, 2022
oh i get this error on this line:
pbDrawTextPositions(@clock["clock"].bitmap,textPositions)hourreal = pbGetTimeNow.hour

it says it has a SyntaxError...

No, it's wrong code:
Code:
pbDrawTextPositions(@clock["clock"].bitmap,textPositions)
It must do this:
Code:
pbDrawTextPositions(@sprites["clock"].bitmap,textPositions)
And above, you set @sprites["clock"], too.

and why you put
Code:
hourreal = pbGetTimeNow.hour
near pbDrawTextPositions, check again my post and do it like that. If you have a error when you do it, tell me.
 
Last edited:
31
Posts
6
Years
No, it's wrong code:
Code:
pbDrawTextPositions(@clock["clock"].bitmap,textPositions)
It must do this:
Code:
pbDrawTextPositions(@sprites["clock"].bitmap,textPositions)
And above, you set @sprites["clock"], too.

and why you put
Code:
hourreal = pbGetTimeNow.hour
near pbDrawTextPositions, check again my post and do it like that. If you have a error when you do it, tell me.

Oh well, i only copied your script before... but i will change it as soon as i can and tell you what happened. Thanks so far :)
 
31
Posts
6
Years
Yes! Your change isn't compatible and it's wrong.

Okay... Now i get an error on this line:

@sprites["newsprite"] = Sprite.new(@viewport)

Errorcode:

Script 'ModularMenu' line 18: NoMethodError occured.

undefinied method `[]=' for nil:NilClass
 
295
Posts
5
Years
  • Age 28
  • Seen Aug 15, 2022
Okay... Now i get an error on this line:

@sprites["newsprite"] = Sprite.new(@viewport)

Errorcode:

Script 'ModularMenu' line 18: NoMethodError occured.

undefinied method `[]=' for nil:NilClass

where you put my code? I don't know you use what version. If you use v17.x and use modular Menu, the script of Luka S.J., you put my code after this line
"@sprites["scroll"].end_y = (Graphics.height - 204)/2"
Ok, now try it.
 
Last edited:
31
Posts
6
Years
where you put my code? I don't know you use what version. If you use v17.x and use modular Menu, the script of Luka S.J., you put my code after this line
"@sprites["scroll"].end_y = (Graphics.height - 204)/2"
Ok, now try it.

oh my god it is working!!! Only issue is that it shows the real time, not the unreal time but i am sooo glad it is working at leat :) Thank you very much :)
If you have a solution fort this too i would be glad too. But thank you very much for helping.me
 
295
Posts
5
Years
  • Age 28
  • Seen Aug 15, 2022
oh my god it is working!!! Only issue is that it shows the real time, not the unreal time but i am sooo glad it is working at leat :) Thank you very much :)
If you have a solution fort this too i would be glad too. But thank you very much for helping.me

For unreal time, it just change some conditions but I think if you don't know how to work, maybe, you don't use unreal time or you don't use my code.
 
Last edited:
31
Posts
6
Years
You're welcome

Hey, i could Change it so it would Show the unrealtime and the day of the week.
I just had to Change all Time.now to pbGetTime.now

i am fully happy now :)

I put a Picture so you can see :)
 

Attachments

  • test.png
    test.png
    35.1 KB · Views: 41
295
Posts
5
Years
  • Age 28
  • Seen Aug 15, 2022
Hey, i could Change it so it would Show the unrealtime and the day of the week.
I just had to Change all Time.now to pbGetTime.now

i am fully happy now :)

I put a Picture so you can see :)

It's very nice.
 
24
Posts
5
Years
  • Age 30
  • Seen Jul 24, 2023
To anyone seeing/using this thread in the future: in Kairyla's last post about changing Time.now to pbGetTime.now, I couldn't get it to work until I changed all instances of Time.now to pbGetTimenow - without the period in between Time and now. Thanks Kairyla and bo4p for having this conversation in the first place, it was a huge help to me.

I also put an image behind the time shown on the start menu, and added a Morning/Day/Night notifier. I'd be happy to post my code for that if anyone is interested in it.
 
1
Posts
3
Years
  • Age 31
  • Seen May 28, 2020
Hey. I know this is from a long time ago, but I just started getting into Essentials now. Would you be able to post that finished code? I am having trouble trying to follow the above conversation and where to put it into the Modular Menu Script.
 
232
Posts
7
Years
  • Age 28
  • Seen yesterday
where you put my code? I don't know you use what version. If you use v17.x and use modular Menu, the script of Luka S.J., you put my code after this line
"@sprites["scroll"].end_y = (Graphics.height - 204)/2"
Ok, now try it.

Could you support the v18's modular menu? please ... I would like that very much
 
Back
Top