Frictional Games Forum (read-only)
[SCRIPT] Need help with my script - 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] Need help with my script (/thread-21618.html)



Need help with my script - ooadrianoo - 05-25-2013

Hello everyone,
this script doesn't work. "icounter" must be declared and expression must be in boolean type.

PHP Code:
void OnStart()
{
int icounter 1;
}

void counter(string &in asStickyAreastring &in asBodyName)
{
if (
icounter 2) ++icounter
Here^ "icounter" should be declared
PHP Code:
else GiveSanityBoostSmall();


I don't need to declare "icounter". I could be in boolean type but I don't know why it doesn't work this way.

Any suggestions?


RE: Need help with my script - Bridge - 05-26-2013

icounter is a local variable, which is why the function counter does not recognize it.

EDIT: Also, it says your expression is not of type Boolean because icounter isn't declared, so it's meaningless. It's the same as saying: If three is less than banana then this.


RE: Need help with my script - TheGreatCthulhu - 05-26-2013

To make it a global variable (visible to every function) move it out of the OnStart() function. For example, like this:
PHP Code:
int icounter 1;

void OnStart()
{
}

void counter(string &in asStickyAreastring &in asBodyName)
{
    if (
icounter 2) ++icounter
    else 
GiveSanityBoostSmall();




RE: Need help with my script - ooadrianoo - 05-26-2013

(05-26-2013, 12:58 AM)TheGreatCthulhu Wrote: To make it a global variable (visible to every function) move it out of the OnStart() function. For example, like this:
PHP Code:
int icounter 1;

void OnStart()
{
}

void counter(string &in asStickyAreastring &in asBodyName)
{
    if (
icounter 2) ++icounter
    else 
GiveSanityBoostSmall();


Thanks! Now it works, you deserved a reputation Smile


RE: Need help with my script - Bridge - 05-26-2013

http://omnigeek.robmiracle.com/2011/10/14/understanding-scope-for-beginning-programmers/