Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,089 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Creating dynamic text and panel #437574
02/19/14 21:15
02/19/14 21:15
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
I am trying to create a dynamic TEXT and PANEL that shows up every time an enemy gets hit, so that the TEXT/PANEL shows the TITLE of the enemy, along with that enemy's HEALTH number. I want this TEXT/PANEL to remain on the screen for a certain amount of time, like 10 seconds after the enemy was last hit (and then disappear), or if a different enemy gets hit (to which I would want that enemy's own TEXT/PANEL to appear in place of the previous injured enemy's TEXT/PANEL.

This is the code so far that I have to try and do this:

Code:
// OgreFortress.c

...

STRING* title;

...

TEXT* enemy_health_txt =
{
	layer = 1;
	pos_x = 830;
	pos_y = 10;
	string (title, "'S HEALTH:");
	flags = CENTER_X | TRANSLUCENT | SHOW;
}

PANEL* pDisplay =
{
	digits (880, 10, 5, *, 1, my.HEALTH);
	
	flags = SHOW;
}

...

action ogre_action()
{
   ...

   title = "OGRE";
   my.HEALTH = 100;

   ...

   while(1)
   {
      
      ...
   }
}

action wizard_action()
{
   ...

   title = "WIZARD";
   my.HEALTH = 100;

   ...

   while(1)
   {
      
      ...
   }
}



When I run this script as it is, I receive this error:

< string ^title, "'S HEALTH:");>
OGREFORTRESS.C 5:2 (): Bad or missing parameter
.. 1.218 sec.
1 runtime errors
Error E355: Startup failure - any key to abort

If I tried replacing "title" in the "TEXT* enemy_health_txt" function with "my.title", I get this error:

< string ^my.title, "'S HEALTH:");>
OGREFORTRESS.C 5:2 (): Syntax error - my.title invalid character
.. 1.203 sec.
1 runtime errors
Error E355: Startup failure - any key to abort

Does anyone know what I am doing wrong in the "title" area of the TEXT function?

Keep in mind that I am at the very beginning stages of making this dynamic TEXT/PANEL. I am sure that once this "title" issue has been resolved, I will probably have more questions about making the full dynamic TEXT/PANEL functionality work, that I will use this forum chain for. Thank you.

Last edited by Ruben; 02/19/14 21:20.
Re: Creating dynamic text and panel [Re: Ruben] #437576
02/19/14 21:32
02/19/14 21:32
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
I tried placing this at the top of the program:

#define TITLE skill7

I then replaced:

title = "OGRE"; // in the ogre_action() function
and
title = "WIZARD"; // in the wizard_action() function

with:

my.TITLE = "OGRE"; // in the ogre_action() function
and
my.TITLE = "WIZARD"; // in the wizard_action() function

and I changed the TEXT function to look like this:

Code:
TEXT* enemy_health_txt =
{
	layer = 1;
	pos_x = 830;
	pos_y = 10;
	string (my.TITLE, "'S HEALTH:");
	flags = CENTER_X | TRANSLUCENT | SHOW;
}



I am now getting this error:

Error in 'line 1298:
Can not convert 'ARRAY' to 'FIXED'
< my.TITLE = "OGRE"; >
.
Error in 'line 1664:
Can not convert 'ARRAY' to 'FIXED'
< my.TITLE = "WIZARD"; >
........ 0.183 sec
Error compiling OGREFORTRESS.C
Error E355: Startup failure - any key to abort

Re: Creating dynamic text and panel [Re: Ruben] #437592
02/20/14 07:29
02/20/14 07:29
Joined: Apr 2005
Posts: 274
austria
Ascalon Offline
Member
Ascalon  Offline
Member

Joined: Apr 2005
Posts: 274
austria
hi, you must cast your "...." to a string. make it so:

my.TITLE = (STRING*)"OGRE";


my webside : www.ascalon.jimdo.de
Re: Creating dynamic text and panel [Re: Ascalon] #437633
02/20/14 18:37
02/20/14 18:37
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
"OGRE" is not a string and you shouldn't cast it to a string.

The error message exactly shows you the problem. You cannot assign a char array to a var.


Always learn from history, to be sure you make the same mistakes again...

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1