Solipsist
Junior Member
Posts: 29
Threads: 5
Joined: Aug 2012
Reputation:
0
|
No matching signature to AddTimer
For the life of mine, I could not find a single thread which solves this issue. I am completely baffled about this error.
What I'm trying to do here, is to time the Callback-check-trigger whether the player is using his Lantern or not after stepping into an area. If the player's lantern is active, the script waits for the player to run out of oil or to deactivate it; then the event is initiated.
Yes, it's a cheap scare, but I'm experimenting here.
Quote:void OnStart()
{
if (ScriptDebugOn())
GiveItemFromFile("lantern", "lantern.ent");
//
AddEntityCollideCallback("Player", "S_Trigger", "C_LanternOut", false, 1);
}
void C_LanternOut(string &in asParent, string &in asChild, int alState) //Player has walked into the area.
{
if (GetLanternActive()==true) //Lantern on?
addTimer("", 0.75f, "CR_LanternOut"); //Proceed to a Recursion Function.
else //Lantern is Off.
addTimer("", 0.5f, "CF_LanternOut"); //Set the event
}
void CR_LanternOut(string &in asTimer) // A recursion function, as long as the player has his lantern on; this will be in a timed loop.
{
if (GetLanternActive()==true)
addTimer("", 0.75f, "CR_LanternOut"); //The recursion
else
addTimer("", 0.5f, "CF_LanternOut"); //Set the event
}
void CF_LanternOut(string &in asTimer) //The event, a grunt's awakening snort.
{
PlaySoundAtEntity("", "enabled.snt", "Player", 0, false);
}
This code is not even HALF of what I want it to do, but can you really blame me? Only when the timers will start working I'll be able to do improve it...I even went to the lengths of creating separate functions with asTimer arguments..Because, who knows! Not alot makes sense in this script.
P.S: Terribly sorry if this issue has been addressed already, I sincerely tried to find anything for a whole day.
(This post was last modified: 08-08-2012, 12:26 PM by Solipsist.)
|
|
08-08-2012, 12:19 PM |
|
Adny
Posting Freak
Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation:
173
|
RE: No matching signature to AddTimer
When you use the if/else statement, you need to create additional brackets (both closed an open) to indicate what you want to have happen when the requirements for the if/else is met (or not):
void func()
{
if()
{
//do stuff
}
}
Also, you didn't captialize the first letter of AddTimer. Here's a full revision:
void OnStart()
{
if(ScriptDebugOn() == true)
{
GiveItemFromFile("lantern", "lantern.ent");
}
AddEntityCollideCallback("Player", "S_Trigger", "C_LanternOut", false, 1);
}
void C_LanternOut(string &in asParent, string &in asChild, int alState)
{
if(GetLanternActive() == true)
{
AddTimer("", 0.75f, "CR_LanternOut");
}
else
{
AddTimer("", 0.5f, "CF_LanternOut");
}
}
void CR_LanternOut(string &in asTimer)
{
if(GetLanternActive()==true)
{
AddTimer("", 0.75f, "CR_LanternOut");
}
else
{
AddTimer("", 0.5f, "CF_LanternOut");
}
}
void CF_LanternOut(string &in asTimer)
{
PlaySoundAtEntity("", "enabled.snt", "Player", 0, false);
}
Hope that helped.
I rate it 3 memes.
|
|
08-08-2012, 12:32 PM |
|
Solipsist
Junior Member
Posts: 29
Threads: 5
Joined: Aug 2012
Reputation:
0
|
RE: No matching signature to AddTimer
You've got to be %*(#% kidding me, I jacked up the spelling? I swear the errors in this scripting language are way too misleading.. (Had odd issues with deciding if the script accepts 0-1 or true-false as boolean, apparently..It accepts both, but as "1" / "0" or true / false. Goddamnit.)
Btw, The "Brackets" tip is irrelevant to me, as you can see; I did just that. if(ScriptDebugOn() == true)
Also, the "== true" sign Is redundant. You can write
" if(ScriptDebugOn())" and it would mean the same thing..Same goes to my AddTimer line, which should be better without the '==true' sign anyway.
Anyhoo; Cheers for correcting my idiotic error. The script works now.
Edit: QUESTION!
I rewrote the script to make it simpler, I got it down to this ;
Quote:C_LanternOut(string &in asParent...Etc)
{
if (GetLanternActive() )
AddTimer("", 0.45f, "C_LanternOut"); //Recurse until False.
else
PlaySoundAtEntity("", "enabled.snt", "Player", 0, false);
}
The problem is that Timer is not able to trigger C_LanternOut. Do I need an argument "String &in asTimer" in order to allow it to callback to a function? The script worked with what I started with...
EDIT : The answer would be ; yes.
Quote:OnStart()
{
SetLocalVarInt("Flag_LanternOut", 0);
}
void C_LanternOut(string &in asParent, string &in asChild, int alState) //Player has walked into the area.
{
if (GetLanternActive()){
AddTimer("", 0.2f, "CT_LanternOut");
SetLocalVarInt("Flag_LanternOut", 0);
}
else PlaySoundAtEntity("", "enabled.snt", "Player", 0, false);
}
void CT_LanternOut(string &in asTimer)
{
if (GetLanternActive()){
AddTimer("", 0.2f, "CT_LanternOut");
SetLocalVarInt("Flag_LanternOut", 0);
}
else
{
if (GetLocalVarInt("Flag_LanternOut")!=0)
PlaySoundAtEntity("", "enabled.snt", "Player", 0, false);
else{
SetLocalVarInt("Flag_LanternOut", 1);
AddTimer("", 0.85, "CT_LanternOut");
}}}
If anyone ever, for any reason, resonates with this idea. That's an example.
(This post was last modified: 08-08-2012, 03:34 PM by Solipsist.)
|
|
08-08-2012, 01:52 PM |
|
Theforgot3n1
Member
Posts: 192
Threads: 20
Joined: Apr 2012
Reputation:
6
|
RE: No matching signature to AddTimer
(08-08-2012, 01:52 PM)Solipsist Wrote: You've got to be %*(#% kidding me, I jacked up the spelling? I swear the errors in this scripting language are way too misleading.. (Had odd issues with deciding if the script accepts 0-1 or true-false as boolean, apparently..It accepts both, but as "1" / "0" or true / false. Goddamnit.)
Btw, The "Brackets" tip is irrelevant to me, as you can see; I did just that. if(ScriptDebugOn()== true)
Also, the "== true" sign Is redundant. You can write
"if(ScriptDebugOn())" and it would mean the same thing..Same goes to my AddTimer line, which should be better without the '==true' sign anyway.
Anyhoo; Cheers for correcting my idiotic error. The script works now.
Edit: QUESTION!
I rewrote the script to make it simpler, I got it down to this ;
Quote:C_LanternOut(string &in asParent...Etc)
{
if (GetLanternActive() )
AddTimer("", 0.45f, "C_LanternOut"); //Recurse until False.
else
PlaySoundAtEntity("", "enabled.snt", "Player", 0, false);
}
The problem is that Timer is not able to trigger C_LanternOut. Do I need an argument "String &in asTimer" in order to allow it to callback to a function? The script worked with what I started with...
EDIT : The answer would be ; yes.
Quote:OnStart()
{
SetLocalVarInt("Flag_LanternOut", 0);
}
void C_LanternOut(string &in asParent, string &in asChild, int alState) //Player has walked into the area.
{
if (GetLanternActive()){
AddTimer("", 0.2f, "CT_LanternOut");
SetLocalVarInt("Flag_LanternOut", 0);
}
else PlaySoundAtEntity("", "enabled.snt", "Player", 0, false);
}
void CT_LanternOut(string &in asTimer)
{
if (GetLanternActive()){
AddTimer("", 0.2f, "CT_LanternOut");
SetLocalVarInt("Flag_LanternOut", 0);
}
else
{
if (GetLocalVarInt("Flag_LanternOut")!=0)
PlaySoundAtEntity("", "enabled.snt", "Player", 0, false);
else{
SetLocalVarInt("Flag_LanternOut", 1);
AddTimer("", 0.85, "CT_LanternOut");
}}}
If anyone ever, for any reason, resonates with this idea. That's an example. Cool script mate, kind of inspired me a little.
Anyway, could be just me, but if you're uploading scripts, if you could make it bigger, more light, it'd be easier to read. Like:
OnStart()
{
SetLocalVarInt("Flag_LanternOut", 0);
}
void C_LanternOut(string &in asParent, string &in asChild, int alState) //Player has walked into the area.
{
if (GetLanternActive())
{
AddTimer("", 0.2f, "CT_LanternOut");
SetLocalVarInt("Flag_LanternOut", 0);
}
else
PlaySoundAtEntity("", "enabled.snt", "Player", 0, false);
}
void CT_LanternOut(string &in asTimer)
{
if (GetLanternActive())
{
AddTimer("", 0.2f, "CT_LanternOut");
SetLocalVarInt("Flag_LanternOut", 0);
}
else
{
if (GetLocalVarInt("Flag_LanternOut")!=0)
PlaySoundAtEntity("", "enabled.snt", "Player", 0, false);
else
{
SetLocalVarInt("Flag_LanternOut", 1);
AddTimer("", 0.85, "CT_LanternOut");
}
}
}
GL ! (^ might be a little odd, but you get the point)
(This post was last modified: 08-08-2012, 04:02 PM by Theforgot3n1.)
|
|
08-08-2012, 03:57 PM |
|
Solipsist
Junior Member
Posts: 29
Threads: 5
Joined: Aug 2012
Reputation:
0
|
RE: No matching signature to AddTimer
(08-08-2012, 03:57 PM)Theforgot3n1 Wrote: GL ! (^ might be a little odd, but you get the point) Cheers, I honestly tried to use the Code format, but it jacked up my order even harder than Quote..
'Trying now further experiment with the location of the player's view; player turn 180 degrees, turn again, BAM. Stuff in face.
All of this is just to work more efficiently with any future projects.
P.S: Anyway to constraint / tie a child area-script to be moving along the parent Player? (Let's say, a like a spotlight always looking and moving alongside the player)
I know how to do that in Source, alas I did not quite seen any proof of dynamic objects in HPL2 =S
P.P.S: Well, as the problem is solved..Let us let this thread sink.
Answer my question with a PM, please.
|
|
08-09-2012, 09:31 AM |
|
|