Author Topic: TUTORIAL: Moon Phases  (Read 47 times)

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9718
TUTORIAL: Moon Phases
« on: May 25, 2017, 04:53:02 PM »
Advanced Tutorial: Using Logic Block to Calculate the Phase of the Moon

This tutorial will assume that we are tracking the phases of a moon that is much like our own, that completes its cycle in 28 days. This task will require 4 quests to track the phases of the moon and each will track the moon for one week, counting the full and new moons as phases, not just moments. This tutorial can easily be adapted to track a different length moon cycle and even the addition of one or more moons in addition to the one already being tracked.

   1)   To track the phases of the moon we will use four quests, one for each phase of the moon. In the Special Items, Keys and Quests Editor, create 4 appropriately named quests so that you can easily remember what they do - moon_full, moon_waning, moon_new, and moon_waxing are used in this tutorial.
   2)   For this tutorial, we will create an observatory where the player can go to find out what phase the moon is in. If you wanted you could use appropriate pictures or tie it to a Shop or Combat event, but I will use text in a Text Statement event. Choose a square on the map where you would like to place your Logic Block event and the Text Statement events that will represent the Observatory.

   3)   For this use of the Logic Block, we are only interested in the "First Action" box. Since we are not using the other parts of the Logic Block to calculate anything, set the occurence to "Always".
   4)   From the dropdown menu, choose "GPDL Function" so that we can enter a script to compute the moon phase.
   5)   Select the button with the elipses (...) to open the Script Editor.

   6)   The moon phase script makes use of two functions: $GET_PARTY_DAYS and $SET_QUEST.
   7)   In the first part of the script, establish the variables - sue two, one to represent the day of the month and one to represent the phase of the moon.
   8)   The second part of the script are the functions to determine the phase of the moon.
   9)   The full script used in this event is below.
Code: [Select]
$VAR day;
$VAR phase;
day = $GET_PARTY_DAYS() %# 28;
phase = day /# 7;
$SET_QUEST("moon_full", (phase ==# 0) *# 2);
$SET_QUEST("moon_waning", (phase ==# 1) *# 2);
$SET_QUEST("moon_new", (phase ==# 2) *# 2);
$SET_QUEST("moon_waxing", (phase ==# 3) *# 2);

   10)   Notifying the player of the current phase of the moon requires four Text Statement events chained underneath the Logic Block event. The first Text Statment goes in the Normal Chain slot of the Logic Block event. The three subsequent Text Statement events go in the Normal Chain slot of the previously placed event.
   11)   Each event must have it's Event Trigger set to "Quest in Progress". When the events are placed the quests can be chosen - each of the four events uses one of the four quests created earlier, so that one event uses "moon_full", one uses "moon_waning", one uses "moon_new", and one uses "moon_waxing".

Some ideas to consider:
   -this tutorial could easily be adapted to track the seasons of the year
   -the number of the year could be tracked
   -the day of the week could be tracked