Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
i forgot how to script :c
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#11
RE: i forgot how to script :c

(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!):
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);
(This post was last modified: 12-17-2012, 01:18 PM by TheGreatCthulhu.)
12-17-2012, 01:13 PM
Find
nightsxp Offline
Member

Posts: 53
Threads: 8
Joined: Sep 2011
Reputation: 0
#12
RE: i forgot how to script :c

(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!):
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.
(This post was last modified: 12-17-2012, 02:31 PM by nightsxp.)
12-17-2012, 01:31 PM
Find
nightsxp Offline
Member

Posts: 53
Threads: 8
Joined: Sep 2011
Reputation: 0
#13
RE: i forgot how to script :c

hi again x33 how can i teleport player from Area1 to Area2?and after 6 seconds he will return to Area1?
12-19-2012, 06:53 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#14
RE: i forgot how to script :c

You use this line
TeleportPlayer("Area2");

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

Trying is the first step to success.
12-19-2012, 08:12 AM
Find
nightsxp Offline
Member

Posts: 53
Threads: 8
Joined: Sep 2011
Reputation: 0
#15
RE: i forgot how to script :c

(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.
12-19-2012, 08:56 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#16
RE: i forgot how to script :c

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");
}
}

Trying is the first step to success.
12-19-2012, 11:02 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#17
RE: i forgot how to script :c

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

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

Tutorials: From Noob to Pro
12-19-2012, 11:28 AM
Website Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#18
RE: i forgot how to script :c

(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: (Select All)
AddTimer("PlayerStartAreaName"6"TeleportPlayer"); 
Yea, but might be harder to understand Smile

Trying is the first step to success.
12-19-2012, 11:36 AM
Find
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#19
RE: i forgot how to script :c

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.
12-19-2012, 02:17 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#20
RE: i forgot how to script :c

Ok sorry

Trying is the first step to success.
12-19-2012, 02:44 PM
Find




Users browsing this thread: 1 Guest(s)