Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Scripts & Tutorials
Reload this Page [Essentials script] Wall Clock

Notices
For all updates, view the main page.

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.



Reply
 
Thread Tools
  #1    
Old August 9th, 2014 (02:34 PM).
FL's Avatar
FL FL is offline
Pokémon Island Creator
 
Join Date: Sep 2010
Gender: Male
Posts: 1,482
I suggest using this script with Unreal time system and How to add more features to the PokeGear

Code:
#===============================================================================
# * Wall Clock - by FL (Credits will be apreciated)
#===============================================================================
#
# This script is for Pokémon Essentials. It's the Wall Clock from
# Ruby/Sapphire/Emerald.
#
#===============================================================================
#
# To this script works, put it above main and put the pictures at 
# Graphics/Pictures (may works with other sizes):
# -  56x24  clockam
# - 256x256 clockfemale
# - 256x256 clockmale
# -  56x24  clockpm
# -  24x100 clockpointerhour
# -  24x100 clockpointerminute
#
# Command for call this script: 
# 'pbWallClock(true)' for boy clock
# 'pbWallClock(false)' for girl clock
# 'pbWallClock($Trainer.gender==0)' for clock of the player gender
# 'pbWallClock($Trainer.gender!=0)' for clock of the opposite of player gender
#
#===============================================================================

class WallClockScene
  def update
    pbUpdateSpriteHash(@sprites)
  end
  
  IMAGEPATH="Graphics/Pictures/"
  
  def pbStartScene(male)
    @sprites={} 
    @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
    @viewport.z=99999
    @sprites["background"]=IconSprite.new(0,0,@viewport)
    @sprites["background"].bitmap=Bitmap.new(Graphics.width,Graphics.height)
    @sprites["background"].bitmap.fill_rect(0,0,
        @sprites["background"].bitmap.width, 
        @sprites["background"].bitmap.height, Color.new(72,176,184))
    @sprites["clock"]=IconSprite.new(0,0,@viewport)
    @sprites["clock"].setBitmap(IMAGEPATH+(male ? "clockmale" : "clockfemale"))
    @sprites["clock"].x=(Graphics.width-@sprites["clock"].bitmap.width)/2
    @sprites["clock"].y=(Graphics.height-@sprites["clock"].bitmap.height)/2
    @sprites["pointerminute"]=IconSprite.new(0,0,@viewport)
    @sprites["pointerminute"].setBitmap(IMAGEPATH+"clockpointerminute")
    @sprites["pointerminute"].x=@sprites["clock"].x+128
    @sprites["pointerminute"].y=@sprites["clock"].y+128
    @sprites["pointerminute"].ox=12
    @sprites["pointerminute"].oy=88
    @sprites["pointerhour"]=IconSprite.new(0,0,@viewport)
    @sprites["pointerhour"].setBitmap(IMAGEPATH+"clockpointerhour")
    @sprites["pointerhour"].x=@sprites["clock"].x+128
    @sprites["pointerhour"].y=@sprites["clock"].y+128
    @sprites["pointerhour"].ox=12
    @sprites["pointerhour"].oy=88
    pbUpdateClock
    pbFadeInAndShow(@sprites) { update }
  end
  
  def pbUpdateClock
    time = pbGetTimeNow
    @sprites["pointerminute"].angle=(-time.min)*6
    @sprites["pointerhour"].angle=(-time.hour%12)*30+(-time.min)/2
    @sprites["pmam"].dispose if @sprites["pmam"]
    @sprites["pmam"]=IconSprite.new(0,0,@viewport)
    @sprites["pmam"].setBitmap(IMAGEPATH+(
        time.hour>=12 ? "clockpm" : "clockam"))
    @sprites["pmam"].x=@sprites["clock"].x+(
        @sprites["clock"].bitmap.width-@sprites["pmam"].bitmap.width)/2
    @sprites["pmam"].y=@sprites["clock"].y+176
  end  

  def pbMain
    secondsForUpdate=5
    loop do
      Graphics.update
      Input.update
      pbUpdateClock if Graphics.frame_count%(
          secondsForUpdate*Graphics.frame_rate)==0
      self.update
      if Input.trigger?(Input::C) || Input.trigger?(Input::B)
        pbSEPlay($data_system.decision_se) 
        break
      end   
    end 
  end

  def pbEndScene
    pbFadeOutAndHide(@sprites) { update }
    pbDisposeSpriteHash(@sprites)
    @viewport.dispose
  end
end

class WallClockScreen
  def initialize(scene)
    @scene=scene
  end

  def pbStartScreen(male)
    @scene.pbStartScene(male)
    @scene.pbMain
    @scene.pbEndScene
  end
end

def pbWallClock(male=true)
  pbFadeOutIn(99999) {
    scene=WallClockScene.new
    screen=WallClockScreen.new(scene)
    screen.pbStartScreen(male)
  }
end
Attached Thumbnails
clockscreen.png‎  
Attached Files
File Type: zip sampleresources.zip‎ (8.8 KB, 50 views) (Save to Dropbox)
__________________
Reply With Quote
  #2    
Old August 10th, 2014 (04:34 PM).
Radical Raptr's Avatar
Radical Raptr Radical Raptr is offline
#BAMFPokemonNerd
 
Join Date: Mar 2011
Location: everywhere
Age: 20
Gender: Male
Nature: Sassy
Posts: 1,116
Send a message via Skype™ to Radical Raptr
You've outdone yourself once again, FL, your scripts are gold. It's long overdue, but finally this one has been done, kudos man!
__________________

~My Deviantart - Litharreon Wiki - Litharreon Game Download~

Reply With Quote
  #3    
Old August 15th, 2014 (02:39 AM).
Richard PT's Avatar
Richard PT Richard PT is offline
 
Join Date: Aug 2014
Gender: Male
Posts: 49
It works perfectly, thanks FL. Can I make a suggestion? Can we have pinball mini games in pokemon essentials? For prizes, we can give random items for the winners. Or making a pinball mini game like ruby and sapphire with random rewards.
Reply With Quote
  #4    
Old August 17th, 2014 (04:44 AM).
FL's Avatar
FL FL is offline
Pokémon Island Creator
 
Join Date: Sep 2010
Gender: Male
Posts: 1,482
Quote originally posted by Saving Raven:
You've outdone yourself once again, FL, your scripts are gold. It's long overdue, but finally this one has been done, kudos man!
This is a very simple scripts that took me around 2 hours. And I spend almost all the time formatting the images, making the right x/y image positions and making the script instructions =)

Quote originally posted by Richard PT:
It works perfectly, thanks FL. Can I make a suggestion? Can we have pinball mini games in pokemon essentials? For prizes, we can give random items for the winners. Or making a pinball mini game like ruby and sapphire with random rewards.
A basic pinball probably takes 10 times the time of doing this script and I don't like making long scripts, specially if I never will use it.

A pinball uses too many physics and making colliders for the entire stage is annoying. Probably is easier to take a color detection, hum. Anyway, I guess that is faster to port a pinball algorithm from another language.
__________________
Reply With Quote
  #5    
Old August 24th, 2014 (06:50 AM). Edited August 24th, 2014 by Lexxilion.
Lexxilion's Avatar
Lexxilion Lexxilion is offline
 
Join Date: Jul 2014
Gender: Male
Nature: Careful
Posts: 46
I have a syntax error with this line:

time.hour>=12"clockpm" : "clockam"))

EDIT: I have triple checked and the actual line is the same as the one in the OP, but it gets messed up here.
Reply With Quote
  #6    
Old August 24th, 2014 (07:56 AM). Edited August 24th, 2014 by mustafa505.
mustafa505's Avatar
mustafa505 mustafa505 is offline
Developer
 
Join Date: Apr 2010
Location: Hoenn Region 4ver
Gender: Male
Nature: Lonely
Posts: 295
Quote originally posted by Lexxilion:
I have a syntax error with this line:

time.hour>=12"clockpm" : "clockam"))

EDIT: I have triple checked and the actual line is the same as the one in the OP, but it gets messed up here.
Same here can you attach a text file? the codes are getting messy everyday, its probably the vBulletin or browser which is eating the codes :D

EDIT
Found a way to copy the script correctly, now in the normal version of the forum, the script codes are eaten by something, so goto thread tools> show printable version> copy script>install>test>done.

Here is proof it works smoothly:

and just in case a attachment of the script:
Attached Files
File Type: txt wall clock.txt‎ (3.9 KB, 12 views) (Save to Dropbox)
__________________
Reply With Quote
  #7    
Old August 24th, 2014 (08:10 AM). Edited August 24th, 2014 by Lexxilion.
Lexxilion's Avatar
Lexxilion Lexxilion is offline
 
Join Date: Jul 2014
Gender: Male
Nature: Careful
Posts: 46
Thanks Mustafa505, appreciate your help a lot =]
Reply With Quote
  #8    
Old August 31st, 2014 (03:17 AM).
Richard PT's Avatar
Richard PT Richard PT is offline
 
Join Date: Aug 2014
Gender: Male
Posts: 49
Hey, guys, i have an error here when i call the script in an event:

Called script:

'pbWallClock(true)' for boy clock
'pbWallClock(false)' for girl clock
'pbWallClock($Trainer.gender==0)' for clock of the player gender
'pbWallClock($Trainer.gender!=0)' for clock of the opposite of player gender

