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 So many errors
CarnivorousJelly Offline
Posting Freak

Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation: 80
#1
So many errors

I've managed to remove all the coding that had errors in it, but now I'm not quite sure how to write the function I want. The timers in the code (what I removed) was causing the error "main (11, 1): INFO: Compiling void Script_VisionTrigger(string&in, string&in, int)"
Where do I put the timers if I want them to run only when the player is in the specified area?

void OnStart()
{
    AddEntityCollideCallback("Player", "Area_VisionTrigger", "Script_VisionTrigger", false, 0);
}

void OnEnter()
{

}

void Script_VisionTrigger (string &in asParent, string &in asChild, int alState)
{
    if(alState == 1)
    {
        PlayMusic("vision_music", true, 1, 6, 7, false);
        CreateParticleSystemAtEntity("Area_VisionWind", "ps_dust_whirl.ps", "Area_VisionWind", false);
        SetLampLit("candlestick_floor_1", false, true);
        SetLampLit("candle_floor_small_1", false, true);
        PlaySoundAtEntity("blow", "general_wind_whirl", "Player", 0.0f, false);
        
        AddTimer("fadescreen", 18.1f, "timer_fade");
        AddTimer("visionstarter", 19.2f, "timer_vision_start");
        AddTimer("visionender", 203.53f, "timer_vision_end");
    }
    if(alState == -1)
    {
        StopMusic(3, 7);
    }
}

void OnLeave()
{

}

Edit: if it helps, I was trying to get the timers to fade the screen to black, then teleport the player to a second start area and fade back in, have the event play, then teleport him back.

[Image: quote_by_rueppells_fox-d9ciupp.png]
(This post was last modified: 02-10-2013, 10:46 PM by CarnivorousJelly.)
02-10-2013, 10:43 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#2
RE: So many errors

That's not something implemented Wink It's something you could do with variables.

Ex.

OnStart
All timers run.
Set timers to only work if LocalVarInt "TimerVar" == 1

if(GetLocalVarInt("TimerVar") == 1)
{
//DO STUFF WHEN INSIDE AREA
}
if(GetLocalVarInt("TimerVar") == 0)
{
//DO STUFF WHEN OUTSIDE AREA
}

When walking into area:

SetLocalVarInt("TimerVar", 1);

When walking out of area:
SetLocalVarInt("TimerVar", 0);


Understand?

Trying is the first step to success.
(This post was last modified: 02-10-2013, 11:15 PM by FlawlessHappiness.)
02-10-2013, 11:13 PM
Find
CarnivorousJelly Offline
Posting Freak

Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation: 80
#3
RE: So many errors

(02-10-2013, 11:13 PM)BeeKayK Wrote: if(GetLocalVarInt("TimerVar") == 1)
{
//DO STUFF WHEN INSIDE AREA
}
I think this is the one I'm trying to do

(02-10-2013, 11:13 PM)BeeKayK Wrote: Understand?

Not in the slightest D: sorry

[Image: quote_by_rueppells_fox-d9ciupp.png]
02-11-2013, 12:54 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#4
RE: So many errors

Ok.

What I'm guessing you want to do is to have different timers repeat themselves when you are inside an area, and stop when you are outside, right?

Is that correct, or do you only want them to play once?

Trying is the first step to success.
02-11-2013, 07:48 AM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#5
RE: So many errors

void OnStart()
{
AddEntityCollideCallback("Player", "Area_VisionTrigger", "Script_VisionTrigger", false, 0);
}

void OnEnter()
{

}

void Script_VisionTrigger (string &in asParent, string &in asChild, int alState)
{
if(alState == 1)
{
PlayMusic("vision_music", true, 1, 6, 7, false);
CreateParticleSystemAtEntity("Area_VisionWind", "ps_dust_whirl.ps", "Area_VisionWind", false);
SetLampLit("candlestick_floor_1", false, true);
SetLampLit("candle_floor_small_1", false, true);
PlaySoundAtEntity("blow", "general_wind_whirl", "Player", 0.0f, false);

AddTimer("fadescreen", 18.1f, "timer_fade");
AddTimer("visionstarter", 19.2f, "timer_vision_start");
AddTimer("visionender", 203.53f, "timer_vision_end");
SetLocalVarInt("IsPlayerInArea", 1); // where 1 is yes and 0 is no
}
if(alState == -1)
{
StopMusic(3, 7);
SetLocalVarInt("IsPlayerInArea", 0); // where 1 is yes and 0 is no
}
}

