Frictional Games Forum (read-only)
[SCRIPT] Hi, its me again ;d - 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] Hi, its me again ;d (/thread-30136.html)

Pages: 1 2 3


Hi, its me again ;d - NotASkrub - 06-19-2015

So, can someone tell me, where is my mistake with this?

PHP Code:
void OnStart()
{
    
TeleportPlayer("PlayerStartArea_1");
    
AddEntityCollideCallback("Player""Quest1""Tired"true1);
    
AddEntityCollideCallback("Player""Quest1Done""TiredDone"true1);
;}
void Tired(string &in asParentstring &in asChildint alState)
{
    
AddQuest("Tired""Tired");
;}
void TiredDone(string &in asParentstring &in asChildint alState)
{
    
CompleteQuest("Tired""Tired");
    
AddTimer("FadeOutTimer"float (0.1), "FadeOutFunc");
    
;}
void FadeOutFunc(string &in asTimer)
{
    
FadeOut(float (2));
    
AddTimer("FadeInTimer"float (0.1), "FadeInFunc");
;}
void FadeInFunc(string &in asTimer)
{
    
FadeIn(float (4));
;} 
What it has to do is the following:
1. You enter an area (e.g script) and get a quest that you're tired.
2. You go in the area realy close to your bed.
3. You fadeout (go to sleep) and then fade in (wake up) with the first quest finished.
But for some reason, it only finishes the quest..


RE: Hi, its me again ;d - FlawlessHappiness - 06-19-2015

You're getting the idea, but it's supposed to look like this:

