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
Script Help Area script. Help needed !
SpudroSpadre Offline
Junior Member

Posts: 14
Threads: 4
Joined: Dec 2011
Reputation: 0
#1
Area script. Help needed !

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


TENSIONAL GAMES

- Currently working on a Amnesia custom story
02-07-2012, 09:12 PM
Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#2
RE: Area script. Help needed !

(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

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.

}

02-07-2012, 09:22 PM
Find
Khyrpa Offline
Senior Member

Posts: 638
Threads: 10
Joined: Apr 2011
Reputation: 24
#3
RE: Area script. Help needed !

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

(This post was last modified: 02-07-2012, 09:27 PM by Khyrpa.)
02-07-2012, 09:27 PM
Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#4
RE: Area script. Help needed !

(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 ^^



02-07-2012, 09:31 PM
Find
SpudroSpadre Offline
Junior Member

Posts: 14
Threads: 4
Joined: Dec 2011
Reputation: 0
#5
RE: Area script. Help needed !

(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

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



TENSIONAL GAMES

- Currently working on a Amnesia custom story
02-07-2012, 09:41 PM
Find
Ninami Offline
Member

Posts: 59
Threads: 6
Joined: Feb 2012
Reputation: 2
#6
RE: Area script. Help needed !

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.
02-08-2012, 03:12 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#7
RE: Area script. Help needed !

(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.

Tutorials: From Noob to Pro
02-08-2012, 03:40 AM
Website Find
Ninami Offline
Member

Posts: 59
Threads: 6
Joined: Feb 2012
Reputation: 2
#8
RE: Area script. Help needed !

(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?
02-08-2012, 04:44 AM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#9
RE: Area script. Help needed !

(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.

02-08-2012, 06:03 AM
Find
Ninami Offline
Member

Posts: 59
Threads: 6
Joined: Feb 2012
Reputation: 2
#10
RE: Area script. Help needed !

(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?

02-08-2012, 06:25 AM
Find




Users browsing this thread: 2 Guest(s)