void Potential_Timer_Function(string &in strTimer)
{
if (GetLocalVarInt("IsPlayerInArea") == 1)
{
// do the stuff
}
}


void OnLeave()
{

}

This is all assuming you want those timers to expire with nothing happening if the player has left that area.
(This is also all assuming you know that you haven't written any functions for those timer callbacks Tongue)

If you want those timers to work even if you have left the area, well they should do now!

[disclaimer: this is provided untested, therefore I will not be held liable for damage to computer and/or persons including but not limited to dramatic loss of life etc.]

(This post was last modified: 02-11-2013, 11:38 AM by Adrianis.)
02-11-2013, 11:22 AM
Find
CarnivorousJelly Offline
Posting Freak

Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation: 80
#6
RE: So many errors

I'll give that script a try and see if it works; thank you Adrianis Smile

(02-11-2013, 07:48 AM)BeeKayK Wrote: Ok.

What I'm guessing you want to do is to have different timers repeat themselves when you are inside an area, and stop when you are outside, right?

Is that correct, or do you only want them to play once?

I want the music to play every time, the wind effect to play the first time only, then the timers to be triggered every time the player enters the area (reset if they exit) until the event is triggered. Once the event has occurred, I don't want the player to be able to trigger it again.

I'm starting to get the feeling that this script is way over my head :S

[Image: quote_by_rueppells_fox-d9ciupp.png]
02-11-2013, 07:52 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#7
RE: So many errors

Most of what you described is just variables.

Start out with one thing at a time. First get the music working.
Then make it so the wind effect only plays one time.
Then the timers.

Trying is the first step to success.
02-11-2013, 08:36 PM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#8
RE: So many errors

(02-11-2013, 07:52 PM)Kiandra Wrote: I want the music to play every time, the wind effect to play the first time only, then the timers to be triggered every time the player enters the area (reset if they exit) until the event is triggered. Once the event has occurred, I don't want the player to be able to trigger it again.

I'm starting to get the feeling that this script is way over my head :S

You'll get there, if you take the time to break down the problems and code them bit by bit.
However, since you want to actually re-set the timers if they leave the area (rather than just make them invalid when they expire), we should do things slightly differently.


void OnStart()
{
AddEntityCollideCallback("Player", "Area_VisionTrigger", "Script_VisionTrigger", false, 0);
SetLocalVarInt("HasWindPlayed", 0) // setup for use in Script_VisionTrigger
}


void Script_VisionTrigger (string &in asParent, string &in asChild, int alState)
{

if(alState == 1)
{
PlayMusic("vision_music", true, 1, 6, 7, false); // this is to happen every time

if (GetLocalVarInt("HasWindPlayed") == 0) // wind stuff happens first time only
{

CreateParticleSystemAtEntity("Area_VisionWind", "ps_dust_whirl.ps", "Area_VisionWind", false);
SetLampLit("candlestick_floor_1", false, true);
SetLampLit("candle_floor_small_1", false, true);
PlaySoundAtEntity("blow", "general_wind_whirl", "Player", 0.0f, false);
SetLocalVarInt("HasWindPlayed", 1);
}

AddTimer("fadescreen", 18.1f, "timer_fade");
AddTimer("visionstarter", 19.2f, "timer_vision_start");
AddTimer("visionender", 203.53f, "timer_vision_end");
SetLocalVarInt("IsPlayerInArea", 1); // where 1 is yes and 0 is no
}
if(alState == -1)
{
StopMusic(3, 7);
RemoveTimer("fadescreen");
RemoveTimer("visionstarter");
RemoveTimer("visionender");

SetLocalVarInt("IsPlayerInArea", 0); // where 1 is yes and 0 is no
}
}

void Potential_Timer_Function(string &in strTimer)
{
if (GetLocalVarInt("IsPlayerInArea") == 1)
{
// do the stuff
SetEntityActive("Area_VisionTrigger", false); // this will deactivate the trigger area
}
}

Decided to keep the variables for checking if you are in / out of the area, despite the fact that with the RemoveTimers they are not so important, but a nice extra layer of security never hurt

EDIT: Ninja'd, but still useful i hope

(This post was last modified: 02-11-2013, 08:59 PM by Adrianis.)
02-11-2013, 08:55 PM
Find
CarnivorousJelly Offline
Posting Freak

Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation: 80
#9
RE: So many errors

(02-11-2013, 08:55 PM)Adrianis Wrote: You'll get there, if you take the time to break down the problems and code them bit by bit.
However, since you want to actually re-set the timers if they leave the area (rather than just make them invalid when they expire), we should do things slightly differently.

void OnStart()
{
AddEntityCollideCallback("Player", "Area_VisionTrigger", "Script_VisionTrigger", false, 0);
[b]SetLocalVarInt("HasWindPlayed", 0) // setup for use in Script_VisionTrigger[/b]
}


void Script_VisionTrigger (string &in asParent, string &in asChild, int alState)
{

if(alState == 1)
{
PlayMusic("vision_music", true, 1, 6, 7, false); // this is to happen every time

[b]if (GetLocalVarInt("HasWindPlayed") == 0) // wind stuff happens first time only
{[/b]
CreateParticleSystemAtEntity("Area_VisionWind", "ps_dust_whirl.ps", "Area_VisionWind", false);
SetLampLit("candlestick_floor_1", false, true);
SetLampLit("candle_floor_small_1", false, true);
PlaySoundAtEntity("blow", "general_wind_whirl", "Player", 0.0f, false);
[b]SetLocalVarInt("HasWindPlayed", 1);
} [/b]
AddTimer("fadescreen", 18.1f, "timer_fade");
AddTimer("visionstarter", 19.2f, "timer_vision_start");
AddTimer("visionender", 203.53f, "timer_vision_end");
SetLocalVarInt("IsPlayerInArea", 1); // where 1 is yes and 0 is no
}
if(alState == -1)
{
StopMusic(3, 7);
[b]RemoveTimer("fadescreen");
RemoveTimer("visionstarter");
RemoveTimer("visionender");[/b]
SetLocalVarInt("IsPlayerInArea", 0); // where 1 is yes and 0 is no
}
}

void Potential_Timer_Function(string &in strTimer)
{
if (GetLocalVarInt("IsPlayerInArea") == 1)
{
// do the stuff
[b]SetEntityActive("Area_VisionTrigger", false); // this will deactivate the trigger area[/b]
}
}

Decided to keep the variables for checking if you are in / out of the area, despite the fact that with the RemoveTimers they are not so important, but a nice extra layer of security never hurt

EDIT: Ninja'd, but still useful i hope

Very useful Smile If you don't mind, could you explain how this code would be used?

void FadeOut(float afTime);

I have a general grasp on where I should put it in the whole script, but no idea what "float" or "afTime" would actually look like in the script. Unfortunately, staring at 00_rainy_hall.hps didn't help me much other than figuring out how to teleport the player (thankfully, I have the teleport part working).

[Image: quote_by_rueppells_fox-d9ciupp.png]
(This post was last modified: 02-12-2013, 07:16 AM by CarnivorousJelly.)
02-12-2013, 06:45 AM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#10
RE: So many errors

Ok so if you don't know already, 'float' is a decimal number, like 2.5, 424.6485 etc, where an integer (int) can only be a whole number like 2, 45 etc. Floats can hold whole numbers, but integers cannot hold decimal values

FadeOut fades the screen out in the specified time, the float value is seconds, so just think of it as how many seconds until the screen is fully black, then FadeIn is how many seconds until the screen is fully back to normal.
One way these could be used..

void OnStart()
{
    FadeOut(0);
    FadeIn(3);
}

Fade out in 0 seconds, meaning as soon as the game loads the screen is black, then fade in for 3 seconds. I found this useful if you want to position the player for when the game starts, you can force crouch, move their head etc without them noticing.

02-12-2013, 06:14 PM
Find




Users browsing this thread: 1 Guest(s)