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
#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


Messages In This Thread
So many errors - by CarnivorousJelly - 02-10-2013, 10:43 PM
RE: So many errors - by FlawlessHappiness - 02-10-2013, 11:13 PM
RE: So many errors - by CarnivorousJelly - 02-11-2013, 12:54 AM
RE: So many errors - by FlawlessHappiness - 02-11-2013, 07:48 AM
RE: So many errors - by CarnivorousJelly - 02-11-2013, 07:52 PM
RE: So many errors - by Adrianis - 02-11-2013, 08:55 PM
RE: So many errors - by CarnivorousJelly - 02-12-2013, 06:45 AM
RE: So many errors - by Adrianis - 02-11-2013, 11:22 AM
RE: So many errors - by FlawlessHappiness - 02-11-2013, 08:36 PM
RE: So many errors - by Adrianis - 02-12-2013, 06:14 PM
RE: So many errors - by CarnivorousJelly - 02-13-2013, 12:54 AM
RE: So many errors - by CarnivorousJelly - 02-14-2013, 05:23 AM
RE: So many errors - by TheGreatCthulhu - 02-14-2013, 01:23 PM



Users browsing this thread: 1 Guest(s)