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

Calendar Script

Recommended Posts

I'm trying to find a script that allows me to call a calendar from an aptly named Calendar

item in the inventory. It would be pretty straightforward, 12 months, 31 days per month.

I would also need an ability to modify a label of sorts, so I can add in information such

as holidays / discovered events. Ie. After discovering such and such place, you can track

events that occur there, and when they occur.

 

Anyways, if anyone knows of a calendar system that I could mold/tweak to my uses, it would

be great, but if not, I would love someone to try to script something like it. I will

forever be in your debt, O Wizard of Scriptly Goodness!

 

:focus:

Share this post


Link to post
Share on other sites

It appears I was quite vague on my last attempt. Let me clarify:

 

I am looking for a script, that can display a calendar menu from an item.

Below I have images created in GIMP that show sort of what I'm

looking for. Each month has 31 days, no fussing with what month is

supposed to have 28 days, etc. I would prefer to have a calendar

that I can open the day itself to view events. However, thats

a daunting task.

 

Instead, I would like to have it to where you select the month you

wish to view, and it would show you in list form, what events

are occurring. You'll see in my images. If anyone is interested

in doing this for me, I would greatly appreciate it, and you can

PM me for better details. If however, no one is interested, please

after viewing, post simply "Not interested". It will save me from

having to wait weeks, and bumping to find out no one will help me.

 

 

post-13553-127141438074_thumb.jpg post-13553-127141438233_thumb.jpg

Share this post


Link to post
Share on other sites

Hi totalsticks. If no one is already working on this, I will make an attempt at it. One question, though...

Do you want to pre-define all of these events (in a script) and then just unlock them throughout the game? Or do you want to be able to define them as you go (or even dynamically)?

Share this post


Link to post
Share on other sites

Hi totalsticks. If no one is already working on this, I will make an attempt at it. One question, though...

Do you want to pre-define all of these events (in a script) and then just unlock them throughout the game? Or do you want to be able to define them as you go (or even dynamically)?

 

Well, if you're gonna take a crack at it, all I really need is the calendar itself, but

need the option to set events that will occur once unlocked/discovered. (I'm leaning

towards switches for that)

 

Here's an example:

Soandso visits TownA and talks to someone who notifies them of event, switch# on

and now event is viewable in calendar.

 

I cant really visualize how the script will be, but if you would like some more

detail, feel free to PM me. Thanks for wanting to undertake this task!

 

PS: Oh, are you going to work on the one that shows the month, as opposed to one day

at a time? If so, that would probably make your work a LOT easier.

Share this post


Link to post
Share on other sites

I've finished a first draft of your script. It is the month view. I may be able to do the one day at a time if you created a more detailed mock up that shows the screen with some sample data in it. But for now, here is the calendar script:

 

 

#==============================================================================
# Calendar System for RPG Maker XP
#==============================================================================
#  Original Script by: tacodome
#  Idea and design by: totalsticks
#==============================================================================
# Last Updates:
#
# Version 1.0
#  • Basic ability to add events to a calendar
#  • Ability to view events in a list by month
#  • Turn events on and off using switches
#
#==============================================================================
# License: You may freely use this code in any project (commercial or freeware)
# provided you do not remove this notice and you credit tacodome as the author
# of this script.  While you may sell games that use this script, you may not
# sell this script or derivatives of this script directly.
#==============================================================================

#------------------------------------------------------------------------------
# Calendar_Event
#
# This is just a storage class to store all the attributes of an event together
# in one place.
#------------------------------------------------------------------------------
class Calendar_Event
 attr_accessor :start_day    # The start date of the event (int > month * 32 + day)
 attr_accessor :end_day      # The end date of the event (int >month * 32 + day)
 attr_accessor :town         # The town the event takes place in (string)
 attr_accessor :description  # The description of the event (string)
 attr_accessor :switch_num   # The switch number that is associated with the event (int)

 #---------------------------------------------------------------------------
 # initialize
 # 
 # Initializes a new event.  The arguements are as follows:
 #   - startmonth  = the month of the start date (1 - 12)
 #   - startday    = the day of the start date (1 - 31)
 #   - endmonth    = the month of the end date (1 - 12)
 #   - endday      = the day of the end date (1 - 31)
 #   - town        = the name of the town (string)
 #   - desc        = the description of the event (string)
 #   - switch      = the switch number that activates or deactivates this event (1 - 5000)
 #---------------------------------------------------------------------------
 def initialize(startmonth=1, startday=1, endmonth=1, endday=1, town="", desc="", switch=1)
   @start_day = (startmonth << 5) + startday
   @end_day = (endmonth << 5) + endday
   @town = town
   @description = desc
   @switch_num = switch
 end

 def get_start_month
   return @start_day >> 5
 end

 def get_start_day
   return @start_day & 31
 end

 def get_end_month
   return @end_day >> 5
 end

 def get_end_day
   return @end_day & 31
 end
end

#------------------------------------------------------------------------------
# Game_Calendar
#
# This class stores events for the calendar.
#------------------------------------------------------------------------------
class Game_Calendar
 attr_accessor :event_count  # the number of events in the array
 attr_accessor :events       # an array of Calendar_Event objects
 attr_accessor :month_names  # an array defining the names of the months

 def initialize
   @event_count = 0
   @events = []
   @month_names = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
 end

 def add_event(start_month, start_day, end_month, end_day, town, desc, switch)
   new_event = Calendar_Event.new start_month, start_day, end_month, end_day, town, desc, switch
   @events[@event_count] = new_event
   @event_count += 1
   @events = @events.sort_by { |obj| obj.start_day }
 end
end

class Window_Events < Window_Base
 def initialize
   super(0, 0, 500, 480)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.contents.font.name = "Arial"
   self.contents.font.size = 18

   refresh
 end

 def refresh(month=0)
   self.contents.clear
   if (month > 0)
     month_start = (month << 5) + 1
     month_end = (month << 5) + 31
     self.contents.font.color = system_color
     self.contents.font.size = 24
     self.contents.draw_text(0,0,468,32,$game_party.calendar.month_names[month-1],1)
     self.contents.font.size = 18
     y = 40
     $game_party.calendar.events.each { |ev|
       if ev.start_day <= month_end && ev.end_day >= month_start && $game_switches[ev.switch_num]
         text = sprintf("%s %d", $game_party.calendar.month_names[ev.get_start_month()-1], ev.get_start_day())
         if ev.get_start_month() == ev.get_end_month()
           unless ev.get_start_day() == ev.get_end_day()
             text = sprintf("%s-%d", text, ev.get_end_day())
           end
         else
           text = sprintf("%s-%s %d", text, $game_party.calendar.month_names[ev.get_end_month()-1], ev.get_end_day())
         end
         text = sprintf("%s, %s", text, ev.town)
         self.contents.font.color = system_color
         self.contents.draw_text(0, y, 468, 32, text)
         self.contents.font.color = normal_color
         self.contents.draw_text(0, y+20, 468, 32, ev.description)
         y += 44
       end
     }
   end
 end
end

class Window_MonthSelect < Window_Selectable
 def initialize
   super(0, 0, 140, 480)
   self.contents = Bitmap.new(width - 32, height - 32)
   @item_max = $game_party.calendar.month_names.length + 1
   @column_max = 1
   @commands = Array.new($game_party.calendar.month_names)
   @commands[$game_party.calendar.month_names.length] = "Cancel"
   refresh
   self.index = 0
 end

 def refresh
   self.contents.clear
   for i in 0...@item_max
     draw_item(i)
   end
 end

 def draw_item(index)
   y = index * 32
   self.contents.draw_text(4, y, 128, 32, @commands[index])
 end
end

class Game_Party
 attr_accessor :calendar

 alias :calendar_initialize :initialize

 def initialize
   calendar_initialize
   @calendar = Game_Calendar.new
 end
end

class Scene_Calendar
 def main
   @month_window = Window_MonthSelect.new
   @cal_window = Window_Events.new
   @cal_window.x = 140
   @month_window.active = true
   Graphics.transition
   loop do
     Graphics.update
     Input.update
     update
     if $scene != self
       break
     end
   end
   Graphics.freeze
   @cal_window.dispose
   @month_window.dispose
 end

 def update
   @cal_window.update
   @month_window.update
   if @month_window.active
     update_month
     return
   end
 end

 def update_month
   if Input.trigger?(Input::B)
     $game_system.se_play($data_system.cancel_se)
     close_calendar
     return
   end
   if Input.trigger?(Input::C)
     $game_system.se_play($data_system.decision_se)
     if (@month_window.index < $game_party.calendar.month_names.length)
       @cal_window.refresh(@month_window.index + 1)
     else
       close_calendar
     end
     return
   end
 end

 def close_calendar
   $scene = Scene_Map.new
 end
end

#############################################################################
#  USAGE NOTES:
#----------------------------------------------------------------------------
# $game_party has a new attribute called calendar.
# ex:
# num_events = $game_party.calendar.event_count
#
# To Add an event on March 15 for town "Louisville" that is controlled by
# switch # 41, do the following:
#
# $game_party.calendar.add_event(3, 15, 3, 15, "Louisville", "Beware the ides of March", 41)
#
# To add an event that runs from April 1 to April 6 on switch 5000, do:
#
# $game_party.calendar.add_event(4, 1, 4, 6, "My Town", "An event", 5000)
#
# To activate the calendar display, just do:
# $scene = Scene_Calendar.new
# 
# Right now, the game returns to the map when the calendar is closed.  To change
# this, just change the last function of this script (close_calendar) to go
# to your menu or whatever scene instead of Scene_Map.
##############################################################################

post-13202-127179468379_thumb.png

Share this post


Link to post
Share on other sites

Awesome! I'm still giving it some testing out, but it looks exactly how I wanted it.

The day at a time will not be necessary, AND you've made it so I dont have to use

switches! If you werent a guy, I'd make sweet, sweet binary love to you. :drool:

 

Well, I'm gonna get to testing it, see how it fares. I'll post a list of things

that I notice are buggy, etc. Again, thanks mate!

Share this post


Link to post
Share on other sites

Mmmkay.. noticed just one problem.

Everything worked on the first run-through.

 

But, once you try to call the event again, it shows

multiple "Cancel" selectables, and you cant use those

to cancel anymore, have to scroll down past to a blank

selectable to cancel.

 

Any way to get rid of the cancel altogether? I think

people will have to suffer through having to push

the cancel button instead of selecting it. :)

Share this post


Link to post
Share on other sites

Hi,

I fixed that error. Sorry about that. I meant to copy the contents of an array, instead I was copying the reference to it. That was what was messing everything up. You won't get duplicate Cancel options now and the Cancel option works as expected.

Share this post


Link to post
Share on other sites

yow......

Mmm, sorry... can i ask you something?

 

Can we used this script like Date time system in Persona?

Share this post


Link to post
Share on other sites

this is a amazing idea is this for vx or xp?

 

:edit nvm but does anyone know of a vx script like this one?

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