![]() |
[SCRIPT] for(int) [SOLVED] - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: [SCRIPT] for(int) [SOLVED] (/thread-25765.html) Pages:
1
2
|
for(int) [SOLVED] - Lizard - 07-27-2014 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 asParent, string &in asChild, int alState) RE: for(int) - PutraenusAlivius - 07-27-2014 (07-27-2014, 05:36 PM)ZereboO Wrote: Hey guys. PHP Code: SetLightVisible("Lamp_"+i) == true RE: for(int) - Rapture - 07-27-2014 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 RE: for(int) - Lizard - 07-27-2014 Ops ![]() Now it says: "Expression must be of boolean type" which for me it looks like it is? PHP Code: void FuncLightsOut(string &in asParent, string &in asChild, int alState) RE: for(int) - Mudbill - 07-27-2014 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. RE: for(int) - Lizard - 07-27-2014 (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); 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 RE: for(int) - Mudbill - 07-27-2014 SetEntityCallbackFunc has a type called OnIgnite. Use that and trigger a variable along with it. PHP Code: void MyFunc(string &in asEntity, string &in asType) 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. RE: for(int) - Lizard - 07-28-2014 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 RE: for(int) - Romulator - 07-28-2014 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() RE: for(int) - Lizard - 07-28-2014 (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? 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 |