options:
gui name: <MM>/<YY> <M>
function G(MM:number,DD:number,YY:number) :: number:
if {_MM} >= 3:
set {_z} to {_YY}
else if {_MM} is 1 or 2:
set {_z} to {_YY}-1
set {_A} to floor(23*{_MM}/9)
set {_B::*} to floor({_z}/4), floor({_z}/100) and floor({_z}/400)
if {_MM} is 1 or 2:
set {_D} to {_A}+{_DD}+4+{_YY}+{_B::1}-{_B::2}+{_B::3}
else:
set {_D} to {_A}+{_DD}+4+{_YY}+{_B::1}-{_B::2}+{_B::3}-2
return mod({_D},7)
function JDay(JJ:number) :: string:
set {_d::*} to "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi" and "Dimanche"
if {_JJ} is 0:
set {_JJ} to 7
return {_d::%{_JJ}%}
function MMonth(MM:number) :: string:
set {_m::*} to "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre" and "Décembre"
return {_m::%{_MM}%}
function isB(YY:number) :: boolean:
if mod({_YY},4) != 0:
return false
else if mod({_YY},100) != 0:
return true
else if mod({_YY},400) != 0:
return false
else:
return true
function nbMY(MM:number,YY:number) :: number:
set {_n::*} to 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 and 31
if isB({_YY}) is true:
set {_n::2} to {_n::2}+1
return {_n::%{_MM}%}
on command:
if command is "jour":
cancel event
set {_a::*} to arguments split by " "
if {_a::1} is set:
if {_a::2} parsed as number is set:
if {_a::3} parsed as number is set:
# /MM /DD /YY
if {_a::1} parsed as number is smaller or equal to 12:
send "%JDay(G({_a::1} parsed as number,{_a::2} parsed as number,{_a::3} parsed as number))% %{_a::2}% %MMonth({_a::1} parsed as number)% %{_a::3}%" to player
else:
set {_n} to "%now%"
set {_t::*} to first element of {_n} split by " " split by "/"
set {_t::1} to {_t::1} parsed as number
set {_t::2} to {_t::2} parsed as number
set {_t::3} to {_t::3} parsed as number+2000
execute player command "/jour %{_t::2}% %{_t::1}% %{_t::3}%"
else if command is "calendrier":
cancel event
set {_a::*} to arguments split by " "
if {_a::1} is set:
if {_a::2} parsed as number is set:
# /MM /YY
set {_MM} to {_a::1} parsed as number
set {_YY} to {_a::2} parsed as number
set {_i::*} to "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi" and "Dimanche"
loop all numbers between 1 and nbMY({_MM},{_YY}):
set {_N} to loop-number
loop {_i::*}:
if loop-value-2 is JDay(G({_MM},{_N},{_YY})):
add {_N} to {_i::%loop-index%::*}
set {_NAME} to "{@gui name}"
replace all "<M>" with "%MMonth({_MM})%" in {_NAME}
if {_MM} is smaller than 10:
replace all "<MM>" with "0%{_MM}%" in {_NAME}
else:
replace all "<MM>" with "%{_MM}%" in {_NAME}
replace all "<YY>" with "%{_YY}%" in {_NAME}
open virtual chest inventory with size 6 named "%{_NAME}%" to player
loop 7 times:
loop {_i::%loop-value%::*}:
if loop-value-2 is 1:
set {_S} to loop-value-1
loop {_i::%loop-value%::*}:
if loop-value-2 parsed as number - {_S} < 0:
format gui slot loop-value-1 + (loop-index parsed as number-1) * 9 of player with loop-value-2 of glass pane named "%{_i::%loop-value-1%}% %loop-value-2%"
else:
format gui slot loop-value-1 + loop-index parsed as number * 9 of player with loop-value-2 of glass pane named "%{_i::%loop-value-1%}% %loop-value-2%"
if {_MM} is not 1:
format gui slot 45 of player with paper named "§fMois précédent" to run player command "/%command% %{_MM}-1% %{_YY}%"
if {_MM} is not 12:
format gui slot 53 of player with paper named "§fMois suivant" to run player command "/%command% %{_MM}+1% %{_YY}%"
else:
format gui slot 53 of player with paper named "§fMois suivant" to run player command "/%command% 1 %{_YY}+1%"
stop
format gui slot 45 of player with paper named "§fMois précédent" to run player command "/%command% 12 %{_YY}-1%"
format gui slot 53 of player with paper named "§fMois suivant" to run player command "/%command% %{_MM}+1% %{_YY}%"
else:
execute player command "/calendrier"
else:
set {_n} to "%now%"
set {_t::*} to first element of {_n} split by " " split by "/"
set {_t::2} to {_t::2} parsed as number
set {_t::3} to {_t::3} parsed as number+2000
execute player command "/calendrier %{_t::2}% %{_t::3}%"
Plus besoin de faire (J+1).