Changing Text Actor Text without Using MouseDown Event

You must understand the Game Editor concepts, before post here.

Changing Text Actor Text without Using MouseDown Event

Postby plinydogg » Thu Jun 01, 2006 8:04 pm

Hi everyone,

I've got a spaceship traveling to another planet and when it reaches its destination, I want to change all of the info displayed on screen so that it reflects the new planet's info.

I'm using the script editor to do this and I've encountered no problem changing the image but I can't seem to get the text actors to change their contents (neither the text property nor the textNumber property respond to my commands). I know the correct syntax for assigning numbers to text actors and for assigning text to text actors (using strcpy). Why isn't it working?

I read somewhere on the forum that this problem occurs with uninitialized string variables, but as far as I know, you can't initialize string variables in script. Right?

I also vaguely recall reading somewhere (but can't find it anymore) that you need a mousedown event in order to assign text to text actors. Is this true? If so, is there a workaround. Perhaps something using the char type?

Any help would be deeply appreciated!

P.S. If the workaround requires using the char type, it would be great if someone could explain the basics of using char, since I've never had to thusfar.
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Re: Changing Text Actor Text without Using MouseDown Event

Postby makslane » Thu Jun 01, 2006 9:48 pm

Please, show the whole code that you use for change the text.

plinydogg wrote:I also vaguely recall reading somewhere (but can't find it anymore) that you need a mousedown event in order to assign text to text actors. Is this true?


No, is not
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby plinydogg » Thu Jun 01, 2006 10:15 pm

Makslane,

Here's the code I use (it's pretty long, so I didn't include all of it, but if you really want me to, I will, just let me know):

void showPlanetInfo(int i)
{
Actor *p = planets[i];
strcpy(textName.text, p->planetName);
if(p->climate == 1)
{
ChangeAnimation("climatePicture", "climateDesert", NO_CHANGE);
}
textPopulationMax.textNumber = p->populationMax;
textPopulationCurrent.textNumber = p->population;
textProduction.textNumber = p->planetProduction;
textResearch.textNumber = p->planetResearch;
}
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby makslane » Thu Jun 01, 2006 10:44 pm

Changing any of the internal Actor's variables (x, y, xscreen, yscreen, ...) has no effect on the Global Code.

To works, you must put some reference in the caller Script Editor (even a comment):

//textName
//textPopulationMax
//textPopulationCurrent
//textProduction
//textResearch

showPlanetInfo();
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby plinydogg » Thu Jun 08, 2006 5:08 pm

Makslane,

I still can't get it to work for some reason. Where exactly do I need to put the comments?

sorry for being daft!
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby makslane » Thu Jun 08, 2006 5:35 pm

You need put the references before call the funcion. In your case, when you call showPlanetInfo() function.

Can you post your current script code that call the showPlanetInfo() funcion?
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby plinydogg » Thu Jun 08, 2006 6:28 pm

Here it is. As you can see, showPlanetInfo() is called from within another function in global code:

int checkLandingAbility(int j)
{
int dist = distance(playerShips[j]->x, playerShips[j]->y, playerShips[j] -> destx, playerShips[j] -> desty);
int planetToIdentify = playerShips[j]->pDestNum;
if(dist < playerSpeed)
{
playerShips[j]->shipInMotion = 0;
planets[planetToIdentify]->explored = 1;
showPlanetInfo(playerShips[j]->pDestNum);
return 1;
}
else
{
return 0;
}
}
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby makslane » Thu Jun 08, 2006 6:49 pm

In this case you need put, in the caller code:

//textName
//textPopulationMax
//textPopulationCurrent
//textProduction
//textResearch

checkLandingAbility();
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby plinydogg » Thu Jun 08, 2006 7:09 pm

Thanks for the speedy reply. Unfortunately, I still can't get it to work. I should have mentioned, perhaps, that the checkLandingAbility() function is called from a for loop within the nextTurn() function. Just to make sure that it didn't work, I copied and pasted the comment lines into every scope level (e.g., within the for loop, within the nextTurn() function, within everything else), but I still had no luck.
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby makslane » Fri Jun 09, 2006 1:32 am

Just put the references in the Script Editor, not in global code
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron