Jump to content

Photo

Assigning IDs


  • Please log in to reply
3 replies to this topic

#1 grayswandir

grayswandir

    semi-genius

  • Members

Posted 31 May 2013 - 10:03 AM

Never lose track of what's what again. Untested, but it's so simple I'm fairly sure it works. I'll let you know if I run into any bugs once I start using it.
Code
Edit:
A minor bug that nobody will ever run into, seriously don't bother reading this

Edit 2: I got around to using this, just fixing some typos.

Edited by grayswandir, 01 June 2013 - 11:52 AM.


#2 Avaro

Avaro

    >w<

  • Members

Posted 31 May 2013 - 10:11 AM

Can you explain for what this can be used for? For these people like me, who are still scripting beginners. :D



#3 grayswandir

grayswandir

    semi-genius

  • Members

Posted 31 May 2013 - 10:23 AM

So you make an enemy, right? There's already 4 on screen, so it ends up being the 5th one. To get at it you say
npc myEnemy = Screen->LoadNPC(5);
But all of sudden, the player kills enemies 2 and 3. Your enemy 5 is now enemy 3. So how do you get at it?

Like So:
int myEnemyId = GetId(myEnemy);
// ... Later
npc myEnemy = FindNPC(myEnemyId);
Basically, it's a way to keep track of what's what when the only way to get at something is with Screen->LoadWhatever(aConstantlyChangingIndex). And you can do it with NPCs, Items, weapons, etc.

Is that clear?

Edited by grayswandir, 31 May 2013 - 10:25 AM.

  • Hoff123 likes this

#4 Avaro

Avaro

    >w<

  • Members

Posted 31 May 2013 - 12:41 PM

Oh I see. This makes things a lot easier!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users