Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Sign in to follow this  
Crym

Cryms Date/Time system flop

  

5 members have voted

  1. 1. Do I have what it takes to be a scripter?

    • Yes
      1
    • Maybe
      1
    • With some work and dedication
      1
    • Everyone has what it takes
      2


Question

Okay as I'm sure many of you know I've been learning to script, so far so good. I've encountered a problem with a new script I started recently displaying a specific entry stored in an array, for now it shows all entries at once. I'm only trying to have it draw the text at a single index after a set amount of time.

 

Other problems that I'll tackle later will be increasing the day by one when you stay at an inn. I've got it so that it will display the "in game pseudo-time" properly and I have my days stored inside an array and then increasing the index by 1 every 24 "hours" to display a different day.

 

This is it so far

 

 

class Window_DateTime < Window_Base

 def initialize
   d1 = "Sunday"
   d2 = "Monday"
   d3 = "Tuesday"
   d4 = "Wednesday"
   d5 = "Thursday"
   d6 = "Friday"
   d7 = "Saturday"
   @day = [d1, d2, d3, d4, d5, d6, d7]
   super (0, 0, 160, 96)
   self.contents = Bitmap.new(width - 32, height - 32)
   refresh
 end

 # refresh method to display time and date
 def refresh
   self.contents.clear
   @time = Graphics.frame_count / Graphics.frame_rate
   @min = @time  / 15 % 60
   @hour = @time  / 15 / 15
   # reset the hour to 0 and increase the index of the array @day
   if @hour == 24
     @day.index ++
     @hour = 0
   end
   text = sprintf("%02d:%02d", @hour, @min)
   self.contents.font.color = normal_color
   self.contents.draw_text(4, 32, 120, 32, text, 2)

   #Here's the problem this is the only way I've been able to display anything
     self.contents.font.color = normal_color
     self.contents.draw_text(4, 0, 120, 32, @day.to_s, 2)
 end
 def update
   super
   if Graphics.frame_count / Graphics.frame_rate != @time
     refresh
   end
 end
end

 

 

It's not much since it's a simple script to show a simple date/time.

Anyone here able to fix this problem please give me guidance.

 

Thanks,

~TheCrym

 

I fixed the problem, so far I did away with the array and replaced it with a simple variable that is initialized at 0 (0 = Sunday)

 

Here's the fixed one so far,

 

class Window_DateTime < Window_Base

 def initialize
   # day0 = "Sunday"
   # day1 = "Monday"
   # day2 = "Tuesday"
   # day3 = "Wednesday"
   # day4 = "Thursday"
   # day5 = "Friday"
   # day6 = "Saturday"
   @day = 0
   super (0, 0, 160, 96)
   self.contents = Bitmap.new(width - 32, height - 32)
   refresh
 end
 # refresh method to display time and date
 def refresh
   self.contents.clear
   @time = Graphics.frame_count / Graphics.frame_rate
   @min = @time  / 15 % 60
   @hour = @time  / 15 / 15
   if @hour == 24
     @day += 1
     @hour = 0
     if @day = 7
       @day = 0
     end
   end
   if @day = 0
     self.contents.font.color = normal_color
     self.contents.draw_text(4, 0, 120, 32, "Sunday", 2)
   elsif @day = 1
     self.contents.font.color = normal_color
     self.contents.draw_text(4, 0, 120, 32, "Monday", 2)
   elsif @day = 2
     self.contents.font.color = normal_color
     self.contents.draw_text(4, 0, 120, 32, "Tuesday", 2)
   elsif @day = 3
     self.contents.font.color = normal_color
     self.contents.draw_text(4, 0, 120, 32, "Wednesday", 2)
   elsif @day = 4
     self.contents.font.color = normal_color
     self.contents.draw_text(4, 0, 120, 32, "Thursday", 2)
   elsif @day = 5
     self.contents.font.color = normal_color
     self.contents.draw_text(4, 0, 120, 32, "Friday", 2)
   elsif @day = 6
     self.contents.font.color = normal_color
     self.contents.draw_text(4, 0, 120, 32, "Saturday", 2)
   end
   text = sprintf("%02d:%02d", @hour, @min)
   self.contents.font.color = normal_color
   self.contents.draw_text(4, 32, 120, 32, text, 2)
 end

 def update
   super
   if Graphics.frame_count / Graphics.frame_rate != @time
     refresh
   end
 end
end

 

 

Anyone interested in helping me figure out how to change the screen tone in this script as well as how in increase the day every time the player stays at an inn? Anyone who can help figure that out will be rewarded with hugs and/or cake.

 

After testing a few times I realized, it's military time. Hopefully someone knows of an easy way to make it display in standard time. Any help will be appreciated with cookies and cake.

Edited by Crym

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Interesting, well seems that after I posted this a large group of spam was posted knocking this topic off the latest posts, just an observation not really upset as I'm aware there aren't as many here who are good at scripting as other things.

 

I'm still working on this without to much success so I'll still be needing any advice as to how to get this done efficiently. I guess I will make a list of features I'm planning to include with this.

 

[DONE] display pseudo-date/time

[DONE] display the time in Standard time instead of military time.

[----] include night/day with lights turning on and off at appropriate times.

[----] display an image (pocket watch) as part of a HUD with moving hands

[----] replace the steps window with the date/time window displaying standard time in digits instead of moving hands

 

Towards my game

[----] set ground work for certain events to only happen at certain days or at certain times

 

Thanks for the input,

~TheCrym

Share this post


Link to post
Share on other sites
  • 0

If you are using variables for the day than every time you stay at an inn have it increase the variable by 1.

Share this post


Link to post
Share on other sites
  • 0

Yeah, I had thought about that I'm now trying to figure out a effective way to do that. Is there a way to reference the inn from the script editor if anyone knows or will I have to do that in a call script in the event?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...