Frictional Games Forum (read-only)
[SCRIPT] Area script. Help needed ! - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Area script. Help needed ! (/thread-13163.html)

Pages: 1 2


Area script. Help needed ! - SpudroSpadre - 02-07-2012

Hi all !

So let's say I have a script area ( ScriptArea_1 for example ) on map "FirstFloor"
and I want it to get activated when I pick up a key (Key_1) on map GuestRooms.

So the ScriptArea_1 and the Key_1 are both on different maps.

I have no slightest idea what I need to do to get it work.
All help would be appreciated.

Thx. Cool


RE: Area script. Help needed ! - SilentStriker - 02-07-2012

(02-07-2012, 09:12 PM)SpudroSpadre Wrote: Hi all !

So let's say I have a script area ( ScriptArea_1 for example ) on map "FirstFloor"
and I want it to get activated when I pick up a key (Key_1) on map GuestRooms.

So the ScriptArea_1 and the Key_1 are both on different maps.

I have no slightest idea what I need to do to get it work.
All help would be appreciated.

Thx. Cool
Here's a script Smile

Code:
void OnStart()

{

    AddEntityCollideCallback("Player", "NAMEOFAREA", "HasKey_func",
false, 1); // This will activate every time the player enters the area.

}

void HasKey_func(string &in asParent, string &in asChild,  int alState)

{

    if(HasItem("NAMEOFKEY")) // Checks if the player has the key

    {

    

    SetEntityActive("NAMEOFAREA", false);// This gets rid of the area, so the script will only run once.

    }



// If the player doesn't have the key, nothing happens.

}



RE: Area script. Help needed ! - Khyrpa - 02-07-2012

tee global filu mappikansioon (global.hps). lisää sinne tällasta:

void OnGameStart()
{
SetGlobalVarInt("ToActivateOrNotTo", 0);
}

sitte sillon ku se joku tapahtuu et saat sen script arean toimimaan ni laitat sinne:
SetGlobalVarInt("ToActivateOrNotTo", 1);

eli global filussa toi variaabeli muuttuu nollasta ykköseks.

Sitte se mappi missä se area on:

////
void OnEnter()
{
GetGlobalVarInt("ToActivateOrNotTo");
{
if(GetGlobalVarInt("ToActivateOrNotTo") == 1)
{
//stuff you want done here
}
if(GetGlobalVarInt("ToActivateOrNotTo") == 0)
{
//nothing
}
}
}



edit. ninja'D


RE: Area script. Help needed ! - SilentStriker - 02-07-2012

(02-07-2012, 09:27 PM)Khyrpa Wrote: tee global filu mappikansioon (global.hps). lisää sinne tällasta:

void OnGameStart()
{
SetGlobalVarInt("ToActivateOrNotTo", 0);
}

sitte sillon ku se joku tapahtuu et saat sen script arean toimimaan ni laitat sinne:
SetGlobalVarInt("ToActivateOrNotTo", 1);

eli global filussa toi variaabeli muuttuu nollasta ykköseks.

Sitte se mappi missä se area on:

////
void OnEnter()
{
GetGlobalVarInt("ToActivateOrNotTo");
{
if(GetGlobalVarInt("ToActivateOrNotTo") == 1)
{
//stuff you want done here
}
if(GetGlobalVarInt("ToActivateOrNotTo") == 0)
{
//nothing
}
}
}



edit. ninja'D
Hi khyrpa ^^





RE: Area script. Help needed ! - SpudroSpadre - 02-07-2012

(02-07-2012, 09:22 PM)SilentStriker Wrote:
(02-07-2012, 09:12 PM)SpudroSpadre Wrote: Hi all !

So let's say I have a script area ( ScriptArea_1 for example ) on map "FirstFloor"
and I want it to get activated when I pick up a key (Key_1) on map GuestRooms.

So the ScriptArea_1 and the Key_1 are both on different maps.

I have no slightest idea what I need to do to get it work.
All help would be appreciated.

Thx. Cool
Here's a script Smile

Code:
void OnStart()

{

    AddEntityCollideCallback("Player", "NAMEOFAREA", "HasKey_func",
false, 1); // This will activate every time the player enters the area.

}

void HasKey_func(string &in asParent, string &in asChild,  int alState)

{

    if(HasItem("NAMEOFKEY")) // Checks if the player has the key

    {

    

    SetEntityActive("NAMEOFAREA", false);// This gets rid of the area, so the script will only run once.

    }



// If the player doesn't have the key, nothing happens.

}
Thx so much. Im gonna test it in a while. Wink




RE: Area script. Help needed ! - Ninami - 02-08-2012

I haven't tried this my self but does that script really work even though they are on a different map? It just felt so easy, I thought it would be more complicated when you add more maps.


RE: Area script. Help needed ! - Your Computer - 02-08-2012

(02-08-2012, 03:12 AM)Ninami Wrote: I haven't tried this my self but does that script really work even though they are on a different map? It just felt so easy, I thought it would be more complicated when you add more maps.

Inventory items carry on to the next map, so it should work.


RE: Area script. Help needed ! - Ninami - 02-08-2012

(02-08-2012, 03:40 AM)Your Computer Wrote:
(02-08-2012, 03:12 AM)Ninami Wrote: I haven't tried this my self but does that script really work even though they are on a different map? It just felt so easy, I thought it would be more complicated when you add more maps.

Inventory items carry on to the next map, so it should work.
Yeah that's true. But that makes me wonder, how about buttons on one map that opens a door on a different map? Would that work?


RE: Area script. Help needed ! - flamez3 - 02-08-2012

(02-08-2012, 04:44 AM)Ninami Wrote:
(02-08-2012, 03:40 AM)Your Computer Wrote:
(02-08-2012, 03:12 AM)Ninami Wrote: I haven't tried this my self but does that script really work even though they are on a different map? It just felt so easy, I thought it would be more complicated when you add more maps.

Inventory items carry on to the next map, so it should work.
Yeah that's true. But that makes me wonder, how about buttons on one map that opens a door on a different map? Would that work?
You would need a global variable for that.


RE: Area script. Help needed ! - Ninami - 02-08-2012

(02-08-2012, 06:03 AM)flamez3 Wrote:
(02-08-2012, 04:44 AM)Ninami Wrote:
(02-08-2012, 03:40 AM)Your Computer Wrote:
(02-08-2012, 03:12 AM)Ninami Wrote: I haven't tried this my self but does that script really work even though they are on a different map? It just felt so easy, I thought it would be more complicated when you add more maps.

Inventory items carry on to the next map, so it should work.
Yeah that's true. But that makes me wonder, how about buttons on one map that opens a door on a different map? Would that work?
You would need a global variable for that.
I guess that exists? So it's theoretically possible?