Jump to content

Continious Clock Script?


Recommended Posts

OK, question two for the day. I usually consider myself alright at scripting but found myself a bit stumped by this one. I have made a clock in my Titanic map and need to make it keep time at the correct pace, both minute hand and hour hand. Now I thought this would be simple enough however when i tried it, it just crashes the game during load. I set this up via a trigger always tied to the script runner which has always run fine for me. Any ways removing the script allowed me to load normally.

//Generated by BehavEd

rem ( "comment" );

affect ( "HourHand", /*@AFFECT_TYPE*/ FLUSH )
{

    loop ( -1 )
    {

        task ( "HourTime" )
        {
            rotate ( < 360.000 0.000 0.000 >, 1440000.000 );
            do ( "HourHand" );
        }

    }

}


affect ( "MinuteHand", /*@AFFECT_TYPE*/ FLUSH )
{

    loop ( -1 )
    {

        task ( "MinuteTime" )
        {
            rotate ( < 360.000 0.000 0.000 >, 60000.000 );
            do ( "MinuteTime" );
        }

    }

}

}
 

Link to comment

Well an infinite loop is what I'm going for, I want it to continue none stop. So the hour hand is set to rotate "360 o" in the amount of time (in milliseconds)  of 24 hours (this way it move's at the correct speed.)

The minute hand is set to rotate "360 o" in 60000 milliseconds (60 minutes). both need to be continuous (never stopping). 

Now practicallity would say to use a "Func_Rotating", however just like the shader idea, that's damn near impossible to gauge the speed vs time. I know this all sounds like I am being OCD, but that's exactly it, I'm a bit OCD and this needs to work like it should. XD!

I see what you mean by the 'Do" I'll move it and see if that works. Not sure how that even got in there... Why would you suggest a do wait?

Link to comment

I think do is wrong:

affect ( "HourHand", /*@AFFECT_TYPE*/ FLUSH )
{

    loop ( -1 )
    {

        task ( "HourTime" )
        {
            rotate ( < 360.000 0.000 0.000 >, 1440000.000 );
        }

        do ( "HourTime" );

    }

}

because it would expand as:

rotate ( < 360.000 0.000 0.000 >, 1440000.000 );
rotate ( < 360.000 0.000 0.000 >, 1440000.000 );
rotate ( < 360.000 0.000 0.000 >, 1440000.000 );
rotate ( < 360.000 0.000 0.000 >, 1440000.000 );
....

i.e. infinitely many rotates on every frame :|

 

when you actually want to dowait so that it expands as 

rotate ( < 360.000 0.000 0.000 >, 1440000.000 );
wait ( 1440000.000 );
rotate ( < 360.000 0.000 0.000 >, 1440000.000 );
wait ( 1440000.000 );
....
 
I have no idea if icarus scripting works reasonably well over such large times, and it might also see 360 degrees as the same as 0?

 

func_rotating would be more sensible, but is having a clock nobody will ever see move really worth it anyway?

AngelModder likes this
Link to comment

I think do is wrong:

affect ( "HourHand", /*@AFFECT_TYPE*/ FLUSH )
{

    loop ( -1 )
    {

        task ( "HourTime" )
        {
            rotate ( < 360.000 0.000 0.000 >, 1440000.000 );
        }

        do ( "HourTime" );

    }

}

because it would expand as:

rotate ( < 360.000 0.000 0.000 >, 1440000.000 );
rotate ( < 360.000 0.000 0.000 >, 1440000.000 );
rotate ( < 360.000 0.000 0.000 >, 1440000.000 );
rotate ( < 360.000 0.000 0.000 >, 1440000.000 );
....

i.e. infinitely many rotates on every frame :|

 

when you actually want to dowait so that it expands as 

rotate ( < 360.000 0.000 0.000 >, 1440000.000 );
wait ( 1440000.000 );
rotate ( < 360.000 0.000 0.000 >, 1440000.000 );
wait ( 1440000.000 );
....
 
I have no idea if icarus scripting works reasonably well over such large times, and it might also see 360 degrees as the same as 0?

 

func_rotating would be more sensible, but is having a clock nobody will ever see move really worth it anyway?

I will see it.. :D! As will other Titanic enthusiasts. It's one of those touches like accurate texture's or the proper ambient sounds in an area that helps sell the atmosphere. Besides using a Func_Rotating would be taking the easy way out. Nothing ever worth while is achieved easily.

Any ways I've taken all the suggestions thus far and this is what I get. in game I just keep getting spammed with can't find task group 1, which I am guessing is referring to the clock hands. I've double checked and the script_targetnames are correct. Not sure wth is going on... I can sink a ship, but can't seem to make a clock work right :./!

 

/Generated by BehavEd

 

rem ( "comment" );

 

affect ( "hourhand", /*@AFFECT_TYPE*/ FLUSH )

{

 

    loop ( -1 )

    {

 

        task ( "HourTime" )

        {

            rotate ( < 360.000 0.000 0.000 >, 1440000.000 );

            wait ( 1440000.000 );

            rotate ( < 360.000 0.000 0.000 >, 1440000.000 );

            wait ( 1440000.000 );

        }

 

        do ( "HourTime" );

    }

 

}

 

 

affect ( "minutehand", /*@AFFECT_TYPE*/ FLUSH )

{

 

    loop ( -1 )

    {

 

        task ( "MinuteTime" )

        {

            rotate ( < 360.000 0.000 0.000 >, 60000.000 );

            wait ( 60000.000 );

            rotate ( < 360.000 0.000 0.000 >, 60000.000 );

        }

 

        do ( "MinuteTime" );

        wait ( "1" );

    }

 

}

 

Link to comment

you don't want the wait(string) you have after do("MinuteTime") - it should be a number there! maybe move the task declaration out of the loop too? that way it'd look more like:

affect ( "hourhand", /*@AFFECT_TYPE*/ FLUSH )
{
    task ( "HourTime" )
    {
        rotate ( < 360.000 0.000 0.000 >, 1440000.000 );
        wait ( 1440000.000 );
    }
    loop ( -1 )
    {
        do ( "HourTime" );
    }
}
 
affect ( "minutehand", /*@AFFECT_TYPE*/ FLUSH )
{
    task ( "MinuteTime" )
    {
        rotate ( < 360.000 0.000 0.000 >, 60000.000 );
        wait ( 60000.000 );
    }
    loop ( -1 )
    {
        do ( "MinuteTime" );
    }
}
Link to comment

It's possible.

I've made a real analog clock with moving hands (no scripts), moving with the speed of real time. However it won't follow actual time of day. The hands will start at random positions, depending on server starting time.

 

I also made a digital clock(military style 00:00 - 23:59) using scripts that move at a defined speed. Each day can last 20 minutes if want be.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...