Jump to content

help with script that activates at certain time of day


WOTmodsproductions

Recommended Posts

Im trying to get a script to work for my mod, it needs to be activated at a certain time of the day, for example the static object in question is disabled by default and should then enable between the hours (roughly) of 8pm and 6am.

 

This is the stript I made

 

Scriptname 0000fencetest1

 

 

 

Begin Gamemode

 

If GetCurrentTime > 19.75 && GetCurrentTime < 6.0

 

NF2. enable

NF1. enable

 

 

endif

end

 

Begin Gamemode

 

If GetCurrentTime > 6.1 && GetCurrentTime < 19.30

 

NF2. disable

NF1. disable

 

endif

end

 

 

 

The script is placed on a misc item as I didnt know how else to get the script into the area, but nothings happens, ive never tried to do a script where it activates between ceratin times, the static is a 'persistant reference'. The GECK accepts the script, its just that nothing happens in game at the times ive selected.

Would someone be able to tell me how I can activate these 2 static objects at a certain time and then disable them again when it becomes daylight? thanks

Link to comment
Share on other sites

Try

scn ...  

short timevar  

begin gamemode 
set timevar to GetCurrentTime
if NF2.GetDisabled 
 if timevar > 19.75 && timevar < 6 
  NF2.enable 
  NF1.enable 
 endif 
else 
 if timevar > 6.1 && timevar < 19.3 
  NF2.disable 
  NF1.disable 
 endif 
endif 
end

instead.

 

Instead of placing the script on an object, just make it a quest script and attaching it to a start-game enabled quest. That's usually what they're used for anyway.

 

EDIT: I'm assuming NF1 and 2 are persistent object references, not base object references? I can't remember if it generates an error or not, but that's been a problem for a few people.(And fixed a typo in the script)

Edited by Skevitj
Link to comment
Share on other sites

Ive tried that and it still doesnt work, ive attached the script to the quest and it will not activate on start up....ever...so I created a script and got it to add the quest when I pick up a certain item, this activates the quest.....but still the scripts for the static items do not activate

 

and yes they are persistant references and not base objects

Edited by thelonewarrior
Link to comment
Share on other sites

From that explanation it seems like the quest you attached it to isn't start-game enabled (ie, "Start Game Enabled" option ticked, Priority > 60 (dunno if this actually makes a difference, but I think it has a few times) and the script attached.

 

I can't see any reason why the script wouldn't work based on the information provided, so try just making up a simple script which uses a gamemode block to display a message once. If you start up the mod and the message pops up, then the quest is fine and given the information provided, the script above should do it's job. If the message doesn't show up, then there is a problem with the quest not running and that needs to be looked at.

Link to comment
Share on other sites

Ok ive managed to get part of it to work, it doesnt show up the quest at the start, but it does run the script....once. it activates the static items once, I know its run the script as the items are disabled by default but are enabled when I have this

 

 

begin gamemode

If GetCurrentTime < 20.00 && GetCurrentTime > 6.00

NF2.enable

NF1.enable

endif

else

If GetCurrentTime < 6.10 && GetCurrentTime > 19.50

NF2.disable

NF1.disable

endif

endif

end

 

so when the time reaches 6am and they are meant to be disabled, they arnt.....

Link to comment
Share on other sites

Ok ive managed to get part of it to work, it doesnt show up the quest at the start, but it does run the script....once. it activates the static items once, I know its run the script as the items are disabled by default but are enabled when I have this

 

 

begin gamemode

If GetCurrentTime < 20.00 && GetCurrentTime > 6.00

NF2.enable

NF1.enable

endif

else

If GetCurrentTime < 6.10 && GetCurrentTime > 19.50

NF2.disable

NF1.disable

endif

endif

end

 

so when the time reaches 6am and they are meant to be disabled, they arnt.....

 

 

EDIT: Ive tried adding a message to the script, but it doesnt come up so something is stopping it

Link to comment
Share on other sites

This will never return as true:

 

If GetCurrentTime < 6.10 && GetCurrentTime > 19.50

 

The script engine treats the number returned by GetCurrentTime as just a number - it doesn't know it's a clock and that you are crossing midnight here. So if GetCurrentime returns 5am, you have:

 

if 5 < 6.10 && 5 > 19.50

 

Which is false.

Link to comment
Share on other sites

Ha, didn't even bother looking at the conditions when I copied them.

 

Changing the AND (&&) to an OR (||, i think) in the If GetCurrentTime < 6.10 && GetCurrentTime > 19.50 test will fix it up, since only one can (and needs to be true at a time). The other one (If GetCurrentTime < 20.00 && GetCurrentTime > 6.00) should remain an AND test.

Link to comment
Share on other sites

There's actually a 'Vnight' global variable already maintained by the game, but the defifinition of night is > 21:00 or < 4:30

 

If that is not close enough then it's easy enough to make your own local nighttime variable.

 

Put this in a quest that has a delay time of 60 seconds or even more.

 

int iNightTime

BEGIN gamemode 

 if GameHour > 19.75
   set iNightTime to 1
 elseif GameHour < 6.0
   set iNightTime to 1
 else
   set iNightTime to 0
 endif

 if iNightTime
   if NF1.GetDisabled
     NF1.enable
     NF2.enable
     ;add more refs here if needed
   endif
 elseif NF1.GetDisabled == 0
   NF1.disable
   NF2.disable
   ;add more refs here
 endif
END

Link to comment
Share on other sites

  • Recently Browsing   0 members

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