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


Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another Scripting Problem...
Entih Offline
Junior Member

Posts: 47
Threads: 4
Joined: Sep 2010
Reputation: 0
#15
RE: Another Scripting Problem...

Since the previous poster laid out the script, let me see if I can help you with syntax, so you become more efficient with your self-scripting. I've been wanting to write a set of tutorials for scripting, but have been too busy, so this will have to do for now.

Lets look at your item use script:

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("MansionDoor", false, true);
PlaySoundAtEntity("", "unlock_door" , "MansionDoor", 0, false);
RemoveItem("Mansion Key");
}

When you called 'AddUseItemCallback' in OnStart(), you said "Whenever the map FIRST runs, make it so whenever that item is used on this door, it does the function 'UsedKeyOnDoor'.

Whenever you see brackets, { }, it means all the stuff between them belong to the function or line that came before them. So don't really think of it as combining scripts or such, think of it as a bunch of chunks of script which do different things.

As such, when the key is used on the door, it skips down the code until it finds that 'void UsedKeyOnDoor(...)'. It then looks at the parentheses and says "Okay, the item used was called 'key', so asItem becomes the name 'key'. Item used on was called 'door', so asEntity becomes the name 'door'."

It then goes into the brackets and performs the instructions line by line, until it hits the closing bracket. Or the keyword 'return', if you're getting a little complicated.

Collides work exactly the same way, just with a different function with different stuff in the parentheses. Take a look at the script provided by the previous poster and dissect it, say to yourself what each line means and what it does, as that tends to help.
10-10-2010, 06:38 PM
Find


Messages In This Thread
Another Scripting Problem... - by Kyle - 10-10-2010, 05:18 PM
RE: Another Scripting Problem... - by Entih - 10-10-2010, 05:37 PM
RE: Another Scripting Problem... - by Kyle - 10-10-2010, 05:54 PM
RE: Another Scripting Problem... - by Chilton - 10-10-2010, 05:57 PM
RE: Another Scripting Problem... - by Frontcannon - 10-10-2010, 05:58 PM
RE: Another Scripting Problem... - by Kyle - 10-10-2010, 06:05 PM
RE: Another Scripting Problem... - by Chilton - 10-10-2010, 06:07 PM
RE: Another Scripting Problem... - by Frontcannon - 10-10-2010, 06:09 PM
RE: Another Scripting Problem... - by Chilton - 10-10-2010, 06:11 PM
RE: Another Scripting Problem... - by Kyle - 10-10-2010, 06:12 PM
RE: Another Scripting Problem... - by Chilton - 10-10-2010, 06:13 PM
RE: Another Scripting Problem... - by Kyle - 10-10-2010, 06:15 PM
RE: Another Scripting Problem... - by Chilton - 10-10-2010, 06:17 PM
RE: Another Scripting Problem... - by Kyle - 10-10-2010, 06:24 PM
RE: Another Scripting Problem... - by Entih - 10-10-2010, 06:38 PM
RE: Another Scripting Problem... - by Kyle - 10-11-2010, 01:40 AM



Users browsing this thread: 1 Guest(s)