Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help SetLanternLitCallback
hunchbackproduction Offline
Junior Member

Posts: 36
Threads: 13
Joined: Jul 2013
Reputation: 0
#1
SetLanternLitCallback

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");
}

Scripting level is over 9000!
(This post was last modified: 07-19-2013, 06:59 PM by hunchbackproduction.)
07-19-2013, 05:32 PM
Website Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: SetLanternLitCallback

Lantern callback requires a boolean parameter.

Tutorials: From Noob to Pro
07-19-2013, 09:20 PM
Website Find
hunchbackproduction Offline
Junior Member

Posts: 36
Threads: 13
Joined: Jul 2013
Reputation: 0
#3
RE: SetLanternLitCallback

(07-19-2013, 09:20 PM)Your Computer Wrote: Lantern callback requires a boolean parameter.

Alrighty, so how would I implement that ?

Scripting level is over 9000!
07-20-2013, 11:50 AM
Website Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#4
RE: SetLanternLitCallback

The SetLanternLitCallback is what sets your callback, it isn't called when you light your lantern.

For example:

PHP Code: (Select All)
void onStart {

SetLanternLitCallback("LitCallback"); 

}

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

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

(This post was last modified: 07-20-2013, 01:29 PM by Tomato Cat.)
07-20-2013, 01:02 PM
Find
hunchbackproduction Offline
Junior Member

Posts: 36
Threads: 13
Joined: Jul 2013
Reputation: 0
#5
RE: SetLanternLitCallback

(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: (Select All)
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) ?

Scripting level is over 9000!
(This post was last modified: 07-20-2013, 02:21 PM by hunchbackproduction.)
07-20-2013, 02:06 PM
Website Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#6
RE: SetLanternLitCallback

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
Find
hunchbackproduction Offline
Junior Member

Posts: 36
Threads: 13
Joined: Jul 2013
Reputation: 0
#7
RE: SetLanternLitCallback

(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!

Scripting level is over 9000!
07-29-2013, 04:24 PM
Website Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#8
RE: SetLanternLitCallback

(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: (Select All)
//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: (Select All)
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: (Select All)
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.
(This post was last modified: 07-31-2013, 04:18 PM by Tomato Cat.)
07-29-2013, 07:37 PM
Find
hunchbackproduction Offline
Junior Member

Posts: 36
Threads: 13
Joined: Jul 2013
Reputation: 0
#9
RE: SetLanternLitCallback

(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: (Select All)
//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: (Select All)
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: (Select All)
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!

Scripting level is over 9000!
07-30-2013, 04:54 PM
Website Find
hunchbackproduction Offline
Junior Member

Posts: 36
Threads: 13
Joined: Jul 2013
Reputation: 0
#10
RE: SetLanternLitCallback

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!

Scripting level is over 9000!
(This post was last modified: 08-03-2013, 07:17 PM by hunchbackproduction.)
08-03-2013, 07:16 PM
Website Find




Users browsing this thread: 1 Guest(s)