Question: NAME[3] STRING ACTOR VARIABILE

Non-platform specific questions.

Question: NAME[3] STRING ACTOR VARIABILE

Postby equinox » Thu Mar 12, 2009 5:55 pm

HI at ALL,

I do not know how to use this var to give a name. I do:
NAME[0] = " EROE";
NAME[1] = " EROE1";
NAME[2] = " EROE2";

TEXT.text = NAME[1];...but not work.
------------------------
NAME: string actor var
ATTORE[0] = CreateActor("EROE_1", "EROE_1", "(none)", "(none)", 0, -1, true);
ATTORE[0]->NAME = "heroe";<---not work:



Please,help me with this code?

Tnk1000.
User avatar
equinox
 
Posts: 118
Joined: Tue Jan 29, 2008 3:38 pm
Score: 0 Give a positive score

Re: Question: NAME[3] STRING ACTOR VARIABILE

Postby skydereign » Thu Mar 12, 2009 11:48 pm

Okay, you can't use math signs with strings. If you want an outside event to change the text of an actor, you would need to do this
Code: Select all
strcpy(TEXT.text, NAME[0]);

I can't tell if there was another question. If there was just ask.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Question: NAME[3] STRING ACTOR VARIABILE

Postby equinox » Fri Mar 13, 2009 1:23 pm

NAME: string actor var
ATTORE[0] = CreateActor("EROE_1", "EROE_1", "(none)", "(none)", 0, -1, true);
ATTORE[0]->NAME = "heroe";<---not work:<----------WHY ??

Qustion #2
Actor *ATTORE[3];
NOM = Actor String variable

strcpy(ATTORE[0]->NOM,"Leone");
sprintf(WRITE1.text,ATTORE[0]->NOM);<-----WORK

...BUT...
strcpy(ATTORE[1]->NOM,"Joe");
sprintf(WRITE1.1.text,ATTORE[0]->NOM);<-----NOT WORK

WRITE1.1...the error?

for moment...Tnk1000 for help me.
Score: 26 += 1;
User avatar
equinox
 
Posts: 118
Joined: Tue Jan 29, 2008 3:38 pm
Score: 0 Give a positive score

Re: Question: NAME[3] STRING ACTOR VARIABILE

Postby skydereign » Sat Mar 14, 2009 12:11 am

Okay, string setting should be done by strcpy. This is just how it is.
Code: Select all
strcpy(ATTORE[0]->NAME,"heroe");

This string you used is a char*? That would be my preference.

You cannot do actor.1.variable. This is not allowed, instead you can use the getclone function, I believe, or some derivative. What are you trying to do? Is WRITE1 an actor? If so, I believe there is a better way to do what you want it to do, but I can't tell with the given information. Anyway, you would just pass it a pointer to the actor struct of WRITE1, and point it to text.
This is Cleve Blakemore's version of the getClone derivatives. It would go into global code;
Code: Select all
Actor * getCloneIdx (const char *cname, int cindex)    //g_GetCloneByIndex, its original name
{
    char buffer[50];

    sprintf(buffer,"%s.%i",cname,cindex);

    return(getclone(buffer));
}

Then you call it to get the Actor* to WRITE1. So it would be called as such,
Code: Select all
sprintf(getCloneIdx(WRITE1, 1)->text ,ATTORE[0]->NOM);

Or if you are using this multiple times in script, you could create temp Actor*, set that to the getCloneIdx, and use that. I believe that answers your question.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Question: NAME[3] STRING ACTOR VARIABILE

Postby equinox » Sat Mar 14, 2009 6:24 am

skydereign wrote:Okay, string setting should be done by strcpy. This is just how it is.
Code: Select all
strcpy(ATTORE[0]->NAME,"heroe");


This code above is what I needed

This string you used is a char*? That would be my preference.

Yes, I used this string as a char. I also prefer.

You cannot do actor.1.variable. This is not allowed,

