Wank
Junior Member
Posts: 28
Threads: 11
Joined: May 2013
Reputation:
0
Help with combining scripts
I can't put these together and get them to work. First script-
void OnStart()
{
AddEntityCollideCallback("Player", "scr_spawnEnemy1", "SpawnEnemy1", true, 1);
}
void SpawnEnemy1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Enemy1", true);
AddEnemyPatrolNode("Enemy1", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_6", 0, "");
}
Second script-
void OnStart()
{
AddUseItemCallback("", "key_study_one", "mansion_3", "unlock", true);
}
void unlock(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(door, false, true);
PlaySoundAtEntity("", "unlock_door", door, 0, false);
RemoveItem(item);
}
05-24-2013, 01:22 AM
Tomato Cat
Senior Member
Posts: 287
Threads: 2
Joined: Sep 2012
Reputation:
20
RE: Help with combining scripts
Are you getting any sort error?
05-24-2013, 01:34 AM
PutraenusAlivius
Posting Freak
Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation:
119
RE: Help with combining scripts
Did you get any errors? In case you do, I put the whole thing in one script.
Spoiler below!
void OnStart()
{
AddEntityCollideCallback("Player", "scr_spawnEnemy1", "SpawnEnemy1", true, 1);
AddUseItemCallback("", "key_study_one", "mansion_3", "unlock", true);
}
void SpawnEnemy1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Enemy1", true);
AddEnemyPatrolNode("Enemy1", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_6", 0, "");
}
void unlock(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door", false, true);
PlaySoundAtEntity("", "unlock_door", "door", 0, false);
RemoveItem("item");
}
"Veni, vidi, vici."
"I came, I saw, I conquered."
05-24-2013, 02:00 AM
Wank
Junior Member
Posts: 28
Threads: 11
Joined: May 2013
Reputation:
0
RE: Help with combining scripts
(05-24-2013, 01:34 AM) Tomato Cat Wrote: Are you getting any sort error?
Huh, I was, now i'm not. Even though I am not getting an error, it still doesn't work.
(05-24-2013, 02:00 AM) JustAnotherPlayer Wrote: Did you get any errors? In case you do, I put the whole thing in one script.
Spoiler below!
void OnStart()
{
AddEntityCollideCallback("Player", "scr_spawnEnemy1", "SpawnEnemy1", true, 1);
AddUseItemCallback("", "key_study_one", "mansion_3", "unlock", true);
}
void SpawnEnemy1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Enemy1", true);
AddEnemyPatrolNode("Enemy1", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_6", 0, "");
}
void unlock(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door", false, true);
PlaySoundAtEntity("", "unlock_door", "door", 0, false);
RemoveItem("item");
}
Huh, I was, now i'm not. Even though I am not getting an error, it still doesn't work.
(This post was last modified: 05-24-2013, 03:21 AM by Wank .)
05-24-2013, 03:20 AM
Tomato Cat
Senior Member
Posts: 287
Threads: 2
Joined: Sep 2012
Reputation:
20
RE: Help with combining scripts
JustAnotherPlayer made some adjustments for you:
PlaySoundAtEntity ( "" , "unlock_door" , "door" , 0 , false ); //This is proper. "Quotations" denote a string argument. JAP fixed this for you. //You had this: PlaySoundAtEntity ( "" , "unlock_door" , door , 0 , false ); //"door" is not a string. It was also like this in the SetSwing door function.
Also, right here:
RemoveItem ( "item" ); //If you're trying to use the asItem parameter to remove said item, it would be asItem rather than "item" RemoveItem ( asItem ); //This is correct
I'm *guessing* this is what's wrong. I dunno. What specifically is happening?
Make sure your level editor names match etcetc.
(This post was last modified: 05-24-2013, 03:29 AM by Tomato Cat .)
05-24-2013, 03:26 AM
Wank
Junior Member
Posts: 28
Threads: 11
Joined: May 2013
Reputation:
0
RE: Help with combining scripts
(05-24-2013, 01:34 AM) Tomato Cat Wrote: Are you getting any sort error?
I am getting an error that says "FATAL ERROR (16, 20) :Expected identifier
void OnStart()
{
AddEntityCollideCallback("Player", "scr_spawnEnemy1", "SpawnEnemy1", true, 1);
}
void SpawnEnemy1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Enemy1", true);
AddEnemyPatrolNode("Enemy1", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_6", 0, "");
}
AddUseItemCallback("", "key_study_one", "mansion_3", "UseKeyOnDoor" , true);
void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door", "door", 0, false);
RemoveItem(asItem);;
}
void OnLeave ()
{
}
05-24-2013, 12:06 PM
PutraenusAlivius
Posting Freak
Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation:
119
RE: Help with combining scripts
Spoiler below!
void OnStart()
{
AddEntityCollideCallback("Player", "scr_spawnEnemy1", "SpawnEnemy1", true, 1);
AddUseItemCallback("", "key_study_one", "mansion_3", "UseKeyOnDoor", true);
}
void SpawnEnemy1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Enemy1", true);
AddEnemyPatrolNode("Enemy1", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_6", 0, "");
}
void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_3", 0, false);
RemoveItem(asItem);
}
"Veni, vidi, vici."
"I came, I saw, I conquered."
05-24-2013, 12:44 PM
Wank
Junior Member
Posts: 28
Threads: 11
Joined: May 2013
Reputation:
0
RE: Help with combining scripts
(05-24-2013, 12:44 PM) JustAnotherPlayer Wrote:
Spoiler below!
void OnStart()
{
AddEntityCollideCallback("Player", "scr_spawnEnemy1", "SpawnEnemy1", true, 1);
AddUseItemCallback("", "key_study_one", "mansion_3", "UseKeyOnDoor", true);
}
void SpawnEnemy1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Enemy1", true);
AddEnemyPatrolNode("Enemy1", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("Enemy1", "PathNodeArea_6", 0, "");
}
void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_3", 0, false);
RemoveItem(asItem);
}
Thank you, this worked!
05-24-2013, 11:09 PM
Wooderson
Posting Freak
Posts: 2,460
Threads: 25
Joined: Dec 2011
Reputation:
52
RE: Help with combining scripts
What a nice name xD
05-24-2013, 11:18 PM