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
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#11
RE: SetLanternLitCallback

(08-03-2013, 07:16 PM)hunchbackproduction Wrote: 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!

it should not be bool LanternLit it has to be bool abLit since it's a programmed parameter.

so it should look more like this

SetLanternLitCallback("LanternLit");

void LanternLit(bool abLit)
{
    if(true)
    {
      AddDebugMessage("It's working!", true);
     }
    else
    {
     AddDebugMessage("It's NOT working", true);
    }
}

Here's your fixed code:

void LanternTinderCheck(bool abLit)
{
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");
}

(This post was last modified: 08-03-2013, 09:33 PM by SilentStriker.)
08-03-2013, 09:31 PM
Find
Tomato Cat Offline
Senior Member

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

(08-03-2013, 07:16 PM)hunchbackproduction Wrote: 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!
Don't worry. It will all make sense. =p

You could put addNumber(1, 3) somewhere, but the parser/compiler will give you an error unless you define that function somewhere.

I and K, as in my previous example, represent the values that you pass to that function.

"public" is what's known as an access specifier. It's more of an advanced topic. It was force of habit, but I don't think the HPL scripting requires it. You can ignore it if you like.

The boolean is passed through the internal workings of the engine. You define parameters when you define the function. Also, try using "AddDebugMessage" rather than setmessage.
08-04-2013, 01:33 AM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#13
RE: SetLanternLitCallback

(08-04-2013, 01:33 AM)Tomato Cat Wrote:
(08-03-2013, 07:16 PM)hunchbackproduction Wrote: 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!
Don't worry. It will all make sense. =p

You could put addNumber(1, 3) somewhere, but the parser/compiler will give you an error unless you define that function somewhere.

I and K, as in my previous example, represent the values that you pass to that function.

"public" is what's known as an access specifier. It's more of an advanced topic. It was force of habit, but I don't think the HPL scripting requires it. You can ignore it if you like.

The boolean is passed through the internal workings of the engine. You define parameters when you define the function. Also, try using "AddDebugMessage" rather than setmessage.

Oh. I really thought it's a returnType.

"Veni, vidi, vici."
"I came, I saw, I conquered."
08-04-2013, 02:12 AM
Find
Tomato Cat Offline
Senior Member

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

(08-04-2013, 02:12 AM)JustAnotherPlayer Wrote: Oh. I really thought it's a returnType.

No, in this case "void" is the return type (or lack thereof).
08-04-2013, 03:06 AM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#15
RE: SetLanternLitCallback

(08-04-2013, 03:06 AM)Tomato Cat Wrote:
(08-04-2013, 02:12 AM)JustAnotherPlayer Wrote: Oh. I really thought it's a returnType.

No, in this case "void" is the return type (or lack thereof).

Oh ok. If returnType is int/float, I have to return a value through return; right?

"Veni, vidi, vici."
"I came, I saw, I conquered."
08-04-2013, 03:28 AM
Find
Tomato Cat Offline
Senior Member

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

Yep. It's the same with all the primitive types and any objects etc.
(This post was last modified: 08-04-2013, 03:35 AM by Tomato Cat.)
08-04-2013, 03:34 AM
Find
Your Computer Offline
SCAN ME!

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

(08-03-2013, 09:31 PM)SilentStriker Wrote: it should not be bool LanternLit it has to be bool abLit since it's a programmed parameter.

In computer programming, parameter variable names are irrelevant insofar as the signature of the function is concerned. All that really matters is the data type of the parameter. In other words, either "LanternLit" or "abLit" or whatever, or nothing at all, can be used. For example, this would still work:
PHP Code: (Select All)
void LanternCallback(bool)
{
    
// Do something...


Tutorials: From Noob to Pro
(This post was last modified: 08-04-2013, 09:42 AM by Your Computer.)
08-04-2013, 09:42 AM
Website Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#18
RE: SetLanternLitCallback

(08-04-2013, 09:42 AM)Your Computer Wrote:
(08-03-2013, 09:31 PM)SilentStriker Wrote: it should not be bool LanternLit it has to be bool abLit since it's a programmed parameter.

In computer programming, parameter variable names are irrelevant insofar as the signature of the function is concerned. All that really matters is the data type of the parameter. In other words, either "LanternLit" or "abLit" or whatever, or nothing at all, can be used. For example, this would still work:
PHP Code: (Select All)
void LanternCallback(bool)
{
    
// Do something...


True, god I'm rusty with my programming...

(This post was last modified: 08-04-2013, 10:45 AM by SilentStriker.)
08-04-2013, 10:44 AM
Find
hunchbackproduction Offline
Junior Member

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

Haha ^ Thanks to all of you :3 The CODE IT WORKS Big Grin! Real thanks to you guys, reputation for everyone. May even put you guys in the credits if I ever finish this thing!

Scripting level is over 9000!
08-04-2013, 02:17 PM
Website Find




Users browsing this thread: 1 Guest(s)