Frictional Games Forum (read-only)
i forgot how to script :c - 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: i forgot how to script :c (/thread-19547.html)

Pages: 1 2 3 4


RE: i forgot how to script :c - TheGreatCthulhu - 12-17-2012

(12-17-2012, 12:13 PM)nightsxp Wrote: what;s wrong??


AddEntityCollideCallback("Player","Area ","lantern");




void gothrough(string &in asParent, string &in asChild, int alState)
{
if(HasItem("lantern") == true)
{

SetEntityActive("block", false);


}


}


i actually want: if player has lantern he can go throuh ''Area''
This is wrong: AddEntityCollideCallback("Player","Area ","lantern");

That function takes 5 parameters, not 3; look at the declaration (this is the declaration, not how you call it!):
Code:
void AddEntityCollideCallback(
    string& asParentName,       // your "Player" parameter
    string& asChildName,        // your "Area" parameter
    string& asFunction,          // callback function - your "lantern" parameter <---- watch it!
    bool abDeleteOnCollide,     // pass either true or false here
    int alStates                     // check the docs to see what to pass here (either -1, 0, or 1)
    );

Next, if you want the gothrough() function to be called by the game when the player and the area collide, then you have to specify it's name "gothrough" instead of "lantern" above - otherwise the engine will look for a callback function called "lantern", and it will never call this function.

Also, when you have troubles, always describe the errors in more detail - what did you expect to happen vs what actually happens, what are the error messages, if any, etc...

P.S. BTW, if you need a bit more guidance, the proper way to call AddEntityCollideCallback() is (asuming you want gothrough as your callback):
AddEntityCollideCallback("Player", "Area ", "gothrough", true, 1);


RE: i forgot how to script :c - nightsxp - 12-17-2012

(12-17-2012, 01:13 PM)TheGreatCthulhu Wrote:
(12-17-2012, 12:13 PM)nightsxp Wrote: what;s wrong??


AddEntityCollideCallback("Player","Area ","lantern");




void gothrough(string &in asParent, string &in asChild, int alState)
{
if(HasItem("lantern") == true)
{

SetEntityActive("block", false);


}


}


i actually want: if player has lantern he can go throuh ''Area''
This is wrong: AddEntityCollideCallback("Player","Area ","lantern");

That function takes 5 parameters, not 3; look at the declaration (this is the declaration, not how you call it!):
Code:
void AddEntityCollideCallback(
    string& asParentName,       // your "Player" parameter
    string& asChildName,        // your "Area" parameter
    string& asFunction,          // callback function - your "lantern" parameter <---- watch it!
    bool abDeleteOnCollide,     // pass either true or false here
    int alStates                     // check the docs to see what to pass here (either -1, 0, or 1)
    );

Next, if you want the gothrough() function to be called by the game when the player and the area collide, then you have to specify it's name "gothrough" instead of "lantern" above - otherwise the engine will look for a callback function called "lantern", and it will never call this function.

Also, when you have troubles, always describe the errors in more detail - what did you expect to happen vs what actually happens, what are the error messages, if any, etc...

P.S. BTW, if you need a bit more guidance, the proper way to call AddEntityCollideCallback() is (asuming you want gothrough as your callback):
AddEntityCollideCallback("Player", "Area ", "gothrough", true, 1);
Thanks yo you all :I i will try to understand.


RE: i forgot how to script :c - nightsxp - 12-19-2012

hi again x33 how can i teleport player from Area1 to Area2?and after 6 seconds he will return to Area1?


RE: i forgot how to script :c - FlawlessHappiness - 12-19-2012

You use this line
TeleportPlayer("Area2");

The other one is just a timer. You know how to use them right?


RE: i forgot how to script :c - nightsxp - 12-19-2012

(12-19-2012, 08:12 AM)beecake Wrote: You use this line
TeleportPlayer("Area2");

The other one is just a timer. You know how to use them right?
Maybe x3 Thanks a lot.


RE: i forgot how to script :c - FlawlessHappiness - 12-19-2012

Let's say you call a timer called TeleportTimer
You call these 2 lines:
AddTimer("Area2", 0, "TeleportTimer");
AddTimer("Area1", 6, "TeleportTimer");


void TeleportTimer(string &in asTimer)
{
if(asTimer == "Area1")
{
TeleportPlayer("Area1");
}

if(asTimer == "Area2")
{
TeleportPlayer("Area2");
}
}


RE: i forgot how to script :c - Your Computer - 12-19-2012

TeleportPlayer already takes in only one string, so it's much simpler to do

PHP Code:
AddTimer("PlayerStartAreaName"6"TeleportPlayer"); 



RE: i forgot how to script :c - FlawlessHappiness - 12-19-2012

(12-19-2012, 11:28 AM)Your Computer Wrote: TeleportPlayer already takes in only one string, so it's much simpler to do

PHP Code:
AddTimer("PlayerStartAreaName"6"TeleportPlayer"); 
Yea, but might be harder to understand Smile


RE: i forgot how to script :c - TheGreatCthulhu - 12-19-2012

How is that harder to understand? It's the same thing, except the call is now made directly. That's like saying that it's easier to write if you tape the pen at the end of a long stick, and use the stick instead Tongue

Also, even with your indirect approach, the if statements are not required in this scenario - you can just pass the parameter along.


RE: i forgot how to script :c - FlawlessHappiness - 12-19-2012

Ok sorry