How to access text of created clone through sprintf

Game Editor comments and discussion.

How to access text of created clone through sprintf

Postby lverona » Sun Aug 21, 2016 7:06 pm

One can create a created clone like this:

Code: Select all
CreateActor("stats_num", "icon", "(none)", "(none)", view.x+110, view.y+294, true);
getclone(stats_num.clonename)->textNumber=minutes;


So here I have no problems writing to textNumber.

However, I don't know how to write to text. I tried this, but it doesn't work. Any ideas?

Code: Select all
sprintf(getclone(stats_num.clonename)->text,"%d:%02d",minutes,sec);
lverona
 
Posts: 221
Joined: Tue Apr 24, 2012 11:54 am
Score: 1 Give a positive score

Re: How to access text of created clone through sprintf

Postby skydereign » Thu Aug 25, 2016 10:53 pm

That works for me. Do you have multiple stats_num actors?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: How to access text of created clone through sprintf

Postby lverona » Fri Aug 26, 2016 9:12 pm

Yes, I do. Multiple. Basically, the idea is to quickly generate text, without having to create several different actors beforehand with set text. So I want to create it on the fly. No problem with numbers, but with text it is a nightmare.
lverona
 
Posts: 221
Joined: Tue Apr 24, 2012 11:54 am
Score: 1 Give a positive score

Re: How to access text of created clone through sprintf

Postby skydereign » Mon Aug 29, 2016 6:43 am

If you have multiple then stats_num.clonename will only get you the clone with the highest cloneindex. Can you check if the setting text is working on that clone? If you want to target specific ones you'll need to use a getclone2 function.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest