AngelModder Posted January 31, 2015 Posted January 31, 2015 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 BehavEdrem ( "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" ); } }}}
Ramikad Posted January 31, 2015 Posted January 31, 2015 Isn't it easier (if it's possible) to just use a shader that rotates the clock hands at the right speed?
AngelModder Posted January 31, 2015 Author Posted January 31, 2015 It would be possible however gauging speed with shades can can be a real pain. More of a luck thing really. Besides nothing beats good old fashioned scripting.
redsaurus Posted January 31, 2015 Posted January 31, 2015 If you have the do inside the task block it'll never actually be called. should probably be a dowait too, otherwise you have an infinite loop. AngelModder likes this
AngelModder Posted January 31, 2015 Author Posted January 31, 2015 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?
redsaurus Posted January 31, 2015 Posted January 31, 2015 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
AngelModder Posted January 31, 2015 Author Posted January 31, 2015 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.. ! 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" ); } }
redsaurus Posted February 1, 2015 Posted February 1, 2015 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" ); } }
mrwonko Posted February 1, 2015 Posted February 1, 2015 You don't need tasks at all. Just rotate and wait. The other problem is that rotate 360 means rotate to the 360° position on the shortest path, not rotate by 360°. i.e. it means rotate from 0° to 0° or not at all. You'll need at least 3 rotates to 120, 240 and 360°. AngelModder likes this
AngelModder Posted February 1, 2015 Author Posted February 1, 2015 Well thanks to you guys it's working finally! Was fun to actually check it to make sure it's correct. It was spot on the right time every time. HAHAThanks @@mrwonko @@redsaurus !
Lazarus Posted February 1, 2015 Posted February 1, 2015 Is it an accurate clock? I am curious if time can be set on forhand to servertime? AngelModder and z3filus like this
AngelModder Posted February 2, 2015 Author Posted February 2, 2015 No I have it starting at noone and chimes every 30 minutes etc. I'm not sure if you can put together a script that detects the server time.
Saiaku Posted February 9, 2015 Posted February 9, 2015 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.
Futuza Posted February 9, 2015 Posted February 9, 2015 No I have it starting at noone and chimes every 30 minutes etc. I'm not sure if you can put together a script that detects the server time.You'd probably have to have a tiny mod to allow game to pull current cpu clock time and use that as the starting time. AngelModder likes this
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now