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
Confused with void Func_Name
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#5
RE: Confused with void Func_Name

(03-10-2012, 03:06 AM)DaAinGame Wrote: Adrianis, I can't tell if your post helped me or confused me even more....
Thats Ok, it took me a little while to get used to, havn't seen a script work like this before, so I might not be able to explain it too well, but no one else is so what the hell I'll try at least Smile

Your 'Fade' function is fine. So, there are 'Engine functions' (the page for which I previded before) such as 'AddTimer' and 'AddEntityCollideCallback'. The conditions for these must be filled in with the relevant information, so where the timer function is 'AddTimer(string& asName, float afTime, string& asFunction);' you need to replace the strings and integers (inc. floats) etc with values like ("T1", 15, "TimerFunc")

Now the AddEntityCollideCallback, which I think is what you are using for the 'LookRocks' function. When this is added within the void OnStart(), needs the strings/integers etc filled in. It calls to a function that you define.

Where you define your function, created by the callback part of the previous engine function used (AddEntityCollideCallback), there are a set of conditions, which you have written below,

"void LookRocks(string &in asParent, string &in asChild, int alState)"

This is correct. You do not replace these strings/ints (variables) because their values are taken from the engine script which called it, and this means you only need to reference the variable name. The variables themselves are as follows,
asParent = The entity (can be "Player") that will collide with the other entity, or 'Child'
asChild = The entity (or area) that will be collided with by the Parent
alState = Whether the function is called on the start of the collision (1), at the end (-1) or either start/end (0)

"how do I figure out what does the second part means?"
- It is taken from the function that called it

Now, your function is called 'LookRocks', if you are using a 'Look at' callback such as SetEntityPlayerLookAtCallback, then the syntax for the callback function (your 'LookRocks' function) should be (string &in asEntity, int alState).

Let me give you some context by showing you what I've done,


void OnStart()
{
SetEntityPlayerLookAtCallback("work_desk_worn_2", "LookAtCandles", true);
}
This is the engine function to call to another function when the player looks at the desk

void LookAtCandles(string &in asEntity, int alState)
{
SetLampLit("candlestick02_1", false, false);
SetLampLit("candlestick02_3", false, false);
CreateParticleSystemAtEntity("candlestick_1_gust", "ps_dust_push.ps", "ScriptArea_4", true);
CreateParticleSystemAtEntity("candlestick_3_gust", "ps_dust_push.ps", "ScriptArea_5", true);
PlaySoundAtEntity("wind", "27_wind.snt", "Player", 0, false);
SetLightFlickerActive("PointLight_1", true);
SetLightFlickerActive("PointLight_2", true);
AddTimer("T1", 0.4, "CandleLightOut");
}
In this callback function, I actually ignore the asEntity and alState (which make up the condition for this callback function) variables as they have no relevance to what I want to do with the function. At the end, I use AddTimer to create a call out to another callback function, below

void CandleLightOut(string &in asTimer)
{
SetLightVisible("PointLight_1", false);
SetLightVisible("PointLight_2", false);
}
Note how the condition variable has changed due to the different engine function I used to call to this function. Again, I have not used the asTimer variable. However, if I wanted to I could use the asTimer variable in the following way

void CandleLightOut(string &in asTimer)
{
if (asTimer == "T1")
{
SetLightVisible("PointLight_1", false);
SetLightVisible("PointLight_2", false);
}
}

Here I use the asTimer variable, which holds the name of the timer that was used initially to call this function, to check whether the timer calling to this function is the correct timer. I can actually reference whatever variable is pulled into this function by the callback, which means you can have 1 callback function used multiple times by other functions, that work regardless of what entity/light etc is affected

If you look at the Engine functions here (http://wiki.frictionalgames.com/hpl2/amn..._functions) you will see that where functions are used that call to other functions, such as the timer or look at callbacks, the variable names that make up the conditions for that function are defined in the description of the function, there is no way you can guess or choose yourself unfortunately, you must use this page as a reference.

I hope that clears things up, however, looking at the amount written I have a feeling it might not Smile

(This post was last modified: 03-11-2012, 04:40 AM by Adrianis.)
03-11-2012, 04:33 AM
Find


Messages In This Thread
Confused with void Func_Name - by DaAinGame - 03-10-2012, 02:32 AM
RE: Confused with void Func_Name - by Adrianis - 03-10-2012, 02:52 AM
RE: Confused with void Func_Name - by DaAinGame - 03-10-2012, 03:06 AM
RE: Confused with void Func_Name - by Adrianis - 03-11-2012, 04:33 AM
RE: Confused with void Func_Name - by DaAinGame - 03-11-2012, 08:00 PM



Users browsing this thread: 1 Guest(s)