Jump to content
  • 0
ProjectX

Euphys WoE Controller 30 Minutes Interval Support

Question

Hello! Just want to post here and maybe someone can help me figure this out. I already gave up so I need to ask and hopefully someone can help.

I'm trying to modify the WoE Controller https://github.com/HerculesWS/Hercules/blob/master/npc/custom/woe_controller.txt
To support a 30 minutes interval for start and end time.

This is part of the code.

case 1:
			mes "[New Session]";
			if (.Size > 127) {
				mes "You have already reached the maximum of 32 sessions.";
				next;
				break;
			}
			mes "Select a day.";
			next;
			set .@day, select(" ~ "+implode(.Days$,": ~ "))-1;
			mes "[New Session]";
			mes "Select a start time for ^0055FF"+.Days$[.@day]+"^000000.";
			next;
			set .@menu$,"";
			for(set .@i,0; .@i<23; set .@i,.@i+1)
				set .@menu$, .@menu$+" ~ "+Add_Zero(.@i,1)+":";
			set .@start, select(.@menu$)-1;
			mes "[New Session]";
			mes "Select an end time for ^0055FF"+.Days$[.@day]+"^000000.";
			next;
			set .@menu$,"";
			for(set .@i,.@start+1; .@i<24; set.@i,.@i+1)
				set .@menu$, .@menu$+" ~ "+Add_Zero(.@i,1)+":";
			set .@end, select(.@menu$)+.@start;
			for(set .@i,0; .@i<.Size; set .@i,.@i+4)
				if (.@day == $WOE_CONTROL[.@i] &&
				   ((.@start >= $WOE_CONTROL[.@i+1] && .@start < $WOE_CONTROL[.@i+2]) ||
				    (.@end > $WOE_CONTROL[.@i+1] && .@end <= $WOE_CONTROL[.@i+2]) ||
				    (.@start <= $WOE_CONTROL[.@i+1] && .@end >= $WOE_CONTROL[.@i+2]))) {
					mes "[New Session]";
					mes "The chosen times overlap with an existing session.";
					next;
					set .@d,1;
					break;
				}
			if (.@d) { set .@d,0; break; }

 

This is what I have right now

 

set .@menu$,"";
for(set .@i,0; .@i<48; set .@i,.@i+1)
    set .@menu$, .@menu$+" ~ "+Add_Zero(.@i/2,1)+":"+(.@i%2==0?"00":"30");
set .@start, select(.@menu$)-1;
set .@start, .@start*30;
mes "[New Session]";
mes "Select an end time for ^0055FF"+.Days$[.@day]+"^000000.";
next;
set .@menu$,"";
for(set .@i,.@start/30+1; .@i<48; set .@i,.@i+1)
    set .@menu$, .@menu$+" ~ "+Add_Zero(.@i/2,1)+":"+(.@i%2==0?"00":"30");
set .@end, select(.@menu$)-1;
set .@end, .@end*30;

 

Another attempt 

for(set .@i,0; .@i<48; set .@i,.@i+1)
    set .@menu$, .@menu$+" ~ "+sprintf("%02d:%02d", .@i/2, .@i%2*30);
set .@start, select(.@menu$)-1;
set .@start, .@start*30;
mes "[New Session]";
mes "Select an end time for ^0055FF"+.Days$[.@day]+"^000000.";
next;
set .@menu$,"";
for(set .@i,.@start/30+1; .@i<48; set .@i,.@i+1)
    set .@menu$, .@menu$+" ~ "+sprintf("%02d:%02d", .@i/2, .@i%2*30);
set .@end, select(.@menu$)-1;
set .@end, .@end*30;

 

Output in-game. Can anyone point me in the right direction?

 

image.png.6f184907cb16278d7ff26985834b5f18.png

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

I changed the time slots to be in 30-minute intervals rather than hourly increments.

Here's the code. I haven't tested it. Please let us know if it works. ~

case 1:
			mes "[New Session]";
			if (.Size > 127) {
				mes "You have already reached the maximum of 32 sessions.";
				next;
				break;
			}
			mes "Select a day.";
			next;
			set .@day, select(" ~ "+implode(.Days$,": ~ "))-1;
			mes "[New Session]";
			mes "Select a start time for ^0055FF"+.Days$[.@day]+"^000000.";
			next;
			set .@menu$,"";
			for(set .@i,0; .@i<47; set .@i,.@i+2)
				set .@menu$, .@menu$+" ~ "+Add_Zero(floor(.@i/2),1)+":"+Add_Zero((.@i%2)*30,2)+":";
			set .@start, select(.@menu$)-1;
			mes "[New Session]";
			mes "Select an end time for ^0055FF"+.Days$[.@day]+"^000000.";
			next;
			set .@menu$,"";
			for(set .@i,.@start+1; .@i<48; set.@i,.@i+2)
				set .@menu$, .@menu$+" ~ "+Add_Zero(floor(.@i/2),1)+":"+Add_Zero((.@i%2)*30,2)+":";
			set .@end, select(.@menu$)+.@start;
			for(set .@i,0; .@i<.Size; set .@i,.@i+4)
				if (.@day == $WOE_CONTROL[.@i] &&
				   ((.@start >= $WOE_CONTROL[.@i+1] && .@start < $WOE_CONTROL[.@i+2]) ||
				    (.@end > $WOE_CONTROL[.@i+1] && .@end <= $WOE_CONTROL[.@i+2]) ||
				    (.@start <= $WOE_CONTROL[.@i+1] && .@end >= $WOE_CONTROL[.@i+2]))) {
					mes "[New Session]";
					mes "The chosen times overlap with an existing session.";
					next;
					set .@d,1;
					break;
				}
			if (.@d) { set .@d,0; break; }



 

Share this post


Link to post
Share on other sites
  • 0