I think somethings here is missing.

And i got this error in this event, when it tried to call this script.



Note: I put this script above main in data script.
And i put the graphics in graphics\pictures.
The only problem is called the script in event.
Reply With Quote
  #9    
Old August 31st, 2014 (09:08 AM).
mej71's Avatar
mej71 mej71 is offline
 
Join Date: Mar 2014
Location: Omnipresence
Gender: Male
Posts: 833
Don't say the whole thing

Code:
pbWallClock(true)
You're calling a method. ' will never be in a method name, symbols are not allowed in method names. Method names will also always start with a lower case letter.
Your next problem is "for boy clock". Comment that out (add a # in front of it. This will leave the text there for your future reference, but prevent the interpreter from trying to read it.)
Reply With Quote
  #10    
Old September 1st, 2014 (06:19 AM). Edited September 1st, 2014 by Richard PT.
Richard PT's Avatar
Richard PT Richard PT is offline
 
Join Date: Aug 2014
Gender: Male
Posts: 49
Thanks for your explanation, mej71.

After a few tests in my project, and i figure out what's the problem.
I interpreter all wrong.

It's 4 ways to call the script:

pbWallClock(true) - for boy clock
pbWallClock(false) - for girl clock
pbWallClock($Trainer.gender==0) - for clock of the player gender
pbWallClock($Trainer.gender!=0) - for clock of the opposite of player gender

And now worked perfectly fine.
Reply With Quote
  #11    
Old 1 Week Ago (07:29 AM).
AndromedaKerova AndromedaKerova is offline
 
Join Date: Aug 2015
Gender: Female
Posts: 15
I'm having an issue with this script.

I use a base game that was simply updated to 15.1
No new scripts added beforehand.

This is what I get when I attempt to playtest.


My script is exactly as originally posted but here is the def that includes line 70:
Code:
63  def pbUpdateClock
64    time = pbGetTimeNow
65    @sprites["pointerminute"].angle=(-time.min)*6
66    @sprites["pointerhour"].angle=(-time.hour%12)*30+(-time.min)/2
67    @sprites["pmam"].dispose if @sprites["pmam"]
68    @sprites["pmam"]=IconSprite.new(0,0,@viewport)
69    @sprites["pmam"].setBitmap(IMAGEPATH+(
70        time.hour>=12"clockpm" : "clockam"))
71   @sprites["pmam"].x=@sprites["clock"].x+(
72        @sprites["clock"].bitmap.width-@sprites["pmam"].bitmap.width)/2
73    @sprites["pmam"].y=@sprites["clock"].y+176
74  end
Reply With Quote
  #12    
Old 1 Week Ago (09:21 AM).
FL's Avatar
FL FL is offline
Pokémon Island Creator
 
Join Date: Sep 2010
Gender: Male
Posts: 1,482
Quote originally posted by AndromedaKerova:
I'm having an issue with this script.

I use a base game that was simply updated to 15.1
No new scripts added beforehand.

This is what I get when I attempt to playtest.


My script is exactly as originally posted but here is the def that includes line 70:
Code:
63  def pbUpdateClock
64    time = pbGetTimeNow
65    @sprites["pointerminute"].angle=(-time.min)*6
66    @sprites["pointerhour"].angle=(-time.hour%12)*30+(-time.min)/2
67    @sprites["pmam"].dispose if @sprites["pmam"]
68    @sprites["pmam"]=IconSprite.new(0,0,@viewport)
69    @sprites["pmam"].setBitmap(IMAGEPATH+(
70        time.hour>=12"clockpm" : "clockam"))
71   @sprites["pmam"].x=@sprites["clock"].x+(
72        @sprites["clock"].bitmap.width-@sprites["pmam"].bitmap.width)/2
73    @sprites["pmam"].y=@sprites["clock"].y+176
74  end
PokéCommunity is breaking my codes:

Quote originally posted by mustafa505:
Found a way to copy the script correctly, now in the normal version of the forum, the script codes are eaten by something, so goto thread tools> show printable version> copy script>install>test>done.
__________________
Reply With Quote
  #13    
Old 1 Week Ago (05:35 PM).
AndromedaKerova AndromedaKerova is offline
 
Join Date: Aug 2015
Gender: Female
Posts: 15
I'm sure I copied directly from a printable version but anyhow, I did manage to figure it out. In my way of understanding, that line is asking a question. "if it's 12 then I am either am or pm" I put the question mark in and it worked. :D

Could have copied and pasted again from the printable version but I wanted to see if I could figure out that form of code myself.
Reply With Quote
Reply
Quick Reply

Sponsored Links

You may also like.. (Beta)
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are UTC -8. The time now is 09:58 PM.