1 registered members (AndrewAMD),
718
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
string for entity pointer ?
#282663
08/03/09 01:06
08/03/09 01:06
|
Joined: May 2009
Posts: 1,816 at my pc (duh)
darkinferno
OP
Serious User
|
OP
Serious User
Joined: May 2009
Posts: 1,816
at my pc (duh)
|
I'm looking at a new way of re scripting some elements of my game and i came up with the thought of:
ENTITY*object1;
ENTITY*object2;
STRING*obj_name="object1";
function blah()
{
set(obj_name,INVISIBLE);
}
but it doesn't work, the reason i wanted to do this was so i could use one short function and affect whichever entity i choose just by editing the STRING... any ideas on this?
|
|
|
Re: string for entity pointer ?
[Re: Gerrit]
#282681
08/03/09 07:25
08/03/09 07:25
|
Joined: May 2009
Posts: 1,816 at my pc (duh)
darkinferno
OP
Serious User
|
OP
Serious User
Joined: May 2009
Posts: 1,816
at my pc (duh)
|
Hi I don't know if that is possible but why don't you give the pointer as an argument when you call your function?
Gerrit noobish question but am not that great at all the programming elements yet, could you give me an example of this? i mean, i do have workarounds but i'm just looking an easier and faster way, it would also help in other areas...
|
|
|
Re: string for entity pointer ?
[Re: Xarthor]
#282711
08/03/09 11:13
08/03/09 11:13
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
Expert
|
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
Maybe I misunderstand what you're trying to do, but this should do the trick:
ENTITY* toSetInvisibleEnt;
void blah()
{
ENTITY* currentInvisible;
while(1)
{
if(currentInvisible != toSetInvisibleEnt){
reset(currentInvisible,INVISIBLE);
currentInvisible = toSetInvisibleEnt;
set(currentInvisible,INVISIBLE);
}
wait(1);
}
}
function blahaaa()
{
while(my)
{
//do your stuff
if(something or other is true)
toSetInvisibleEnt = my;
wait(1);
}
}
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: string for entity pointer ?
[Re: Xarthor]
#282733
08/03/09 12:49
08/03/09 12:49
|
Joined: Dec 2008
Posts: 271
Saturnus
Member
|
Member
Joined: Dec 2008
Posts: 271
|
To associate a pointer with a string you could also use a hash map (see GSHashmap by pegamode) or a similar data structure. This should be considered if you need many string lookups per frame, because a linear search is much slower.
|
|
|
|