Frictional Games Forum (read-only)

Full Version: SetLanternLitCallback
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
void SetLanternLitCallback(string& asCallback);
Sets the function to call when the player uses his lantern.
Callback syntax: MyFunc(bool abLit)

I am using this code in my custom story, however it seems to be doing nothing and I'd like to think I didn't make an error in code. Any help would be appreciated!!! <3 Big Grin


void LanternTinderCheck(string& asCallback)
{
if (GetGlobalVarInt("Tinderboxes") == 0)
{
SetMessage("Chemical", "notinderboxes", 1);
SetLanternActive(false, true);
SetLanternDisabled(true);
AddTimer("", 1, "ReAllowLighting");
}
if (GetGlobalVarInt("Tinderboxes") > 0)
{
AddGlobalVarInt("Tinderboxes", -1);
SetMessage("Chemical", "lanternlit", 1);
SetLanternLitCallback("LanternTinderCheck");
}
}

void ReAllowLighting(string &in asTimer)
{
SetLanternDisabled(false);
SetLanternLitCallback("LanternTinderCheck");
}

void OnStart()
{
SetLanternLitCallback("LanternTinderCheck");
SetGlobalVarInt("Tinderboxes", 0);
}

void OnEnter()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "ArthurCheck", true, 1);
PlayMusic("RopeFootstep.ogg", true, 1, 1, 1, false);
}

void OnLeave()
{
SetupLoadScreen("LoadingText", "Loading", 7, "HNBKChapterOne.jpg");
}
Lantern callback requires a boolean parameter.
(07-19-2013, 09:20 PM)Your Computer Wrote: [ -> ]Lantern callback requires a boolean parameter.

Alrighty, so how would I implement that ?
The SetLanternLitCallback is what sets your callback, it isn't called when you light your lantern.

For example:

PHP Code:
void onStart {

SetLanternLitCallback("LitCallback"); 

}

void LitCallback(bool abLit /*Your boolean parameter*/) {

/*This functions is called when you light your lantern*/
 

(07-20-2013, 01:02 PM)Tomato Cat Wrote: [ -> ]The SetLanternLitCallback is what sets your callback, it isn't called when you light your lantern.

For example:

PHP Code:
void onStart {

SetLanternLitCallback("LitCallback"); 

}

void LitCallback(bool abLit /*Your boolean parameter*/) {

/*This functions is called when you light your lantern*/
 


Aaaaaaaaaaaaaaaaaaaaaaaah, I see now.

void LitCallback(bool abLit /*Your boolean parameter*/)

With that line of code would I do something like:

void LitCallback(true) ?
No, it's a parameter. It specifies that the function takes a boolean value, which is passed by the callback. (I'm assuming true for lit, false for unlit.) =p
(07-20-2013, 02:58 PM)Tomato Cat Wrote: [ -> ]No, it's a parameter. It specifies that the function takes a boolean value, which is passed by the callback. (I'm assuming true for lit, false for unlit.) =p

Alright, just came back from holidays and ready to code Big Grin

I ain't no pro haxor, so could you please explain to me wtf is a parameter and actually give me a example of the SetLanternLitCallback being used please xD.

Sorry for the hassle and thanks for the help so far dudes!
(07-29-2013, 04:24 PM)hunchbackproduction Wrote: [ -> ]Alright, just came back from holidays and ready to code Big Grin

I ain't no pro haxor, so could you please explain to me wtf is a parameter and actually give me a example of the SetLanternLitCallback being used please xD.

Sorry for the hassle and thanks for the help so far dudes!

Welcome back!

A parameter is a value passed to a function. In the most basic sense.

PHP Code:
//For example
public void addNumber(int iint k)
{
   
//Prints the sum of two numbers
   
print(k);


In this snippet, "i" and "k" represent integers. Their values are "passed" (think, "sent to") the function addNumber.

Say you wanted to use the function somewhere. You would write:

PHP Code:
addNumber(31); 

In this case, the parameter "i" represents the integer value of 3. Whereas "k" represents 1.

Now, for the lantern callback, it's pretty much the same. Only what's passed is a "boolean" (true/false) type.

PHP Code:
public void test(bool lanternLit)
{
   if(
lanternLit//Shorthand for if *** is "true"
   
{
      
//Code to keep the monsters away
   
}
   else 
//If the lanterLit value is "false"
   
{
      
//Code to get attacked by monsters
   
}


Only in this case, the parameter is passed internally.
(07-29-2013, 07:37 PM)Tomato Cat Wrote: [ -> ]
(07-29-2013, 04:24 PM)hunchbackproduction Wrote: [ -> ]Alright, just came back from holidays and ready to code Big Grin

I ain't no pro haxor, so could you please explain to me wtf is a parameter and actually give me a example of the SetLanternLitCallback being used please xD.

Sorry for the hassle and thanks for the help so far dudes!

Welcome back!

A parameter is a value passed to a function. In the most basic sense.

PHP Code:
//For example
public void addNumber(int iint k)
{
   
//Adds the sum of two numbers
   
print(k);


In this snippet, "i" and "k" represent integers. Their values are "passed" (think, "sent to") the function addNumber.

Say you wanted to use the function somewhere. You would write:

PHP Code:
addNumber(31); 

In this case, the parameter "i" represents the integer value of 3. Whereas "k" represents 1.

Now, for the lantern callback, it's pretty much the same. Only what's passed is a "boolean" (true/false) type.

PHP Code:
public void test(bool lanternLit)
{
   if(
lanternLit//Shorthand for if *** is "true"
   
{
      
//Code to keep the monsters away
   
}
   else 
//If the lanterLit value is "false"
   
{
      
//Code to get attacked by monsters
   
}


Only in this case, the parameter is passed internally.

Alrighty, making more sense now ^^ Your really good at this Big Grin I'll try this stuff out, then come back if I need some more clarification!
Ok! tried to get this to work, I thought I understood this, But boy was I wrong xD
I need a little more clarification on how this whole thing works.
When you explained the I and K parameter thing I got it, But why is I and K needed ? Can't you just code: "addnumber(3,1)" ?


Also what is up with "public" I saw you put that there before your voids

I still do not get the whole lanternlit, and how it links to parameters ? Are the parameters "true" or "false" and do I have to define these somewhere ?


void LanternLit(bool lanternLit)
{
if(lanternLit)
{
SetMessage("test", "test", 1);
}
else
{

}
}

I have this piece of test code, please explain to me why it does not work! As when I light my lantern the test message does not appear.
PS: I have given you a reputation for the help so far ^ Thanks!
Pages: 1 2