Getting the last clone?

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

Getting the last clone?

Postby ikarus » Fri Aug 19, 2011 9:10 am

Making a health bar where an actor is made for each health gained and the last clone is destroyed for each hp lost. Problem is DestroyActor needs a string. Now I'm trying to get my head around the deadly low level C code I've never had to deal with before. After some googleing this is what I got.

Code: Select all
int index = ActorCount("HP");
index -= 1;
char buffer[255];
char name[255] = "HP."
buffer = (char)index;
name = strcat(name, buffer);
DestroyActor(name);

It gives an error of something like "cannot convert from 'char' to 'ARY[255]char'
Can someone please tell me what I'm doing wrong? Or even better please tell me there's an easier way to do this???
>>>>>>>>>>>>>>>>>>>>> http://www.code1011.com <<<<<<<<<<<<<<<<<<<<<<<
ikarus
 
Posts: 143
Joined: Fri Aug 12, 2011 3:06 am
Score: 11 Give a positive score

Re: Getting the last clone?

Postby skydereign » Fri Aug 19, 2011 12:27 pm

Well, not sure why you need to create actors, as using an animation for that is much easier (like an animated health bar), but to destroy the last clone, assuming you only ever destroy the last clone (so essentially only this code will destroy the HP actor), you have to do something like this.
Code: Select all
char buffer[50];
sprintf(buffer, "HP.%d", ActorCount("HP")-1);
DestroyActor(buffer);


You keep talking about how low level c is, and while yes it is, gE c isn't all that low level. Pretty much everything is provided for you, with the exception of strings, which for almost all cases you can use sprintf.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Getting the last clone?

Postby ikarus » Fri Aug 19, 2011 4:06 pm

Thanks, been searching the script reference for "string" or "char", realized I should of searched for "text". And O.o... I was just kidding about the low level thing lol, if there weren't all of ge's helper functions I'd be in over my head lol. I'm primarily a high-level language programmer so I relish the thought, just saying at least C's syntax is copied so much so I at least already lmao

Oh and this is a game where you really have to watch your health closely, so I need a way to make it clear, think of it as kinda similar to the health system from zelda.
>>>>>>>>>>>>>>>>>>>>> http://www.code1011.com <<<<<<<<<<<<<<<<<<<<<<<
ikarus
 
Posts: 143
Joined: Fri Aug 12, 2011 3:06 am
Score: 11 Give a positive score

Re: Getting the last clone?

Postby skydereign » Fri Aug 19, 2011 7:44 pm

Yeah, I kind of figured you were joking, the statement though begged a response. Anyway, most games made with gE don't require any of the really low level stuff in c. But, since the health system is like zelda's then that method should work fine as the highest cloneindex will always match. That wouldn't be the case if you destroy one that is not the most recently created clone.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Getting the last clone?

Postby ikarus » Wed Aug 24, 2011 7:13 am

skydereign wrote:...Anyway, most games made with gE don't require any of the really low level stuff in c.


Yeah.... But then again the JustForTheHellOfItYouGottaTryIt fairy begs otherwise
>>>>>>>>>>>>>>>>>>>>> http://www.code1011.com <<<<<<<<<<<<<<<<<<<<<<<
ikarus
 
Posts: 143
Joined: Fri Aug 12, 2011 3:06 am
Score: 11 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron