Mys 1.3.6 Time Season & Calendar Changes Mod

Forum
Last Post
Threads / Messages

GeneticAlpha

Loving Mysidia!
Member
Joined
May 24, 2020
Messages
283
Points
18
Age
30
Location
Tennessee
Mysidian Dollar
13,356
Seasons Display works with 1.3.6

So I wanted to have a little season icon and text that would change based on the calendar, so I managed to get this working in the sidebar.

$today = new DateTime();
if(new DateTime() < new DateTime($today->format('Y').'-3-20 00:00:00')) $season = "Winter <img src='IMAGE HERE'>";
else if (new DateTime() < new DateTime($today->format('Y').'-6-21 00:00:00')) $season = "Spring <img src='IMAGE HERE'>";
else if (new DateTime() < new DateTime($today->format('Y').'-9-22 00:00:00')) $season = "Summer <img src='IMAGE HERE'>";
else if (new DateTime() < new DateTime($today->format('Y').'-12-20 00:00:00')) $season = "Fall <img src='IMAGE HERE'>";
else $season = "Winter <img src='IMAGE HERE'>";
$this->moneyBar->add(new Comment("<<b>{$season}</b>"));

I pasted this into the protected function setMoneyBar area of class_sidebar.php file. So my code looks like this:

protected function setMoneyBar(){
$mysidia = Registry::get("mysidia");
$this->moneyBar = new Paragraph;

$today = new DateTime();
if(new DateTime() < new DateTime($today->format('Y').'-3-20 00:00:00')) $season = "Winter <img src=''>";
else if (new DateTime() < new DateTime($today->format('Y').'-6-21 00:00:00')) $season = "Spring <img src=''>";
else if (new DateTime() < new DateTime($today->format('Y').'-9-22 00:00:00')) $season = "Summer <img src=''>";
else if (new DateTime() < new DateTime($today->format('Y').'-12-20 00:00:00')) $season = "Fall <img src=''>";
else $season = "Winter <img src=''>";
$this->moneyBar->add(new Comment("<b id='season'>{$season}</b><br>"));

$this->moneyBar->add(new Comment("You have {$mysidia->user->money} {$mysidia->settings->cost}.<br>"));

$donate = new Link("donate");
$donate->setText("Transfer Freedom Points");
$this->setDivision($this->moneyBar);
}

Note: With the newest Mysidia version 1.3.6 you will need to add at the top near the <?php tag: use DateTime(); or it won't work.
___________________

Day/Night Cycle I will test this on 1.3.6 but it does work for 1.3.5

I also wanted to create a code for changing my explore page image map based on day and night. So for this I made a page for my image map area called Map.

So first you need to create the regular php page in your root folder. public_html. You can call it whatever, but I called mine map.php and inside paste this:
<?php



class MapController extends AppController{



public function __construct(){

parent::__construct("member");

}

}

and save. Then in your view folder, create a new file called (whatever you pick)view.php. Mine was mapview.php.
Paste this into the view file:
<?php

class MapView extends View{



public function index(){

$mysidia = Registry::get("mysidia");

$document = $this->document;

$document->setTitle("<br>The Wild<br><br>");

$h = date('G'); //set variable $h to the hour of the day
//G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.
if ($h < 12) $img = "<img src=' ' width='750' usemap='#image-map'>";
else $img = "<img src=' ' width='750' usemap='#image-map'>";
//
$document->add(new Comment("{$img}<br>"));

}}

Hope this helps anyone! I'll be working at figuring out how to get the time and calendar to work together but right now you'll have to switch the day and night image out for each new season. Once I get it figured out I'll add it.
 
Last edited:

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,267
Messages
33,049
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top