Frictional Games Forum (read-only)

Full Version: for(int) [SOLVED]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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:
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);
        }
    }

(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:
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:
SetLightVisible("Lamp_"+i) == true 
That function doesn't exist. The argument is SetLightVisible(string& asLightName, bool abVisible).
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
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:
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);
        }
    }

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.
(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
SetEntityCallbackFunc has a type called OnIgnite. Use that and trigger a variable along with it.

PHP Code:
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.
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
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:
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
}

(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:
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
Pages: 1 2