Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Request How to make several keys in on map
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#4
RE: How to make several keys in on map

(08-17-2011, 04:27 AM)Khan Wrote: Im a complete nooby to scripting, so, I have no clue half of wat you said, lol ;(

Tongue

As you should already know, AddUseItemCallback() calls a function upon using an item on another entity. In your case this is FUNCTION(). The variables passed to this function contain the names of the entities that were interacted with. In your case, asItem would contain the name of the key; asEntity would contain the name of the door. A conditional statement is a statement that requires its expression (that which is inside its parentheses) to evaluate to true (boolean) before executing the code in the code block below it. The if statement is therefore a conditional statement.

In your FUNCTION() function, you would place conditional statements to check whether or not asItem contains the name of the key used and whether or not asEntity contains the name of the door you want the key to work on. This allows the same function to be used for multiple keys. It would also allow for the same key to be used on multiple doors.

Example:
void FUNCTION(string &in asItem, string &in asEntity)
{
     if (asItem == "chamberkey" && asEntity == "chamberdoor")
     {
          // unlock door and remove key from inventory
     }

     else if (asItem == "cellarkey" && asEntity == "cellardoor")
     {
          // unlock door and remove key from inventory
     }
}

In the level editor you would name the keys and doors accordingly. If you want any key to be used on any door, then remove the second half of the if statement's expression and don't remove the key from inventory.

Tutorials: From Noob to Pro
(This post was last modified: 08-17-2011, 05:07 AM by Your Computer.)
08-17-2011, 05:00 AM
Website Find


Messages In This Thread
How to make several keys in on map - by Khan - 08-17-2011, 03:51 AM
RE: How to make several keys in on map - by Khan - 08-17-2011, 04:27 AM
RE: How to make several keys in on map - by Your Computer - 08-17-2011, 05:00 AM
RE: How to make several keys in on map - by Khan - 08-17-2011, 01:16 PM
RE: How to make several keys in on map - by Khan - 08-17-2011, 09:01 PM



Users browsing this thread: 2 Guest(s)