LUA - Checking the order of kills
Moderator: Moderators
- Fiodis
- Master of the Force

- Posts: 4145
- Joined: Wed Nov 12, 2008 9:27 pm
- Projects :: Rannoch + Tientia + Tools Programming
LUA - Checking the order of kills
How would you go about checking the order in which the character damages or kills something? For instance, say you want to make a keypad with a lock, and there's ten buttons (0 - 9), and you have a five-number activation key which the character types out by shooting the appropriate buttons. How could you check in which order he shoots them?
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: LUA - Checking the order of kills
There are lots of ways to do it. Heres one way:
* Store your key in a table: key[1] = ''o"; key[2]=''p"; key[3]="e"; key[4]=''n";
* Have a variable to keep track of how much of the key has been entered: entered = 1
* When a character/button is destroyed, see if it matches the value in the table: if key[entered] == destoryedChar then...
** If they don't match, then reset the 'entered sequence': entered = 1
** If they do match, then move on to the next key: entered += 1
*** After the +=1, you will need to see if the entire key has been entered: if entered > table.getn(key) then...
**** If so, then the correct key has been entered and you open the door and reset everything
* Store your key in a table: key[1] = ''o"; key[2]=''p"; key[3]="e"; key[4]=''n";
* Have a variable to keep track of how much of the key has been entered: entered = 1
* When a character/button is destroyed, see if it matches the value in the table: if key[entered] == destoryedChar then...
** If they don't match, then reset the 'entered sequence': entered = 1
** If they do match, then move on to the next key: entered += 1
*** After the +=1, you will need to see if the entire key has been entered: if entered > table.getn(key) then...
**** If so, then the correct key has been entered and you open the door and reset everything