yes, in fact I saw that i can not use in this mode. :o(

instead you can use the getclone function, I believe, or some derivative.

What are you trying to do? Is WRITE1 an actor?

Y, WRITE1 IS actor. used to print the name of hero.

If so, I believe there is a better way to do what you want it to do, but I can't tell with the given information. Anyway, you would just pass it a pointer to the actor struct of WRITE1, and point it to text.
This is Cleve Blakemore's version of the getClone derivatives. It would go into global code;
Code: Select all
Actor * getCloneIdx (const char *cname, int cindex)    //g_GetCloneByIndex, its original name
{
    char buffer[50];

    sprintf(buffer,"%s.%i",cname,cindex);

    return(getclone(buffer));
}

Then you call it to get the Actor* to WRITE1. So it would be called as such,
Code: Select all
sprintf(getCloneIdx(WRITE1, 1)->text ,ATTORE[0]->NOM);

Or if you are using this multiple times in script, you could create temp Actor*, set that to the getCloneIdx, and use that. I believe that answers your question.


yes, you answered me in an excellent way to my question.

Tnk1000.
Score ++

P.S.:
I just tried the functions,,, but by mistake. I do not understand where is wrong.
Attachments
Image1.png
User avatar
equinox
 
Posts: 118
Joined: Tue Jan 29, 2008 3:38 pm
Score: 0 Give a positive score

Re: Question: NAME[3] STRING ACTOR VARIABILE

Postby skydereign » Sat Mar 14, 2009 9:27 pm

Yeah, sorry. I wrote it in wrong. It is asking for a const char*.
Code: Select all
sprintf(getCloneIdx("WRITE1", 1)->text ,ATTORE[0]->NOM);

That should work.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Question: NAME[3] STRING ACTOR VARIABILE

Postby equinox » Sun Mar 15, 2009 11:22 am

Tnk,

sprintf(getCloneIdx("WRITE1", 1)->text ,ATTORE[0]->NOM);<----WORK.
...but..

HP = 50; Actor var
sprintf(getCloneIdx("WRITE1", 1)->textnumber ,ATTORE[0]->HP);<----NOT WORK.

sprintf(getclone("WRITE1.0")->text,ATTORE[0]->NOM);<---WORK
sprintf(getclone("WRITE1.0")->textnumber,ATTORE[0]->HP);<---NOT WORK


you can help me yet,please?
Last edited by equinox on Sun Mar 15, 2009 11:40 am, edited 1 time in total.
User avatar
equinox
 
Posts: 118
Joined: Tue Jan 29, 2008 3:38 pm
Score: 0 Give a positive score

Re: Question: NAME[3] STRING ACTOR VARIABILE

Postby skydereign » Sun Mar 15, 2009 11:33 am

Can you give me the error? It could be as simple as this, we shall see...
Code: Select all
sprintf(getCloneIdx("WRITE1", 1)->textNumber ,ATTORE[0]->HP);

The difference is textNumber. Originally you had it written as textnumber. If this does not work, then give me the error.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Question: NAME[3] STRING ACTOR VARIABILE

Postby equinox » Sun Mar 15, 2009 11:44 am

Yes tnk, the error is:

STAMPO1 == WRITE1


sprintf(getclone("WRITE1.0")->text,ATTORE[0]->NOM);<---WORK
sprintf(getclone("WRITE1.0")->textnumber,ATTORE[0]->HP);<---NOT WORK
Attachments
Image1.png
User avatar
equinox
 
Posts: 118
Joined: Tue Jan 29, 2008 3:38 pm
Score: 0 Give a positive score

Re: Question: NAME[3] STRING ACTOR VARIABILE

Postby skydereign » Sun Mar 15, 2009 11:54 am

If these are not char* or other strings, it is best not to treat that as such. You can do the same thing by doing this.
Code: Select all
getCloneIdx("WRITE1", 1)->textNumber=ATTORE[0]->HP;

Since these are both dealing with ints/doubles, they can be equalized with math symbols.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Question: NAME[3] STRING ACTOR VARIABILE

Postby equinox » Sun Mar 15, 2009 12:33 pm

Tnk1000.

This solution ...work fine.

many thanks to you for help.

Score ++
User avatar
equinox
 
Posts: 118
Joined: Tue Jan 29, 2008 3:38 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron