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


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is wrong with this script! *Different script problem*
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#1
What is wrong with this script! *Different script problem*

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_2" , true);
}



AddEntityCollideCallback{"Player" , "ScriptArea_2" , "MonsterFunc1" , true , 1};

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_1" , true);
}



void StartPlayerLookAt(ScriptArea_3, 50, 40, onlook);

void TimerDoneLookAt(string &in asTimer)
{
StopPlayerLookAt();
}






ALWAYS, it ALWAYS said err at line 14,25. expected identifier, the bold part in the script is line 14,25. Don't i already have an identifier, and yes, i have gone countless times to the script recollection, but that's where i got the script from, and it's not working. Any HELP PLEASE
(This post was last modified: 05-07-2011, 01:29 AM by flamez3.)
05-07-2011, 01:02 AM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#2
RE: What is wrong with this script!

AddEntityCollideCallback{"Player" , "ScriptArea_2" , "MonsterFunc1" , true , 1};

void StartPlayerLookAt(ScriptArea_3, 50, 40, onlook);
Those two lines are not inside a function. The latter line, unless defining a function should not be preceded by the void keyword. Additionally there are two identical (in signature) functions called "MonsterFunc1" with the same signature, this is ambiguous and will also make the compiler throw an error.
(This post was last modified: 05-07-2011, 01:23 AM by Apjjm.)
05-07-2011, 01:22 AM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#3
RE: What is wrong with this script!

(05-07-2011, 01:22 AM)Apjjm Wrote:
AddEntityCollideCallback{"Player" , "ScriptArea_2" , "MonsterFunc1" , true , 1};

void StartPlayerLookAt(ScriptArea_3, 50, 40, onlook);
Those two lines are not inside a function. The latter line, unless defining a function should not be preceded by the void keyword. Additionally there are two identical (in signature) functions called "MonsterFunc1" with the same signature, this is ambiguous and will also make the compiler throw an error.

thanks for the help, but i decided to scrap the first event, now it's just this
PHP Code: (Select All)
////////////////////////////
// Run first time starting map
void OnStart()
{
  
AddEntityCollideCallback("Player" "ScriptArea_1" "MonsterFunc1" true 1);
}
void MonsterFunc1(string &in asParent string &in asChild int alState)
{
  
SetEntityActive("servant_grunt_2" true);
}



void OnEnter()
 ;
StartPlayerLookAt("ScriptArea_3"9.09.0onlook);

void TimerDoneLookAt(string &in asTimer)
{
  
StopPlayerLookAt();
}

AddTimer(""5.5f"TimerDoneLookAt"); 

it gives me errors like this

FATAL ERROR : Could not load script file
'custom stories.......(etc)
main (15,20) : ERR : Expected identifier
main (22,9) : ERR : Expected identifier


i have no idea what i did wrong, can you or anyone help me with this script?
05-07-2011, 01:27 AM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#4
RE: What is wrong with this script!

(05-07-2011, 01:27 AM)flamez3 Wrote: i have no idea what i did wrong, can you or anyone help me with this script?
try the following:
void OnStart()
{
  AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}

void OnEnter()
{
  StartPlayerLookAt("ScriptArea_3", 9.0, 9.0, onlook);
  AddTimer("", 5.5f, "TimerDoneLookAt");
}

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
  SetEntityActive("servant_grunt_2" , true);
}

void TimerDoneLookAt(string &in asTimer)
{
  StopPlayerLookAt();
}

I am assuming here you want the timer to start when you call the StartPlayerLookAt function. Remember that everything you want to happen in a function must be wrapped in the {}'s, and anything you want to happen at the start of the map called in either onStart() or onEnter():
//Example:
void SomeFunction()
{
   function1("function 1");
   function2(0.1f);
   int x = 10;
   function3(x);
  }
(This post was last modified: 05-07-2011, 01:34 AM by Apjjm.)
05-07-2011, 01:33 AM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#5
RE: What is wrong with this script!

(05-07-2011, 01:33 AM)Apjjm Wrote:
(05-07-2011, 01:27 AM)flamez3 Wrote: i have no idea what i did wrong, can you or anyone help me with this script?
try the following:
void OnStart()
{
  AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}

void OnEnter()
{
  StartPlayerLookAt("ScriptArea_3", 9.0, 9.0, onlook);
  AddTimer("", 5.5f, "TimerDoneLookAt");
}

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
  SetEntityActive("servant_grunt_2" , true);
}

void TimerDoneLookAt(string &in asTimer)
{
  StopPlayerLookAt();
}

I am assuming here you want the timer to start when you call the StartPlayerLookAt function. Remember that everything you want to happen in a function must be wrapped in the {}'s, and anything you want to happen at the start of the map called in either onStart() or onEnter():
//Example:
void SomeFunction()
{
   function1("function 1");
   function2(0.1f);
   int x = 10;
   function3(x);
  }

I think that disabled the other problems, now it just says
main (8,47) Onlook is not decalared


any ideas?
(This post was last modified: 05-07-2011, 01:44 AM by flamez3.)
05-07-2011, 01:41 AM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#6
RE: What is wrong with this script!

(05-07-2011, 01:41 AM)flamez3 Wrote: I think that disabled the other problems, now it just says
main (8,47) Onlook is not decalared
any ideas?

What do you intend "Onlook" to be? Currently onlook is an undefined variable in your script - for now try "" instead.
Onlook, though, is actually supposed to name to a callback function in a string (or be "" if you don't want one. This works in the same way as you defined the callback routine for the timer.) when the player actually is looking at the target.
(This post was last modified: 05-07-2011, 01:53 AM by Apjjm.)
05-07-2011, 01:53 AM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#7
RE: What is wrong with this script!

(05-07-2011, 01:53 AM)Apjjm Wrote:
(05-07-2011, 01:41 AM)flamez3 Wrote: I think that disabled the other problems, now it just says
main (8,47) Onlook is not decalared
any ideas?

What do you intend "Onlook" to be? Currently onlook is an undefined variable in your script - for now try "" instead.
Onlook, though, is actually supposed to name to a callback function in a string (or be "" if you don't want one. This works in the same way as you defined the callback routine for the timer.) when the player actually is looking at the target.

THANK YOU, One problem, How do i make it so after you go past a point in the game, it looks where i made the scriptarea_3, because now it's just looking at it the start of the game.
05-07-2011, 02:00 AM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#8
RE: What is wrong with this script!

(05-07-2011, 02:00 AM)flamez3 Wrote: THANK YOU, One problem, How do i make it so after you go past a point in the game, it looks where i made the scriptarea_3, because now it's just looking at it the start of the game.

You would have to create a new script area, which like your monster one, is triggered when the player collides with it, though triggers a different callback function. This can then make the player look at a different area. If you called this new script area "CollisionLookAt_1" (as I strongly suggest giving your objects names that summise their function a little), then you could try changing your code as follows:

//Add to the onStart() routine
AddEntityCollideCallback("Player" , "CollisionLookAt_1" , "LookatArea_1" , true , 1);

//Place outside of any existing functions:
void LookatArea_1(string &in asParent , string &in asChild , int alState)
{
   StartPlayerLookAt("ScriptArea_3", 9.0, 9.0, "");
   AddTimer("", 5.5f, "TimerDoneLookAt");
}
If you understand what is going on here, you should be able to apply this approach to any number of areas, and make the callback function do other things if you need it to.
(This post was last modified: 05-07-2011, 02:11 AM by Apjjm.)
05-07-2011, 02:08 AM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#9
RE: What is wrong with this script!

(05-07-2011, 02:08 AM)Apjjm Wrote:
(05-07-2011, 02:00 AM)flamez3 Wrote: THANK YOU, One problem, How do i make it so after you go past a point in the game, it looks where i made the scriptarea_3, because now it's just looking at it the start of the game.

You would have to create a new script area, which like your monster one, is triggered when the player collides with it, though triggers a different callback function. This can then make the player look at a different area. If you called this new script area "CollisionLookAt_1" (as I strongly suggest giving your objects names that summise their function a little), then you could try changing your code as follows:

//Add to the onStart() routine
AddEntityCollideCallback("Player" , "CollisionLookAt_1" , "LookatArea_1" , true , 1);

//Place outside of any existing functions:
void LookatArea_1(string &in asParent , string &in asChild , int alState)
{
   StartPlayerLookAt("ScriptArea_3", 9.0, 9.0, "");
   AddTimer("", 5.5f, "TimerDoneLookAt");
}
If you understand what is going on here, you should be able to apply this approach to any number of areas, and make the callback function do other things if you need it to.

Thanks for this help you gave me, it did the job(it still looks at it in the start but it does look at it when i walk over the script. If there was a reputation button, i would spam it on you lol. thanks
05-07-2011, 02:21 AM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#10
RE: What is wrong with this script!

(05-07-2011, 02:21 AM)flamez3 Wrote: Thanks for this help you gave me, it did the job(it still looks at it in the start but it does look at it when i walk over the script. If there was a reputation button, i would spam it on you lol. thanks
Not a problem Wink. If you want to stop the "lookAt" function when the room starts, just remove the two lines from the onEnter() function, as these start the "lookAt" and start the timer to stop the "lookAt".
05-07-2011, 02:29 AM
Find




Users browsing this thread: 1 Guest(s)