Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Update GetCurrentTime() as a Text Object?

Author
Message
GunnerJnr
AGK Developer
8
Years of Service
User Offline
Joined: 30th Nov 2015
Location: Bridgwater, UK
Posted: 4th Jan 2017 22:35 Edited at: 4th Jan 2017 23:04
Hi all,

It's been some time since I have done any programming in AGK2 and I think my brain has just melted. I am probably being very dumb here but I am looking for a way to update GetCurrentTime() as a text object.. If this is possible at all, so I can display the time in the app as I think it will be a nice little feature.

I guess it needs to go into the main loop so it can update. However, I can only see the print command available which updates the GetCurrentTime(), if I add the CreateText() command to the do loop it just moans at me that the index id already exists (as it is trying to create the same object every frame), so I tried a conditional such as if GetTextExists(CURRENT_TIME_INDEX) = 1 /* create the text etc.. */ endif but this again leaves me in the same boat where the time doesn't update.

Any help on this would be greatly appreciated.

Here is what I have so far:



Kind Regards
GunnerJnr
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 4th Jan 2017 23:13 Edited at: 4th Jan 2017 23:15
a#=Timer () //before loop
if Timer()-a# => 1.0
Tick Tack
SetTextString( iTextIndex, "new time")
a#=Timer ()
endif
AGK (Steam) V2.0.22 : Windows 10 Pro 64 Bit : AMD (16.12.1) Radeon R7 265 : Mac mini OS Sierra (10.12)
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 5th Jan 2017 09:08 Edited at: 5th Jan 2017 09:09
SetTextString( CURRENT_TIME_INDEX, GetCurrentTime() )
GunnerJnr
AGK Developer
8
Years of Service
User Offline
Joined: 30th Nov 2015
Location: Bridgwater, UK
Posted: 5th Jan 2017 09:14 Edited at: 5th Jan 2017 09:49
Wow can't believe I overlooked SetTextString() now I feel silly, thanks Mobbius , also thanks Markus. I think I'll recap the API docs to familiarise myself again.

Here it is working in all its glory. (See attached gif)

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-09-29 21:26:31
Your offset time is: 2024-09-29 21:26:31