niubbone Posted May 12, 2010 Posted May 12, 2010 (edited) I'm making a small game in which I want to include a small calendar needed to check some events and that advances by one day every action I make.The game is like a little life simulator, so, when you hang out with a girl, go out with friends, study and so on a day passes for each action.Therefore I created a basic starting date stored in a variable as a string. Then, when needed, I created a function that should add a single day to the date everytime it's called.But something seems not to work with _DateAddHere's the first chunk of code I came up with (thanks todanwilli):#include <Date.au3> Global $date = "2010/12/20" Global $NewDate = $date For $i = 1 To 5 $NewDate = _DateAdd('d', 1, $NewDate) MsgBox(4096, "", "Today + 1 days:" & _Format($NewDate)) Next Func _Format($FDate) Return StringRight($FDate,2) & '/' & StringMid($FDate,6,2) & '/' & StringLeft($FDate,4) EndFunc MsgBox(0,"new date check",$newdate) ;this for example wil add 5 days but in final function ;will be added only 1 day removing the for 1 to 5 cycleThis adds the date for 5 days consecutively and I can even bring the date value out of the loop for later use.Now, Since the code of the game will be lot of lines, to make it smaller I would had liked to bring all the code in a function, so whenever I need i can call it and add 1 day to the current standalone game calendar date.This is what I tried, but it doesn't works... Any suggestion?#include <Date.au3> Global $date = "2010/12/20" Global $NewDate = $date Global $case1=3 Global $case2=7 If $case1>2 Then DayAfter($NewDate) Msgbox(0,"try",$NewDate) EndIf If $case2>3 Then DayAfter($NewDate) Msgbox(0,"try",$NewDate) EndIf Func DayAfter($Data) Local $NewDate = $Data $NewDate = _DateAdd('d', 1, $NewDate) MsgBox(4096, "", "Today + 1 days:" & StringRight($NewDate,2) & '/' & StringMid($NewDate,6,2) & '/' & StringLeft($NewDate,4)) EndFuncI don't know how to make that the new modified date keep being added to the previous so I can make day 20, day 21, 22 ,23 and so on making the game run all the days, the months and the years from the date I set at the beginning....Thanks for helpEDIT. I think I solved this. Edited May 12, 2010 by niubbone
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now