15 hours ago, Neffletics said:

I changed the time slots to be in 30-minute intervals rather than hourly increments.

Here's the code. I haven't tested it. Please let us know if it works. ~

case 1: mes "[New Session]"; if (.Size > 127) { mes "You have already reached the maximum of 32 sessions."; next; break; } mes "Select a day."; next; set .@day, select(" ~ "+implode(.Days$,": ~ "))-1; mes "[New Session]"; mes "Select a start time for ^0055FF"+.Days$[.@day]+"^000000."; next; set .@menu$,""; for(set .@i,0; .@i<47; set .@i,.@i+2) set .@menu$, .@menu$+" ~ "+Add_Zero(floor(.@i/2),1)+":"+Add_Zero((.@i%2)*30,2)+":"; set .@start, select(.@menu$)-1; mes "[New Session]"; mes "Select an end time for ^0055FF"+.Days$[.@day]+"^000000."; next; set .@menu$,""; for(set .@i,.@start+1; .@i<48; set.@i,.@i+2) set .@menu$, .@menu$+" ~ "+Add_Zero(floor(.@i/2),1)+":"+Add_Zero((.@i%2)*30,2)+":"; set .@end, select(.@menu$)+.@start; for(set .@i,0; .@i<.Size; set .@i,.@i+4) if (.@day == $WOE_CONTROL[.@i] && ((.@start >= $WOE_CONTROL[.@i+1] && .@start < $WOE_CONTROL[.@i+2]) || (.@end > $WOE_CONTROL[.@i+1] && .@end <= $WOE_CONTROL[.@i+2]) || (.@start <= $WOE_CONTROL[.@i+1] && .@end >= $WOE_CONTROL[.@i+2]))) { mes "[New Session]"; mes "The chosen times overlap with an existing session."; next; set .@d,1; break; } if (.@d) { set .@d,0; break; }


case 1:
			mes "[New Session]";
			if (.Size > 127) {
				mes "You have already reached the maximum of 32 sessions.";
				next;
				break;
			}
			mes "Select a day.";
			next;
			set .@day, select(" ~ "+implode(.Days$,": ~ "))-1;
			mes "[New Session]";
			mes "Select a start time for ^0055FF"+.Days$[.@day]+"^000000.";
			next;
			set .@menu$,"";
			for(set .@i,0; .@i<47; set .@i,.@i+2)
				set .@menu$, .@menu$+" ~ "+Add_Zero(floor(.@i/2),1)+":"+Add_Zero((.@i%2)*30,2)+":";
			set .@start, select(.@menu$)-1;
			mes "[New Session]";
			mes "Select an end time for ^0055FF"+.Days$[.@day]+"^000000.";
			next;
			set .@menu$,"";
			for(set .@i,.@start+1; .@i<48; set.@i,.@i+2)
				set .@menu$, .@menu$+" ~ "+Add_Zero(floor(.@i/2),1)+":"+Add_Zero((.@i%2)*30,2)+":";
			set .@end, select(.@menu$)+.@start;
			for(set .@i,0; .@i<.Size; set .@i,.@i+4)
				if (.@day == $WOE_CONTROL[.@i] &&
				   ((.@start >= $WOE_CONTROL[.@i+1] && .@start < $WOE_CONTROL[.@i+2]) ||
				    (.@end > $WOE_CONTROL[.@i+1] && .@end <= $WOE_CONTROL[.@i+2]) ||
				    (.@start <= $WOE_CONTROL[.@i+1] && .@end >= $WOE_CONTROL[.@i+2]))) {
					mes "[New Session]";
					mes "The chosen times overlap with an existing session.";
					next;
					set .@d,1;
					break;
				}
			if (.@d) { set .@d,0; break; }



 


Thank you for trying. I got an error on the floor() part I changed it to atoi but checking I got this menu and the time is not matching either.

 

image.png.5bb250abb06068176f6d21b3eabc67fb.png

 

New code:

case 1:
            mes "[New Session]";
            if (.Size > 127) {
                mes "You have already reached the maximum of 32 sessions.";
                next;
                break;
            }
            mes "Select a day.";
            next;
            set .@day, select(" ~ "+implode(.Days$,": ~ "))-1;
            mes "[New Session]";
            mes "Select a start time for ^0055FF"+.Days$[.@day]+"^000000.";
            next;
            set .@menu$,"";
            for(set .@i,0; .@i<47; set .@i,.@i+2)
                set .@menu$, .@menu$+" ~ "+Add_Zero(atoi(.@i/2),1)+":"+Add_Zero((.@i%2)*30,2)+":";
            set .@start, select(.@menu$)-1;
            mes "[New Session]";
            mes "Select an end time for ^0055FF"+.Days$[.@day]+"^000000.";
            next;
            set .@menu$,"";
            for(set .@i,.@start+1; .@i<48; set.@i,.@i+2)
                    set .@menu$, .@menu$+" ~ "+Add_Zero(atoi(.@i/2),1)+":"+Add_Zero((.@i%2)*30,2)+":";
            set .@end, select(.@menu$)+.@start;
            for(set .@i,0; .@i<.Size; set .@i,.@i+4)
                if (.@day == $WOE_CONTROL[.@i] &&
                   ((.@start >= $WOE_CONTROL[.@i+1] && .@start < $WOE_CONTROL[.@i+2]) ||
                    (.@end > $WOE_CONTROL[.@i+1] && .@end <= $WOE_CONTROL[.@i+2]) ||
                    (.@start <= $WOE_CONTROL[.@i+1] && .@end >= $WOE_CONTROL[.@i+2]))) {
                    mes "[New Session]";
                    mes "The chosen times overlap with an existing session.";
                    next;
                    set .@d,1;
                    break;
                }
            if (.@d) { set .@d,0; break; }

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.