Elvio Zobovic Posted November 25, 2014 Share Posted November 25, 2014 Hi,Could anyone help me out with this?I have no clue what I'm doing wrong here but SL keeps giving me a syntax error. integer now = (integer)llGetWallclock(); integer minutes = (now / 60) % 60; integer hours = now / 3600; default { state_entry() { llSetTimerEvent(5); } timer() { if (hours == 1) { } if (hours == 2) { } if (hours == 3) { } if (hours == 4) { } if (hours == 5) { } if (hours == 6) { } if (hours == 7) { } if (hours == 8) { } if (hours == 9) { } if (hours == 10) { } if (hours == 11) { } if (hours == 12 || hours == 00) { } if (mins == 13) { } if (mins == 28) { } if (mins == 43) { } if (mins == 58) { llSetTexture("41ae3187-3220-62df-00db-7f149bcc2d62",2); } } } ERROR: (4, 14) : ERROR : Syntaxt error That is right where the '(' starts of '(integer)llGetWallclock();'Thanks all help appreciated! Link to comment Share on other sites More sharing options...
Dora Gustafson Posted November 25, 2014 Share Posted November 25, 2014 Global variables may be initialized by constants not by expressions like you have Do it in state_entry() instead :smileysurprised::smileyvery-happy: Link to comment Share on other sites More sharing options...
Profaitchikenz Haiku Posted November 26, 2014 Share Posted November 26, 2014 Like Dora says, you can't call a function or initialise globals using expressions, but putting the wallclock call inside state_entry will only cause it to get the wallclock time once and so it won't update. I would put the three variables inside the timer event if they aren't going to be used in any other areas. Link to comment Share on other sites More sharing options...
Elvio Zobovic Posted November 26, 2014 Author Share Posted November 26, 2014 Ahh, that makes sense. Thank you for your time replying! Link to comment Share on other sites More sharing options...
Madelaine McMasters Posted November 26, 2014 Share Posted November 26, 2014 To expand a bit on Dora's and Profaitchikenz's replies, global declarations outside of the state and event handlers of a script don't actually execute, and so they can't contain calls to functions. They can contain static expressions to be evaluated by the script compiler during compilation of the script. These declarations tell the compiler how to handle the variables when they're encountered later in the script. The compiler knows these declarations don't execute and warns you with the ever helpful "Syntax error". I'd argue that you'd actually made a semantic error ;-). As Prof pointed out, you must be careful where you place the call to llGetWallClock() to make sure it's called when you want. If you just put it inside state_entry(), it will only be called when the script is reset or the prim is rezzed. It seems to me you want to set the face of your clock to reflect the current time, and you wish to do that every five seconds. For that reason, "now" should be updated via llGetWallclock() inside your timer event, where it can then drive your texture update logic. That's what Prof advised. Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now