Create an actor through script, and control him in game

Non-platform specific questions.

Create an actor through script, and control him in game

Postby Hblade » Thu Apr 05, 2012 2:45 pm

I'm going to be working on this as I wait for an answer, but I was wondering how I could do this type of function:
Code: Select all
makeText(msg, x, y, windowIndex, messageIndex);

The windowIndex is important, as is the messageindex. MessageIndex represents the cloneindex of the newly created text actor, but what I'm confarzed about is how in the world to change the text of the newly created actor, based on the variable "msg"

here's what I have so far
Code: Select all
NameBox("names.0", "Shop Keeper", 12, 0, 2, 0);
NameBox("names.1", "Another name :3", 125, 0, 2, 1);


This for some reason, makes names.0 over-lap names.1 and names.1 not to show up at all?
here's the completed code for everything
Code: Select all
void NameBox(char *textacotrname, char *texts, int X, int Y, int winIndex, int TextIndex)
{
    char tmp[256];
    int temp;
    Actor *a=getclone(textacotrname); //get the name of the text actor used
 
    if(!temp)
    {
        CreateActor("names", "icon", "(none)", "(none)", 0, 0, false);
        temp=1;
    }
 
    sprintf(a->text, texts); //a function used to set the text of a var to another
 
    a->xscreen=winX[winIndex]+10+X;
    a->yscreen=winY[winIndex]-2+Y;
 
 
 
    setpen(64, 25, 44, 0, a->height);
    moveto(a->xscreen, a->yscreen+(a->height/2));
    lineto(a->xscreen+a->width, a->yscreen+(a->height/2));
}



It works however if I actually clone the text actors.


AKR:
Nevermind the PM
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Create an actor through script, and control him in game

Postby tintran » Sat Apr 07, 2012 8:16 pm

not sure what you're trying to do exactly but did you know that you can do this
Code: Select all
  Actor *a;
  a = CreateActor("names","icon","(none)","(none)",0,0,false); //this will set a to point to the newly created actor.
  sprintf(a->text, "some text");
User avatar
tintran
 
Posts: 157
Joined: Fri Dec 24, 2010 1:34 am
Score: 30 Give a positive score

Re: Create an actor through script, and control him in game

Postby Hblade » Sun Apr 08, 2012 4:11 am

Thanks a bunch man =)!
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron