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
Help with combining scripts
Wank Offline
Junior Member

Posts: 28
Threads: 11
Joined: May 2013
Reputation: 0
#1
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
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#2
RE: Help with combining scripts

Are you getting any sort error?
05-24-2013, 01:34 AM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#3
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
Find
Wank Offline
Junior Member

Posts: 28
Threads: 11
Joined: May 2013
Reputation: 0
#4
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
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#5
RE: Help with combining scripts

JustAnotherPlayer made some adjustments for you:

PHP Code: (Select All)
PlaySoundAtEntity("""unlock_door""door"0false);
//This is proper. "Quotations" denote a string argument. JAP fixed this for you.

//You had this:

PlaySoundAtEntity("""unlock_door"door0false);
//"door" is not a string. It was also like this in the SetSwing door function. 

Also, right here:

PHP Code: (Select All)
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
Find
Wank Offline
Junior Member

Posts: 28
Threads: 11
Joined: May 2013
Reputation: 0
#6
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
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#7
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."
(This post was last modified: 05-24-2013, 12:48 PM by PutraenusAlivius.)
05-24-2013, 12:44 PM
Find
Wank Offline
Junior Member

Posts: 28
Threads: 11
Joined: May 2013
Reputation: 0
#8
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
Find
Wooderson Offline
Posting Freak

Posts: 2,460
Threads: 25
Joined: Dec 2011
Reputation: 52
#9
RE: Help with combining scripts

What a nice name xD

[Image: luv.gif]
05-24-2013, 11:18 PM
Find




Users browsing this thread: 3 Guest(s)