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
Script Help for(int) [SOLVED]
Lizard Offline
Member

Posts: 174
Threads: 23
Joined: Jul 2012
Reputation: 5
#1
for(int) [SOLVED]

Hey guys.

Im having a bit of a problem, that hope you guys can help with.
I keep getting these errors:

No matching signatures to SetLightVisible(string@&)

No conversion from 'bool' to 'int' available

I have working alittle back and forth, but cant find a solution to the problem, so hope you guys can help me out

PHP Code: (Select All)
void FuncLightsOut(string &in asParentstring &in asChildint alState)
{
    for(
int i=1;i<=13;i++)
    {
        if(
SetLightVisible("Lamp_"+i) == true)
        {        
            
SetLightVisible("Lamp_"+ifalse);
            
CreateParticleSystemAtEntity("ps_dust_whirl""ps_dust_whirl.ps""Lamp_"+ifalse);
            
PlaySoundAtEntity("laugh""00_laugh.ogg""Player"0false);
            
GiveSanityDamage(40true);
        }
    }


CURRENT PROJECT:
A Fathers Secret == Just started
(This post was last modified: 07-28-2014, 12:17 PM by Lizard.)
07-27-2014, 05:36 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#2
RE: for(int)

(07-27-2014, 05:36 PM)ZereboO Wrote: Hey guys.

Im having a bit of a problem, that hope you guys can help with.
I keep getting these errors:

No matching signatures to SetLightVisible(string@&)

No conversion from 'bool' to 'int' available

I have working alittle back and forth, but cant find a solution to the problem, so hope you guys can help me out

PHP Code: (Select All)
void FuncLightsOut(string &in asParentstring &in asChildint alState)
{
    for(
int i=1;i<=13;i++)
    {
        if(
SetLightVisible("Lamp_"+i) == true)
        {        
            
SetLightVisible("Lamp_"+ifalse);
            
CreateParticleSystemAtEntity("ps_dust_whirl""ps_dust_whirl.ps""Lamp_"+ifalse);
            
PlaySoundAtEntity("laugh""00_laugh.ogg""Player"0false);
            
GiveSanityDamage(40true);
        }
    }


PHP Code: (Select All)
SetLightVisible("Lamp_"+i) == true 
That function doesn't exist. The argument is SetLightVisible(string& asLightName, bool abVisible).

"Veni, vidi, vici."
"I came, I saw, I conquered."
07-27-2014, 05:50 PM
Find
Rapture Offline
Posting Freak

Posts: 1,078
Threads: 79
Joined: May 2011
Reputation: 30
#3
RE: for(int)

Are you sure it's that function that is causing the issue (It looks correct to me)? Try commenting it out, or the individual sections to see if the problem goes away...


IMO, to make it easier to read. I would put spaces between the ("Lamp_" + 1) parts.

Also including the (int i=1; i<=13; i++)

Edit: What he said above, didn't look at the name of the function carefully. :x
(This post was last modified: 07-27-2014, 05:51 PM by Rapture.)
07-27-2014, 05:51 PM
Find
Lizard Offline
Member

Posts: 174
Threads: 23
Joined: Jul 2012
Reputation: 5
#4
RE: for(int)

Ops Smile Too used to only use if with states and not booleans

Now it says: "Expression must be of boolean type" which for me it looks like it is?

PHP Code: (Select All)
void FuncLightsOut(string &in asParentstring &in asChildint alState)
{
    for(
int i <= 13 ++)
    {
        if(
SetLightVisible("Lamp_" itrue))
        {        
            
SetLightVisible("Lamp_" ifalse);
            
CreateParticleSystemAtEntity("ps_dust_whirl""ps_dust_whirl.ps""Lamp_" ifalse);
            
PlaySoundAtEntity("laugh""00_laugh.ogg""Player"0false);
            
GiveSanityDamage(40true);
        }
    }


CURRENT PROJECT:
A Fathers Secret == Just started
07-27-2014, 06:13 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#5
RE: for(int)

SetLightVisible does not return a boolean, so it cannot be used in a boolean-asking if-statement. That function will simply change an actual light, not tell you what it is.

Setter scripts can very rarely be used in if-statements. This is a setter, hence the SetLightVisible. Getter scripts are made for questioning. If there was one called GetLightVisible, it would likely return true if the light specified was visible (just like your original setup).

Only scripts that return a specific value can be used in if-statements. This is because you're comparing two values. For example you can compare a string with a string, an int with an int or a boolean with a boolean. Comparing cross-values can be tricky, but whenever you see that a script has the type "void," that means it's not returning anything. It's like comparing nothing to something; doesn't work.

What you can do here instead is to use local variables. Whenever you enable a light, use SetLocalVarInt("Lamp", 1);
Then in the question, use if(GetLocalVarInt("Lamp") == 1) instead.

(This post was last modified: 07-27-2014, 07:35 PM by Mudbill.)
07-27-2014, 07:32 PM
Find
Lizard Offline
Member

Posts: 174
Threads: 23
Joined: Jul 2012
Reputation: 5
#6
RE: for(int)

(07-27-2014, 07:32 PM)Mudbill Wrote: Only scripts that return a specific value can be used in if-statements. This is because you're comparing two values. For example you can compare a string with a string, an int with an int or a boolean with a boolean. Comparing cross-values can be tricky, but whenever you see that a script has the type "void," that means it's not returning anything. It's like comparing nothing to something; doesn't work.

Never really thought of that, but a very good thing to know. Thanks.


(07-27-2014, 07:32 PM)Mudbill Wrote: What you can do here instead is to use local variables. Whenever you enable a light, use SetLocalVarInt("Lamp", 1);
Then in the question, use if(GetLocalVarInt("Lamp") == 1) instead.

I was thinking about the LocalVarInt, but I dont know how to script it up with the LocalVarInt so that the only lamp/torches that the player egnites that gets blown out

CURRENT PROJECT:
A Fathers Secret == Just started
(This post was last modified: 07-27-2014, 07:46 PM by Lizard.)
07-27-2014, 07:44 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#7
RE: for(int)

SetEntityCallbackFunc has a type called OnIgnite. Use that and trigger a variable along with it.

PHP Code: (Select All)
void MyFunc(string &in asEntitystring &in asType)
{
    
SetLocalVarInt("Lamp"1); //???


But what are you trying to do here? Why do you have a for-loop? This doesn't sound like a place you'd want one because if that if-statement were to pass, it would run the script 13 times, resulting in 13 sounds overlapping and a total of 13x40 damage to sanity.

07-27-2014, 11:32 PM
Find
Lizard Offline
Member

Posts: 174
Threads: 23
Joined: Jul 2012
Reputation: 5
#8
RE: for(int)

The player is walking up a spiral staricase that leads to another room where the player picks up a key that activates an area when picked up. When the player enters the area on his way back then all the lights that was ignited on the way up, should be blown out and then make the player lose 40 sanity points

CURRENT PROJECT:
A Fathers Secret == Just started
07-28-2014, 11:15 AM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#9
RE: for(int)

Wouldn't turning off all the candles result in them being blown out whether they are on either way?

A way to work around it, but is a little tedious and not exactly efficient programming;
Duplicate your lamps, set them to be unlit and in a way, merge them within your lamp. You can disable their visibility if you wish, but you'll need more lamps for that. Change the names of the lit ones to suit your code (assuming you have done this already), then use SetEntityActive() to disable the lit candles/lamps.

Example:
PHP Code: (Select All)
void blow_candles()
{
for(
int i 1<= 13i++)
{
 
SetEntityActive("light_"+ifalse); //disable the lit lights
}

for(
int i 14 <= 27 i++)
{
 
SetEntityActive("light_"+itrue); //enable the unlit lights - if you have them
}


Discord: Romulator#0001
[Image: 3f6f01a904.png]
07-28-2014, 11:51 AM
Find
Lizard Offline
Member

Posts: 174
Threads: 23
Joined: Jul 2012
Reputation: 5
#10
RE: for(int)

(07-28-2014, 11:51 AM)Romulator Wrote: Wouldn't turning off all the candles result in them being blown out whether they are on either way?

A way to work around it, but is a little tedious and not exactly efficient programming;
Duplicate your lamps, set them to be unlit and in a way, merge them within your lamp. You can disable their visibility if you wish, but you'll need more lamps for that. Change the names of the lit ones to suit your code (assuming you have done this already), then use SetEntityActive() to disable the lit candles/lamps.

Example:
PHP Code: (Select All)
void blow_candles()
{
for(
int i 1<= 13i++)
{
 
SetEntityActive("light_"+ifalse); //disable the lit lights
}

for(
int i 14 <= 27 i++)
{
 
SetEntityActive("light_"+itrue); //enable the unlit lights - if you have them
}


That would be a way to solve it.


Thanks for your support. I think I know how I want this to go off without any troubles.

Again thanks for the help guys

CURRENT PROJECT:
A Fathers Secret == Just started
07-28-2014, 12:02 PM
Find




Users browsing this thread: 3 Guest(s)