PHP Code:
void OnStart()
{
    
TeleportPlayer("PlayerStartArea_1");
    
AddEntityCollideCallback("Player""Quest1""Tired"true1);
    
AddEntityCollideCallback("Player""Quest1Done""TiredDone"true1);
}
void Tired(string &in asParentstring &in asChildint alState)
{
    
AddQuest("Tired""Tired");
}
void TiredDone(string &in asParentstring &in asChildint alState)
{
    
CompleteQuest("Tired""Tired");
    
AddTimer("FadeOutTimer"0.1f"FadeOutFunc");
    
}
void FadeOutFunc(string &in asTimer)
{
    
FadeOut(2);
    
AddTimer("FadeInTimer"0.1f"FadeInFunc");
}
void FadeInFunc(string &in asTimer)
{
    
FadeIn(5)


Mistakes
When you have to write a float, all you have to do is write a number with a decimal, and then follow up with f.
Example:
1.0f

When ending a function you wrote ";}". It's just "}"
Example:
void Function()
{

}


RE: Hi, its me again ;d - NotASkrub - 06-19-2015

(06-19-2015, 02:12 AM)FlawlessHappiness Wrote: You're getting the idea, but it's supposed to look like this:

PHP Code:
void OnStart()
{
    
TeleportPlayer("PlayerStartArea_1");
    
AddEntityCollideCallback("Player""Quest1""Tired"true1);
    
AddEntityCollideCallback("Player""Quest1Done""TiredDone"true1);
}
void Tired(string &in asParentstring &in asChildint alState)
{
    
AddQuest("Tired""Tired");
}
void TiredDone(string &in asParentstring &in asChildint alState)
{
    
CompleteQuest("Tired""Tired");
    
AddTimer("FadeOutTimer"0.1f"FadeOutFunc");
    
}
void FadeOutFunc(string &in asTimer)
{
    
FadeOut(2);
    
AddTimer("FadeInTimer"0.1f"FadeInFunc");
}
void FadeInFunc(string &in asTimer)
{
    
FadeIn(5)


Mistakes
When you have to write a float, all you have to do is write a number with a decimal, and then follow up with f.
Example:
1.0f

When ending a function you wrote ";}". It's just "}"
Example:
void Function()
{

}
Thank you for the code help, and no, for me if I dont write ";" before the end of the "}"
it will give me an error expecting a ";" before "}"
;d


RE: Hi, its me again ;d - Romulator - 06-19-2015

(06-19-2015, 02:24 AM)NotASkrub Wrote: Thank you for the code help, and no, for me if I dont write ";" before the end of the "}"
it will give me an error expecting a ";" before "}"
;d

Really? o.0

That is awfully strange. The reason for that error is to explain that at a certain line (it could be the one they mention, or any before it, usually within the same function bracket), that you're missing a semicolon at the end of a function.

Say I have these:
PHP Code:
AddEntityCollideCallback("Player""scr_jumpscare""activate_jumpscare"true0)
AddEntityCollideCallback("Playee""scr_scarymusic""activate_scarymusic"true0); 

The first Callback above will error the whole code, since it is missing a semicolon. It can be fixed by putting a semicolon on the new line, but it looks wrong from a coder's perspective.
So if we put a semicolon on the end, or delete the whole line, then the error should not show. (And in my case, I would delete it, because very little jumpscares are good scares).


RE: Hi, its me again ;d - FlawlessHappiness - 06-19-2015

I believe the error you got was because of the "float (4)".
Try with my fixed version. See if you get any errors.


RE: Hi, its me again ;d - NotASkrub - 06-19-2015

I tried, I dont get errors, its just that the fade out does not start and also same goes for fade in..

Edit, its 05:00 am here and I'm going to sleep, feel free to answer and do suggestions, when I get back from school I will check them out ;d


RE: Hi, its me again ;d - Mudbill - 06-19-2015

(From Flawless' example. PS: You missed a semi-colon by the end)

PHP Code:
void FadeOutFunc(string &in asTimer)
{
    
FadeOut(2);
    
AddTimer("FadeInTimer"0.1f"FadeInFunc");
}

void FadeInFunc(string &in asTimer)
{
    
FadeIn(5);


@OP
This right here won't work the way you want it. It starts off going towards black, but before it manages to do anything, it starts going towards being visible again. The timer that follows FadeOut is too quick for you to notice the FadeOut. Make sure your timer starts AFTER the time of the FadeOut (unless you don't want it to be fully black).

So to fix this, you either edit the time of the FadeOut to be shorter than the timer, or edit the timer to be longer than the FadeOut. For example:

PHP Code:
void FadeOutFunc(string &in asTimer)
{
    
FadeOut(2);
    
AddTimer("FadeInTimer"2.1f"FadeInFunc");
}

void FadeInFunc(string &in asTimer)
{
    
FadeIn(5);




RE: Hi, its me again ;d - NotASkrub - 06-19-2015

(06-19-2015, 08:03 AM)Mudbill Wrote: (From Flawless' example. PS: You missed a semi-colon by the end)

PHP Code:
void FadeOutFunc(string &in asTimer)
{
    
FadeOut(2);
    
AddTimer("FadeInTimer"0.1f"FadeInFunc");
}

void FadeInFunc(string &in asTimer)
{
    
FadeIn(5);


@OP
This right here won't work the way you want it. It starts off going towards black, but before it manages to do anything, it starts going towards being visible again. The timer that follows FadeOut is too quick for you to notice the FadeOut. Make sure your timer starts AFTER the time of the FadeOut (unless you don't want it to be fully black).

So to fix this, you either edit the time of the FadeOut to be shorter than the timer, or edit the timer to be longer than the FadeOut. For example:

PHP Code:
void FadeOutFunc(string &in asTimer)
{
    
FadeOut(2);
    
AddTimer("FadeInTimer"2.1f"FadeInFunc");
}

void FadeInFunc(string &in asTimer)
{
    
FadeIn(5);


Ah, I see what you mean MudbillI, I guess I misunderstood the script.. I started watching TechOFreak128 in youtube and from him I started learning how to script and make CS..
What he said was that every command(code) is followed from top to bottom, and I trough that it will not execute the next code before the ones first:
1. I have the fadeout code, and untill that is fully executed, it will not proceed to the next one (e.g the timer)..
Again, thank you for the help!
Will keep that in mind!
Expect further questions if I get stuck again ;d


RE: Hi, its me again ;d - NotASkrub - 06-20-2015

Heya, I'm here with another question! ;d

PHP Code:
void PlayerScare(string &in asParentstring &in asChildstring &in alState)
{
    if (
GetSwingDoorClosed() == false)
        {
            
SetSwingDoorClosed("AwaysLockedDoor"bool (true), "");
            
AddTimer("Lock"float (1.0), "LockDoor");
        }
;}

void LockDoor(string &in asTimer)
{
    
SetSwingDoorLocked("AwaysLockedDoor"bool (true), "");
    
PlaySoundAtEntity("""lock_door.snt""Player"float (0.0), bool (false));
    
SetEntityActive("JumpScare"bool (true));
    
ShowEnemyPlayerPosition("JumpScare");
;} 
This is the code.
[Image: 38tOKDG.png]
This is the error, where is my mistake here? Because, as I saw others to do the same in their tutorials, like techofreak, mudbill etc..


RE: Hi, its me again ;d - DnALANGE - 06-20-2015

void PlayerScare(string &in asParent, string &in asChild, string &in alState)
{
if(GetSwingDoorClosed(asEntity) == false)
{
SetSwingDoorClosed("AwaysLockedDoor", true, "true");
AddTimer("Lock", float (1.0), "LockDoor");
}
}

Quote:SetSwingDoorClosed(string& asName, bool abClosed, bool abEffects);
has to be like this :
SetSwingDoorClosed("""Name of your door", true or false, true or false);

So choose OR true OR false,like :
PHP Code:
SetSwingDoorClosed("""Name of your door"true,false); 

For your script as it is now no need to write bool AND true.
Bool = true or false.

Here is an example from me, try playing with it :
PHP Code:
SetSwingDoorLocked("door1"falsefalse);
SetSwingDoorClosed("door1"falsefalse); 
-
PHP Code:
void Bathroomdoor(string &in asEntity)
{
    if(
GetSwingDoorLocked(asEntity) == true)

//DO SOMETHING HERE/ Put your script here. Only when touching the door and have (Bathroomdoor) set in your leveleditor as PlayerInteractCallBack.