Page 1 of 1

Question: NAME[3] STRING ACTOR VARIABILE

PostPosted: Thu Mar 12, 2009 5:55 pm
by equinox
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.

Re: Question: NAME[3] STRING ACTOR VARIABILE

PostPosted: Thu Mar 12, 2009 11:48 pm
by skydereign
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.

Re: Question: NAME[3] STRING ACTOR VARIABILE

PostPosted: Fri Mar 13, 2009 1:23 pm
by equinox
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;

Re: Question: NAME[3] STRING ACTOR VARIABILE

PostPosted: Sat Mar 14, 2009 12:11 am
by skydereign
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.

Re: Question: NAME[3] STRING ACTOR VARIABILE

PostPosted: Sat Mar 14, 2009 6:24 am
by equinox
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.

Re: Question: NAME[3] STRING ACTOR VARIABILE

PostPosted: Sat Mar 14, 2009 9:27 pm
by skydereign
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.

Re: Question: NAME[3] STRING ACTOR VARIABILE

PostPosted: Sun Mar 15, 2009 11:22 am
by equinox
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?

Re: Question: NAME[3] STRING ACTOR VARIABILE

PostPosted: Sun Mar 15, 2009 11:33 am
by skydereign
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.

Re: Question: NAME[3] STRING ACTOR VARIABILE

PostPosted: Sun Mar 15, 2009 11:44 am
by equinox
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

Re: Question: NAME[3] STRING ACTOR VARIABILE

PostPosted: Sun Mar 15, 2009 11:54 am
by skydereign
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.

Re: Question: NAME[3] STRING ACTOR VARIABILE

PostPosted: Sun Mar 15, 2009 12:33 pm
by equinox
Tnk1000.

This solution ...work fine.

many thanks to you for help.

Score ++