Need a calendar changing script for Nintendo Switch
10 posts
• Page 1 of 1
Need a calendar changing script for Nintendo Switch
Ok playing Pokemon Sword on Switch I was always having a bug I couldn't figure out where my script would foul up after an unspecific amount of tries. I have figure out what is causing this. I can't just change the day of the month to go forward one day. I need to also change the month forward as well as the 1st of each month does not work to reset the day and Pokemon Dens do not reset. Let me show basically what I have.
I am asking how to program some tool that would automatically change the time of the system clock by one day(including month and year). It just needs at least 1 day forward increment. You can skip the 31 day of the year and go 2 days forward for these if its easier to just use a 30 day month. But basically it should only ever start off and go "up" 1 month, "right", "up" 1 day, "right", "up" one year at most. The Nintendo Switch will max out I believe in 2060 as the years do not go past that.
I will be doing research into this as well. But it seems like it would take a nested combo in order to handle the date inside of the original combo.
I don't see any date managing scripts in the language reference guide online but like I said. It doesn't need to be the real date and can use a constant 30 day month as long as the month increments by 1 each 30 days and increments the year once every 360 days while changing the month and day to January 1st each time the year increments.
- Code: Select all
#include <titanone.gph>
int onoff = FALSE;
main {
if(event_press(BUTTON_7)) {
onoff = !onoff;
}
if(onoff) {
combo_run(Poke);
}
}
combo Poke {
set_val(SWITCH_A,100);//Entering the den menu and selecting start encounter
wait(100);
wait(500);
set_val(SWITCH_A,100);
wait(100);
wait(500);
set_val(SWITCH_A,100);
wait(100);
wait(1000);
set_val(SWITCH_A,100);
wait(100);
wait(2500);
set_val(SWITCH_HOME,100);//changing the date area of code beteen returns
wait(100);
wait(1000);
set_val(SWITCH_DOWN,100);
wait(100);
wait(150);
set_val(SWITCH_RIGHT,100);
wait(100);
wait(150);
set_val(SWITCH_RIGHT,100);
wait(100);
wait(150);
set_val(SWITCH_RIGHT,100);
wait(100);
wait(150);
set_val(SWITCH_RIGHT,100);
wait(100);
wait(150);
set_val(SWITCH_A,100);
wait(100);
wait(150);
set_val(SWITCH_DOWN,100);
wait(2500);
wait(150);
set_val(SWITCH_A,100);
wait(100);
wait(150);
set_val(SWITCH_DOWN,100);
wait(100);
wait(150);
set_val(SWITCH_DOWN,100);
wait(100);
wait(150);
set_val(SWITCH_DOWN,100);
wait(100);
wait(150);
set_val(SWITCH_DOWN,100);
wait(100);
wait(150);
set_val(SWITCH_A,100);
wait(100);
wait(150);
set_val(SWITCH_DOWN,100);
wait(100);
wait(150);
set_val(SWITCH_DOWN,100);
wait(100);
wait(150);
set_val(SWITCH_A,100);
wait(100);
wait(150);
/*set_val(SWITCH_UP,100);//an up here would change the month by one
wait(100);
wait(150);*/
set_val(SWITCH_RIGHT,100);
wait(100);
wait(150);
set_val(SWITCH_UP,100);//specifically here is where to it presses up on the day of the month
wait(100);
wait(150);
set_val(SWITCH_RIGHT,100);
wait(100);
wait(150);
/*set_val(SWITCH_UP,100);//an up here would change the year by one currently 1/1/2000(oldest date possible)
wait(100);
wait(150);*/
set_val(SWITCH_RIGHT,100);
wait(100);
wait(150);
set_val(SWITCH_RIGHT,100);
wait(100);
wait(150);
set_val(SWITCH_RIGHT,100);
wait(100);
wait(150);
set_val(SWITCH_RIGHT,100);
wait(100);
wait(150);
set_val(SWITCH_A,100);
wait(100);
wait(150);
set_val(SWITCH_HOME,100);
wait(100);
wait(1000);
set_val(SWITCH_HOME,100);
wait(100);
wait(1000);
set_val(SWITCH_B,100);//Exiting out of the den menu
wait(100);
wait(1500);
set_val(SWITCH_B,100);
wait(100);
wait(500);
set_val(SWITCH_B,100);
wait(100);
wait(1500);
set_val(SWITCH_A,100);
wait(100);
wait(5000);
}
I am asking how to program some tool that would automatically change the time of the system clock by one day(including month and year). It just needs at least 1 day forward increment. You can skip the 31 day of the year and go 2 days forward for these if its easier to just use a 30 day month. But basically it should only ever start off and go "up" 1 month, "right", "up" 1 day, "right", "up" one year at most. The Nintendo Switch will max out I believe in 2060 as the years do not go past that.
I will be doing research into this as well. But it seems like it would take a nested combo in order to handle the date inside of the original combo.
I don't see any date managing scripts in the language reference guide online but like I said. It doesn't need to be the real date and can use a constant 30 day month as long as the month increments by 1 each 30 days and increments the year once every 360 days while changing the month and day to January 1st each time the year increments.
-
Endless - Master Sergeant
- Posts: 38
- Joined: Thu May 02, 2019 1:06 am
Re: Need a calendar changing script for Nintendo Switch
If I understood correctly you need increment the Switch system date by one day. When the day reaches 30/31, then the month needs to be incremented and the day set back to 1. Same for the year at Dec 31.
Definitively you will need the script to track the Switch date, so it can know how behave on each increment.
One single combo will not be enough, you will possible need the following combos:
1. Increment Day
2. Increment Month
3. Increment Year
4. Return to Day 1
5. Return to January
Also, as you have a Titan Two, the best would be use the native Titan Two script code.
Definitively you will need the script to track the Switch date, so it can know how behave on each increment.
One single combo will not be enough, you will possible need the following combos:
1. Increment Day
2. Increment Month
3. Increment Year
4. Return to Day 1
5. Return to January
Also, as you have a Titan Two, the best would be use the native Titan Two script code.
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: Need a calendar changing script for Nintendo Switch
Native Titan Two script code? Is there some code that tracks the Switch's date? Also, how do I convert these ++day, ++month, ++year into SWITCH_UP's?
By the way thanks for the reply in the middle of the night. I was still awake but I wasn't expecting a response so soon.
Can I put "if" statements into a combo?
How do you get combos to run sequentially?
I actually figured out a way to do it without coding just using the macro recorder. I simply change the date forward when I need and when I am out of the pokemon den screen I simply set it back one day. So, it always stays on the same 2 days.
By the way thanks for the reply in the middle of the night. I was still awake but I wasn't expecting a response so soon.
- Code: Select all
int Day = 1;
int Month = 1;
int Year = 1;
if combo_run(Poke){
Day++;
}
if (Day == 30) {
Month++;
Day = 1;
}
if (Month == 12 && Day == 30){
Year++;
Month = 1;
}
Can I put "if" statements into a combo?
How do you get combos to run sequentially?
I actually figured out a way to do it without coding just using the macro recorder. I simply change the date forward when I need and when I am out of the pokemon den screen I simply set it back one day. So, it always stays on the same 2 days.
Last edited by Endless on Sat Dec 14, 2019 2:37 pm, edited 1 time in total.
-
Endless - Master Sergeant
- Posts: 38
- Joined: Thu May 02, 2019 1:06 am
Re: Need a calendar changing script for Nintendo Switch
Here an example code to track and control the date increments. In the defines at the very beginning you should set with current date of your Switch.
Please note the comments with TODO annotation, is where you should call the combos to perform the described action.
Please note the comments with TODO annotation, is where you should call the combos to perform the described action.
- Code: Select all
#define SWITCH_DAY 14
#define SWITCH_MONTH 12
#define SWITCH_YEAR 2019
const uint8 days_in_month[] = {
0, // Start index on 1
31, // Jan
28, // Feb, 29 on leap years
31, // Mar
30, // Apr
31, // May
30, // Jun
31, // Jul
31, // Aug
30, // Sep
31, // Oct
30, // Nov
31, // Dec
};
uint8 day = SWITCH_DAY;
uint8 month = SWITCH_MONTH;
uint16 year = SWITCH_DAY;
main {
if(++day > days_in_month[month]) {
if(month == 2 && day == 29 && (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0)) {
// Leap year, February has 29 days
goto LEAP_YEAR;
}
day = 1;
//
// TODO: Run combo reset day to 1
//
if(++month > 12) {
month = 1;
//
// TODO: Run combo reset month to 1
//
++year;
//
// TODO: Run combo to increment the year
//
} else {
//
// TODO: Run combo to increment the month
//
}
} else {
LEAP_YEAR:;
//
// TODO: Run combo to increment the day
//
}
}
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: Need a calendar changing script for Nintendo Switch
Thank you very much for your time and the excellent code. I will start experimenting with it right away.
Ok, I am using macros heavily at this point. Is there any way to run a combo/macro(prefer combo if possible) that does not run simultaneously with the main macro. Simply put I just want to turn the month forward once every 30 times the main macro runs.
Note: See the problem is I am using a second exploit besides the one I originally planned on using(to level up lots of pokemon at once) instead of beating max raid battles for candies that could be used only on one pokemon and are rare to find. And it is very conscious of the date. If you change the time back at all you go from 1 day to complete a Poke Job to months to complete a Poke Job.
My macro is way too large to convert to .gpc script so I have to incorporate them both together.
Ok, I am using macros heavily at this point. Is there any way to run a combo/macro(prefer combo if possible) that does not run simultaneously with the main macro. Simply put I just want to turn the month forward once every 30 times the main macro runs.
Note: See the problem is I am using a second exploit besides the one I originally planned on using(to level up lots of pokemon at once) instead of beating max raid battles for candies that could be used only on one pokemon and are rare to find. And it is very conscious of the date. If you change the time back at all you go from 1 day to complete a Poke Job to months to complete a Poke Job.
My macro is way too large to convert to .gpc script so I have to incorporate them both together.
-
Endless - Master Sergeant
- Posts: 38
- Joined: Thu May 02, 2019 1:06 am
Re: Need a calendar changing script for Nintendo Switch
You are right, in my example the combos would run all at once. I did some changes to avoid that, also defined the combos, but still need include the button sequence inside the combos to perform the related action.
Press Plus on the controller to trigger the date increment.
Press Plus on the controller to trigger the date increment.
- Code: Select all
#include <switch.gph>
#define SWITCH_DAY 14
#define SWITCH_MONTH 12
#define SWITCH_YEAR 2019
#define DO_INCREMENT 0x01
#define INCREMENT_DAY 0x02
#define SET_DAY_TO_1 0x04
#define INCREMENT_MONTH 0x08
#define SET_MONTH_TO_1 0x10
#define INCREMENT_YEAR 0x20
const uint8 days_in_month[] = {
0, // Start index on 1
31, // Jan
28, // Feb, 29 on leap years
31, // Mar
30, // Apr
31, // May
30, // Jun
31, // Jul
31, // Aug
30, // Sep
31, // Oct
30, // Nov
31, // Dec
};
uint8 day = SWITCH_DAY;
uint8 month = SWITCH_MONTH;
uint16 year = SWITCH_DAY;
uint8 proc_flags;
main {
if(event_active(SWITCH_PLUS) && proc_flags == 0) {
proc_flags |= DO_INCREMENT;
}
if(proc_flags & DO_INCREMENT) {
proc_flags = 0;
if(++day > days_in_month[month]) {
if(month == 2 && day == 29 && (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0)) {
goto LEAP_YEAR; // Leap year, February has 29 days
}
day = 1;
proc_flags |= SET_DAY_TO_1;
if(++month > 12) {
month = 1;
proc_flags |= SET_MONTH_TO_1;
++year;
proc_flags |= INCREMENT_YEAR;
} else {
proc_flags |= INCREMENT_MONTH;
}
} else {
LEAP_YEAR:;
proc_flags |= INCREMENT_DAY;
}
}
if(proc_flags & INCREMENT_DAY) {
combo_run(IncrementDay);
} else if(proc_flags & SET_DAY_TO_1) {
combo_run(SetDayTo1);
} else if(proc_flags & INCREMENT_MONTH) {
combo_run(IncrementMonth);
} else if(proc_flags & SET_MONTH_TO_1) {
combo_run(SetMonthTo1);
} else if(proc_flags & INCREMENT_YEAR) {
combo_run(IncrementYear);
}
}
combo IncrementDay {
//
// TODO: Increment the day
//
proc_flags &= ~INCREMENT_DAY;
}
combo SetDayTo1 {
//
// TODO: Set day to 1
//
proc_flags &= ~SET_DAY_TO_1;
}
combo IncrementMonth {
//
// TODO: Increment the month
//
proc_flags &= ~INCREMENT_MONTH;
}
combo SetMonthTo1 {
//
// TODO: Set month to 1
//
proc_flags &= ~SET_MONTH_TO_1;
}
combo IncrementYear {
//
// TODO: Increment the year
//
proc_flags &= ~INCREMENT_YEAR;
}
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: Need a calendar changing script for Nintendo Switch
I haven't tested it yet but can I use macros instead of combos? I'm not sure if you read that in my previous post but I can't convert the macro to a gpc code because it is too large. I have to use a combination of macros that basically do all the running around. But maybe I could make several combos to handle the button presses.
-
Endless - Master Sergeant
- Posts: 38
- Joined: Thu May 02, 2019 1:06 am
Re: Need a calendar changing script for Nintendo Switch
Sure, here is the script modified to use macros, instead of combos:
- Code: Select all
#include <switch.gph>
#define SWITCH_DAY 14
#define SWITCH_MONTH 12
#define SWITCH_YEAR 2019
#define DO_INCREMENT 0x01
#define INCREMENT_DAY 0x02
#define SET_DAY_TO_1 0x04
#define INCREMENT_MONTH 0x08
#define SET_MONTH_TO_1 0x10
#define INCREMENT_YEAR 0x20
const uint8 days_in_month[] = {
0, // Start index on 1
31, // Jan
28, // Feb, 29 on leap years
31, // Mar
30, // Apr
31, // May
30, // Jun
31, // Jul
31, // Aug
30, // Sep
31, // Oct
30, // Nov
31, // Dec
};
uint8 day = SWITCH_DAY;
uint8 month = SWITCH_MONTH;
uint16 year = SWITCH_DAY;
uint8 proc_flags;
main {
if(macro_time() < 0) {
if(event_active(SWITCH_PLUS) && proc_flags == 0) {
proc_flags |= DO_INCREMENT;
}
if(proc_flags & DO_INCREMENT) {
proc_flags = 0;
if(++day > days_in_month[month]) {
if(month == 2 && day == 29 && (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0)) {
goto LEAP_YEAR; // Leap year, February has 29 days
}
day = 1;
proc_flags |= SET_DAY_TO_1;
if(++month > 12) {
month = 1;
proc_flags |= SET_MONTH_TO_1;
++year;
proc_flags |= INCREMENT_YEAR;
} else {
proc_flags |= INCREMENT_MONTH;
}
} else {
LEAP_YEAR:;
proc_flags |= INCREMENT_DAY;
}
}
if(proc_flags & INCREMENT_DAY) {
macro_run("IncrementDay.gmk");
proc_flags &= ~INCREMENT_DAY;
} else if(proc_flags & SET_DAY_TO_1) {
macro_run("SetDayTo1.gmk");
proc_flags &= ~SET_DAY_TO_1;
} else if(proc_flags & INCREMENT_MONTH) {
macro_run("IncrementMonth.gmk");
proc_flags &= ~INCREMENT_MONTH;
} else if(proc_flags & SET_MONTH_TO_1) {
macro_run("SetMonthTo1.gmk");
proc_flags &= ~SET_MONTH_TO_1;
} else if(proc_flags & INCREMENT_YEAR) {
macro_run("IncrementYear.gmk");
proc_flags &= ~INCREMENT_YEAR;
}
}
}
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: Need a calendar changing script for Nintendo Switch
Assuming this is for Pokemon:
viewtopic.php?f=9&t=14268#p93285
(Remember all T1 scripts can run on T2, via converter)
viewtopic.php?f=9&t=14268#p93285
(Remember all T1 scripts can run on T2, via converter)
-
Buffy - Lieutenant
- Posts: 422
- Joined: Wed Jul 20, 2016 5:23 am
Re: Need a calendar changing script for Nintendo Switch
Buffy wrote:Assuming this is for Pokemon:
viewtopic.php?f=9&t=14268#p93285
(Remember all T1 scripts can run on T2, via converter)
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
10 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 42 guests