Script Needed - Door

Post » Mon Jun 18, 2012 1:00 pm

Edit: Thank you for the help! Issues are resolved! :twirl:


Leaving in old script, for anyone else who may be learning:
Spoiler

Scriptname _WellScript extends ObjectReference


;timecheck
GlobalVariable property GameHour auto

float Property NoEarlierThan = 22.0 Auto
float Property NoLaterThan = 4.0 Auto


bool function IsTimeValid()
Float Time = GameHour.GetValue()

if NoEarlierThan == 22 && NoLaterThan == 4
return TRUE
endif

if NoEarlierThan > NoLaterThan
if Time >= NoEarlierThan && Time <= NoLaterThan
return TRUE
endif

elseif NoEarlierThan < NoLaterThan
if Time >= NoEarlierThan || Time <= NoLaterThan
return TRUE
endif

endif

Return FALSE

endFunction




;door
Event OnActivate(ObjectReference akAcrionRef)
if IsTimeValid() == TRUE
;no action, door will function
else
BlockActivation(TRUE)
Debug.MessageBox("I can't enter the well in broad daylight!")
endif

endEvent

User avatar
Trent Theriot
 
Posts: 3395
Joined: Sat Oct 13, 2007 3:37 am

Post » Mon Jun 18, 2012 11:20 pm

Your IsTimeValid() function always returns true because of:

if NoEarlierThan == 22 && NoLaterThan == 4return TRUEendif
User avatar
QuinDINGDONGcey
 
Posts: 3369
Joined: Mon Jul 23, 2007 4:11 pm

Post » Mon Jun 18, 2012 5:11 pm

the only check you need is.

if Time >= NoEarlierThan || Time <= NoLaterThan
return TRUE
endif
User avatar
JAY
 
Posts: 3433
Joined: Fri Sep 14, 2007 6:17 am

Post » Mon Jun 18, 2012 11:12 am

Your IsTimeValid() function always returns true because of:

if NoEarlierThan == 22 && NoLaterThan == 4return TRUEendif

How will that always return true?
The time MUST be 22 AND 4 at the same time...
User avatar
Trish
 
Posts: 3332
Joined: Fri Feb 23, 2007 9:00 am

Post » Mon Jun 18, 2012 11:31 am

How will that always return true?
The time MUST be 22 AND 4 at the same time...
You're not comparing Time there, you're only comparing your properties, which you set to be those values just above there
float Property NoEarlierThan = 22.0 Autofloat Property NoLaterThan = 4.0 Auto 

You set them to those values, and then you compared them to those values, so it is always true.
User avatar
Dj Matty P
 
Posts: 3398
Joined: Sat Jun 09, 2007 12:31 am

Post » Tue Jun 19, 2012 12:14 am

You're not comparing Time there, you're only comparing your properties, which you set to be those values just above there
float Property NoEarlierThan = 22.0 Autofloat Property NoLaterThan = 4.0 Auto 

You set them to those values, and then you compared them to those values, so it is always true.

Derp. Wasn't thinking straight. :wallbash:
User avatar
sunny lovett
 
Posts: 3388
Joined: Thu Dec 07, 2006 4:59 am


Return to V - Skyrim