Jump to content

Question

Posted (edited)

this isnt working for me  not sure why

 

OnInit:
if (gettime(3) >=0 && gettime(3) <=3) 
set $@isnight, 1; 
night;
if (gettime(3) >=4 && gettime(3) <=7) 
set $@isnight, 0;
day;
if (gettime(3) >=8 && gettime(3) <=11)
set $@isnight, 1; 
night;
if (gettime(3) >=12 && gettime(3) <=15) 
set $@isnight, 0;
day;
if (gettime(3) >=16 && gettime(3) <=19)
set $@isnight, 1; 
night;
if (gettime(3) >=20 && gettime(3) <=23) 
set $@isnight, 0;
day;
end;

 

Edited by mirabell
wrong part of script

2 answers to this question

Recommended Posts

  • 0
Posted

If-statements with more than one line of code to perform should be in curly braces:

OnInit:
	if (gettime(3) >=0 && gettime(3) <=3) {
		$@isnight = 1; 
		night;
	}
	if (gettime(3) >=4 && gettime(3) <=7) {
		$@isnight = 0;
		day;
	if (gettime(3) >=8 && gettime(3) <=11) {
		$@isnight = 1; 
		night;
	}
	if (gettime(3) >=12 && gettime(3) <=15) {
		$@isnight = 0;
		day;
	}
	if (gettime(3) >=16 && gettime(3) <=19) {
		$@isnight = 1; 
		night;
	}
	if (gettime(3) >=20 && gettime(3) <=23) {
		$@isnight = 0;
		day;
	}
	end;

Don't forget that gettime() now uses constants:

Quote

*gettime(<type>)

This function will return specified information about the current system time.

DT_SECOND - Seconds (of the current minute)
DT_MINUTE - Minutes (of the current hour)
DT_HOUR - Hour (of the current day)
DT_DAYOFWEEK - Week day (constants for MONDAY to SUNDAY are available)
DT_DAYOFMONTH - Day of the current month
DT_MONTH - Month (constants for JANUARY to DECEMBER are available)
DT_YEAR - Year
DT_DAYOFYEAR - Day of the year

It will only return numbers. If another type is supplied -1 will be returned.

	if (gettime(DT_DAYOFWEEK)==SATURDAY) mes "It's a Saturday. I don't work on Saturdays.";

 

  • 0
Posted (edited)

thanks so i should be using   (gettime(DT_HOUR) >=16 && gettime(DT_HOUR) <=19)    thanks i forgot about the curls its been 4 years since i wrote a script 

 

Edited by mirabell
  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...