akaitoDEV 34 Posted August 11, 2015 Share Posted August 11, 2015 M2 Download Center This is the hidden content, please Sign In or Sign Up ( Internal ) Hello guys, this function is very old and i have shared it on another board already (not on metin2dev). So this gives out a bool(true,false) function is_weekend() local day = tonumber(os.date("%w")) return day > 4 or day == 0 end 18 3 8 Link to comment Share on other sites More sharing options...
Think 117 Posted August 12, 2015 Share Posted August 12, 2015 so 5, 6 and 0 are valid weekend days. How long do your weekends last? Mine have two days! 2 Link to comment Share on other sites More sharing options...
Keshi 0 Posted August 13, 2015 Share Posted August 13, 2015 so 5, 6 and 0 are valid weekend days. How long do your weekends last? Mine have two days! return day > 4 or day == 0 greater than 4 and 0 Link to comment Share on other sites More sharing options...
Think 117 Posted August 13, 2015 Share Posted August 13, 2015 so 5, 6 and 0 are valid weekend days. How long do your weekends last? Mine have two days! return day > 4 or day == 0 greater than 4 and 0 Ahem, 5 and 6 are greater than 4. Link to comment Share on other sites More sharing options...
Denis 1474 Posted August 13, 2015 Share Posted August 13, 2015 (edited) Shouldn't it be like this ? return day == 6 or day == 0 Edited August 13, 2015 by Denis 1 Link to comment Share on other sites More sharing options...
Premium MrLibya 554 Posted August 14, 2015 Premium Share Posted August 14, 2015 (edited) try this function is_weekend() local weekend = os.date("%w") local day = os.date("%%A") if day == weekend return true else return false end end Edited August 14, 2015 by MrLibya If you're going to do something, then do it right. Link to comment Share on other sites More sharing options...
Think 117 Posted August 15, 2015 Share Posted August 15, 2015 try this function is_weekend() local weekend = os.date("%w") local day = os.date("%%A") if day == weekend return true else return false end end I am confused as to how this is supposed to work: - weekend will hold the weekday as number (e.g 6) - day will hold % + weekday's full name (e.g %Saturday) - or simply '%', not quite sure how it's parsed. (ref for what the os.date yields: http://www.cplusplus.com/reference/ctime/strftime/). 1 Link to comment Share on other sites More sharing options...
Rideas 167 Posted August 15, 2015 Share Posted August 15, 2015 (edited) try this function is_weekend() local weekend = os.date("%w") local day = os.date("%%A") if day == weekend return true else return false end end function is_weekend() local weekend = os.date("%w") local day = os.date("%%A") if day == "Saturday" then return true else return false end end try this function is_weekend() local weekend = os.date("%w") local day = os.date("%%A") if day == weekend return true else return false end end I am confused as to how this is supposed to work: - weekend will hold the weekday as number (e.g 6) - day will hold % + weekday's full name (e.g %Saturday) - or simply '%', not quite sure how it's parsed. (ref for what the os.date yields: http://www.cplusplus.com/reference/ctime/strftime/). Hahahahaha lol Edited August 15, 2015 by Rideas Link to comment Share on other sites More sharing options...
Premium MrLibya 554 Posted August 15, 2015 Premium Share Posted August 15, 2015 (edited) try this function is_weekend() local weekend = os.date("%w") local day = os.date("%%A") if day == weekend return true else return false end end I am confused as to how this is supposed to work: - weekend will hold the weekday as number (e.g 6) - day will hold % + weekday's full name (e.g %Saturday) - or simply '%', not quite sure how it's parsed. (ref for what the os.date yields: http://www.cplusplus.com/reference/ctime/strftime/). ok it's my falt i have see in lua that is give string https://metin2.download/picture/Cz8ytZEw8hs20260NyIdJHibQb1v3YO7/.png now i see it agien and i see it's give number Edited August 31, 2022 by Metin2 Dev Core X - External 2 Internal If you're going to do something, then do it right. Link to comment Share on other sites More sharing options...
Rideas 167 Posted August 15, 2015 Share Posted August 15, 2015 (edited) try this function is_weekend() local weekend = os.date("%w") local day = os.date("%%A") if day == weekend return true else return false end end I am confused as to how this is supposed to work: - weekend will hold the weekday as number (e.g 6) - day will hold % + weekday's full name (e.g %Saturday) - or simply '%', not quite sure how it's parsed. (ref for what the os.date yields: http://www.cplusplus.com/reference/ctime/strftime/). ok it's my falt i have see in lua that is give string https://metin2.download/picture/Cz8ytZEw8hs20260NyIdJHibQb1v3YO7/.png now i see it agien and i see it's give number function is_weekend() local weekend = os.date("%w") local day = os.date("%%A") if day == "Saturday" then return true else return false end end Edited August 31, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Think 117 Posted August 15, 2015 Share Posted August 15, 2015 %%A is not a thing (http://ideone.com/jJHXkO). This will just do (like Denis said), there's no need to complicate it more than it: Shouldn't it be like this ? return day == 6 or day == 0 1 Link to comment Share on other sites More sharing options...
akaitoDEV 34 Posted August 17, 2015 Author Share Posted August 17, 2015 Guys what's up? This is 100% working, Link to comment Share on other sites More sharing options...
Remix 45 Posted October 23, 2015 Share Posted October 23, 2015 Guys what's up? This is 100% working, Not correctly. Test it today. Friday would be 5 so the function would return true even if it isn't weekend. Link to comment Share on other sites More sharing options...
Recommended Posts