SpudroSpadre
Junior Member
Posts: 14
Threads: 4
Joined: Dec 2011
Reputation:
0
|
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.
TENSIONAL GAMES
- Currently working on a Amnesia custom story
|
|
02-07-2012, 09:12 PM |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
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. Here's a script
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 |
|
Khyrpa
Senior Member
Posts: 638
Threads: 10
Joined: Apr 2011
Reputation:
24
|
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 |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
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 |
|
SpudroSpadre
Junior Member
Posts: 14
Threads: 4
Joined: Dec 2011
Reputation:
0
|
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. Here's a script
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.
TENSIONAL GAMES
- Currently working on a Amnesia custom story
|
|
02-07-2012, 09:41 PM |
|
Ninami
Member
Posts: 59
Threads: 6
Joined: Feb 2012
Reputation:
2
|
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 |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
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.
|
|
02-08-2012, 03:40 AM |
|
Ninami
Member
Posts: 59
Threads: 6
Joined: Feb 2012
Reputation:
2
|
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 |
|
flamez3
Posting Freak
Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation:
57
|
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 |
|
Ninami
Member
Posts: 59
Threads: 6
Joined: Feb 2012
Reputation:
2
|
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 |
|
|