Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Mys v1.3.x Mods (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=42)
-   -   Time season and calendar changes (http://www.mysidiaadoptables.com/forum/showthread.php?t=5703)

Micolai 12-27-2020 11:21 AM

Time season and calendar changes
 
Seasons Display

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.

Quote:

$today = new DateTime();
if(new DateTime() < new DateTime($today->format('Y').'-3-20 00:00:00')) $season = "Winter <img src='https://i.imgur.com/yYgkRTD.png'>";
else if (new DateTime() < new DateTime($today->format('Y').'-6-21 00:00:00')) $season = "Spring ";
else if (new DateTime() < new DateTime($today->format('Y').'-9-22 00:00:00')) $season = "Summer <img src='https://i.imgur.com/NwNeO64.png'>";
else if (new DateTime() < new DateTime($today->format('Y').'-12-20 00:00:00')) $season = "Fall <img src='https://i.imgur.com/vWiRVTe.png'>";
else $season = "Winter <img src='https://i.imgur.com/yYgkRTD.png'>";
$this->moneyBar->add(new Comment("<b id='season'>{$season}</b><br>"));
You can see where I have the little image icons beside my season's text.
I pasted this into the protected function setMoneyBar area of class_sidebar.php file. So my code looks like this:

Quote:

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='https://i.imgur.com/yYgkRTD.png'>";
else if (new DateTime() < new DateTime($today->format('Y').'-6-21 00:00:00')) $season = "Spring ";
else if (new DateTime() < new DateTime($today->format('Y').'-9-22 00:00:00')) $season = "Summer <img src='https://i.imgur.com/NwNeO64.png'>";
else if (new DateTime() < new DateTime($today->format('Y').'-12-20 00:00:00')) $season = "Fall <img src='https://i.imgur.com/vWiRVTe.png'>";
else $season = "Winter <img src='https://i.imgur.com/yYgkRTD.png'>";
$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);
}
___________________

Day/Night Cycle

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:
Quote:

<?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:
Quote:

<?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='https://i.imgur.com/sa78yME.jpg' width='750' usemap='#image-map'>";
else $img = "<img src='https://i.imgur.com/rWiXA8c.jpg' 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.

TruaShamu 04-19-2021 07:56 PM

This is great! Thanks so much :)

Micolai 04-20-2021 01:53 PM

Quote:

Originally Posted by TruaShamu (Post 37911)
This is great! Thanks so much :)

No problem! :D


All times are GMT -5. The time now is 06:04 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.