LUA - Checking the order of kills

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
Fiodis
Master of the Force
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

Post by Fiodis »

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?
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: LUA - Checking the order of kills

Post by [RDH]Zerted »

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
Post Reply