• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll here!
  • Red, Hilda, Paxton, or Kellyn - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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

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:
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...
 
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:
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 :)
 
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
 
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:
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
 
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:
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

  • [PokeCommunity.com] Time and Date on the Screen
    test.png
    35.1 KB · Views: 43
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.
 
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.
 
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.
 
Back
Top