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
Script Help How to make a "Wait" in the script.
iFondue Offline
Junior Member

Posts: 28
Threads: 6
Joined: Apr 2012
Reputation: 0
#11
RE: How to make a "Wait" in the script.

You mean like that, do you?


void OnStart()

{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1);
}


////////////////////////////
// Run when entering map
void OnEnter()

void LightOn(string &in asParent, string &in asChild, int alState)
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1);

StartPlayerLookAt("LookFrame", 20, 50, "");

SetLampLit("candlestick_1", true, true);

SetLampLit("candlestick_2", true, true);


AddTimer("light1", 0.5f, "TimerLight");
AddTimer("light2", 1, "TimerLight");
AddTimer("stopeffects", 1.2f, "TimerLight");

}

void TimerLight(string &in asTimer)
{

if(asTimer == "light1")
{
SetLampLit("candlestick_3", true, true);
SetLampLit("candlestick_4", true, true);
}
if(asTimer == "light2")
{
SetLampLit("candlestick_5", true, true);
SetLampLit("candlestick_6", true, true);
}
if(asTimer == "stopeffects")
{
StopPlayerLookAt();
}
}



It's always the same... the two first lamps lit, and all the others not... Sad


Greets

-iFondue
04-10-2012, 06:40 PM
Find
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#12
RE: How to make a "Wait" in the script.

My next question is, are there entities named "candlestick_3", 4, 5, and 6 on the map?

It should also be

void OnEnter()
{
}

Do you have a map_cache? If so, delete it.

04-10-2012, 06:45 PM
Find
iFondue Offline
Junior Member

Posts: 28
Threads: 6
Joined: Apr 2012
Reputation: 0
#13
RE: How to make a "Wait" in the script.

Yes there are candlestick_1, candlestick_2, candlestick_3 .....4,5,6 up to 12!

Changed the { } at on Enter, and deleted the cache.

Now the error comes: FATAL ERROR Could not load Script File.

Main (15/7) Expected '('
Main (32/7) Expected '('

What did I forget?
04-10-2012, 06:53 PM
Find
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#14
RE: How to make a "Wait" in the script.

Can you post the entire script (encase it in the code tags and the spoilers) so I can fully look at it.

By the way, the reason nothing was changing before was because of that cache.

I need the whole script so I can find the line numbers in my own scripting editor.

(This post was last modified: 04-10-2012, 06:57 PM by Putmalk.)
04-10-2012, 06:57 PM
Find
iFondue Offline
Junior Member

Posts: 28
Threads: 6
Joined: Apr 2012
Reputation: 0
#15
RE: How to make a "Wait" in the script.

Sure here it is:

////////////////////////////
// Run first time starting map
void OnStart()


{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1);
}


////////////////////////////
// Run when entering map
void OnEnter()
{

void LightOn(string &in asParent, string &in asChild, int alState)
{
    AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1);
    
    StartPlayerLookAt("LookFrame", 20, 50, "");
    
    SetLampLit("candlestick_1", true, true);
    
    SetLampLit("candlestick_2", true, true);
      

      AddTimer("light1", 0.5f, "TimerLight");
      AddTimer("light2", 1, "TimerLight");
      AddTimer("stopeffects", 1.2f, "TimerLight");

}

void TimerLight(string &in asTimer)
{

       if(asTimer == "light1")
       {
            SetLampLit("candlestick_3", true, true);
            SetLampLit("candlestick_4", true, true);
       }
       if(asTimer == "light2")
       {
            SetLampLit("candlestick_5", true, true);
            SetLampLit("candlestick_6", true, true);
       }
       if(asTimer == "stopeffects")
       {
            StopPlayerLookAt();
       }
}

}
////////////////////////////
// Run when leaving map
void OnLeave()
{

}


04-10-2012, 07:05 PM
Find
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#16
RE: How to make a "Wait" in the script.

With void OnEnter() you are missing an end bracket "}".

Had an additional end bracket at the end of "TimerLight".

The code should look like this to end:

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1);
}


////////////////////////////
// Run when entering map
void OnEnter()
{

}

void LightOn(string &in asParent, string &in asChild, int alState)
{
    //we don't need this callback here, this is will only mess up the code
    //AddEntityCollideCallback("Player" , "ScriptArea_1" , "LightOn" , true , 1);
    
    StartPlayerLookAt("LookFrame", 20, 50, "");
    
    SetLampLit("candlestick_1", true, true);
    SetLampLit("candlestick_2", true, true);
    //an alternate, time-saving way to do this is:
    /*
    for(int i=1;i<3;i++) //for loop will run when i is 1 and 2 only
        SetLampLit("candlestick_"+i, true, true);
    */
    //for 2 that isn't necessary but if you were lighting say 30 candles, this is almost a must!

      AddTimer("light1", 0.5f, "TimerLight");
      AddTimer("light2", 1, "TimerLight");
      AddTimer("stopeffects", 1.2f, "TimerLight");

}

void TimerLight(string &in asTimer)
{

       if(asTimer == "light1")
       {
            SetLampLit("candlestick_3", true, true);
            SetLampLit("candlestick_4", true, true);
       }
       if(asTimer == "light2")
       {
            SetLampLit("candlestick_5", true, true);
            SetLampLit("candlestick_6", true, true);
       }
       if(asTimer == "stopeffects")
       {
            StopPlayerLookAt();
       }
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

That should be correct, but if you get another error just let me know.

(This post was last modified: 04-10-2012, 07:13 PM by Putmalk.)
04-10-2012, 07:11 PM
Find
iFondue Offline
Junior Member

Posts: 28
Threads: 6
Joined: Apr 2012
Reputation: 0
#17
RE: How to make a "Wait" in the script.

OMG! Thank you so much Putmalk! <3

Now it worked! The lamps lit, one after the other! It's perfect!

You seem to be really good at scripting.

Thank you for taking the time for me!

BTW: Subscribed to your YouTue Channel...


Greets

-iFondue


(This post was last modified: 04-10-2012, 07:18 PM by iFondue.)
04-10-2012, 07:16 PM
Find
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#18
RE: How to make a "Wait" in the script.

(04-10-2012, 07:16 PM)iFondue Wrote: OMG! Thank you so much Putmalk! <3

Now it worked! The lamps lit, one after the other! It's perfect!

You seem to be really good at scripting. Thank you again.


BTW: Subscribed to your YouTue Channel...


Greets

-iFondue
Glad it worked, check out those comments I made, they'll help you out, and I'm glad it worked, sorry it took so long, I didn't realize you had a map cache that was blocking everything.

(always delete that map cache until the very end).

And thanks mate. Smile

(This post was last modified: 04-10-2012, 07:18 PM by Putmalk.)
04-10-2012, 07:18 PM
Find
iFondue Offline
Junior Member

Posts: 28
Threads: 6
Joined: Apr 2012
Reputation: 0
#19
RE: How to make a "Wait" in the script.

No Problem!

Thank you, i think I learned a lot.
that's what important.

I will work on my map now...


Thanks

Greets

-iFondue
04-10-2012, 07:19 PM
Find




Users browsing this thread: 5 Guest(s)