Kyle
Posting Freak
Posts: 911
Threads: 36
Joined: Sep 2010
Reputation:
7
|
Another Scripting Problem...
I once again tried to combine 2 scripts and it failed at working. I tried to make a servant grunt to become active when you went into an area. So I added: AddEntityCollideCallback("Player" , "ScriptArea_1" , "CollideRoomTwo" , true, 1); AND void SetEntityActive(servant_grunt, true);
Full script:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "CollideRoomTwo" , true, 1);
AddUseItemCallback("", "Mansion Key", "MansionDoor", "UsedKeyOnDoor", true);
}
void SetEntityActive(servant_grunt, true);
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("MansionDoor", false, true);
PlaySoundAtEntity("", "unlock_door" , "MansionDoor", 0, false);
RemoveItem("Mansion Key");
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
I also wanted to point out that I DO NOT want the grunt to become active when I try to open the door... Please try to keep it seperate.
(This post was last modified: 10-10-2010, 05:20 PM by Kyle.)
|
|
10-10-2010, 05:18 PM |
|
Entih
Junior Member
Posts: 47
Threads: 4
Joined: Sep 2010
Reputation:
0
|
RE: Another Scripting Problem...
Hmm, and where might the function for your callback be? You add it, but you never make it do anything, you see. As such, the activation for the grunt is just kind of sitting out there in the aether where it will never be performed.
You see, anything outside the brackets of a function like 'void OnStart()' and such don't quite do anything. Some variables can be made, but its nothing quite functional for what you want. That's why you create the callback, to create a function which is used when one thing (player) touches another (your area).
A collide function is called like so, and the things to occur go within the brackets:
void CollideFunction(string &in asParent, string &in asChild, int alState)
{
[Stuff That Happens Goes Here...]
}
|
|
10-10-2010, 05:37 PM |
|
Kyle
Posting Freak
Posts: 911
Threads: 36
Joined: Sep 2010
Reputation:
7
|
RE: Another Scripting Problem...
So it should be like this?
////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "Mansion Key", "MansionDoor", "UsedKeyOnDoor", true);
}
void SetEntityActive(servant_grunt, true);
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("MansionDoor", false, true);
PlaySoundAtEntity("", "unlock_door" , "MansionDoor", 0, false);
RemoveItem("Mansion Key");
}
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "CollideRoomTwo" , true, 1);
void CollideFunction(string &in asParent, string &in asChild, int alState)
}
void SetEntityActive(servant_grunt, true);
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
|
|
10-10-2010, 05:54 PM |
|
Chilton
Member
Posts: 138
Threads: 9
Joined: Sep 2010
Reputation:
0
|
RE: Another Scripting Problem...
Try this:
void OnStart()
{
AddUseItemCallback("", "Mansion Key", "MansionDoor", "UsedKeyOnDoor", true);
AddEntityCollideCallback("Player" , "ScriptArea_1" , "CollideRoomTwo" , true, 1);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("MansionDoor", false, true);
PlaySoundAtEntity("", "unlock_door" , "MansionDoor", 0, false);
RemoveItem("Mansion Key");
}
void CollideRoomTwo(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt", true);
}
void OnEnter()
{
}
void OnLeave()
{
}
If that doesnt work, its because im half asleep and mistyped. It should work though - Also, your getting the organisation and syntaxing wrong - Just compare your script to my ammended one
EDIT: This should work. I got no errors when i validated it just now
|
|
10-10-2010, 05:57 PM |
|
Frontcannon
Senior Member
Posts: 538
Threads: 10
Joined: Jul 2010
Reputation:
2
|
RE: Another Scripting Problem...
Please learn the syntax, the script you just posted will just make your level crash D:
╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
|
|
10-10-2010, 05:58 PM |
|
Kyle
Posting Freak
Posts: 911
Threads: 36
Joined: Sep 2010
Reputation:
7
|
RE: Another Scripting Problem...
Nope, didn't work. The error message said that "servant_grunt is not declared."
|
|
10-10-2010, 06:05 PM |
|
Chilton
Member
Posts: 138
Threads: 9
Joined: Sep 2010
Reputation:
0
|
RE: Another Scripting Problem...
(10-10-2010, 06:05 PM)Kyle Wrote: Nope, didn't work. The error message said that "servant_grunt is not declared." Sorry
Use it now - I forgot to put markers around it. Its now edited in, and if thats the only error, it will work
|
|
10-10-2010, 06:07 PM |
|
Frontcannon
Senior Member
Posts: 538
Threads: 10
Joined: Jul 2010
Reputation:
2
|
RE: Another Scripting Problem...
(10-10-2010, 06:07 PM)Chilton Wrote: (10-10-2010, 06:05 PM)Kyle Wrote: Nope, didn't work. The error message said that "servant_grunt is not declared." Sorry
Use it now - I forgot to put markers around it. Its now edited in, and if thats the only error, it will work
I somehow missed your post, I was referring to Kyle's post
╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
|
|
10-10-2010, 06:09 PM |
|
Chilton
Member
Posts: 138
Threads: 9
Joined: Sep 2010
Reputation:
0
|
RE: Another Scripting Problem...
(10-10-2010, 06:09 PM)Frontcannon Wrote: (10-10-2010, 06:07 PM)Chilton Wrote: (10-10-2010, 06:05 PM)Kyle Wrote: Nope, didn't work. The error message said that "servant_grunt is not declared." Sorry
Use it now - I forgot to put markers around it. Its now edited in, and if thats the only error, it will work
I somehow missed your post, I was referring to Kyle's post
I figured, based on the buffer between you typing and me posting - Funny thing is you were correct by accident :p
|
|
10-10-2010, 06:11 PM |
|
Kyle
Posting Freak
Posts: 911
Threads: 36
Joined: Sep 2010
Reputation:
7
|
RE: Another Scripting Problem...
Frostcannon. Actually Chilton really messed up the syntax. Luckly it works, but the monster spawns before I reach the trigger area...
|
|
10-10-2010, 06:12 PM |
|
|