Jump to content

Script help: Game days timer


Altais

Recommended Posts

Hello :happy: I am trying to make a timer script for a housing mod. The idea is that when you leave the house at a certain point in a certain quest, the door locks, a timer starts, and 2 days later the door unlocks and you get a message that you can return to the house. I am very new to scripting btw.

 

Anyway, my problem is that I can't figure out how to make a 2 day timer script that works. As a start I tried to make a 1 day timer script after a look at this page (Timers headline).

 

 

Scn (whatever)

Short StartDay
Short State
Short HouseReady

Begin Gamemode

If State == 0 && GetStage (the quest) == 10 && Player.GetInCell (the house) == 0
	(the door to the house).Lock 255
	Set StartDay to GameDaysPassed
	Set State to 1
ElseIf State == 1
	If GameDaysPassed > StartDay
		Set HouseReady to 1
		Set State to 2
		(the door to the house).Unlock
		SetStage (the quest) 20
	EndIf
EndIf

End

 

 

As I said I tried this to see if a 1 day timer would work, but alas it didn't. Just after I leave the house, the quest is set to stage 20 and I get the message that my house is ready.

 

Is there something fundamentaly wrong with this script? Any ideas about how I can make it work, and any suggestions on how to make a script timer script that lasts for 2 days?

 

I know there are a lot of brilliant modders out there, and any tips you can give are highly appreciated. :biggrin:

Link to comment
Share on other sites

You have

 

if GameDaysPassed > StartDay

 

and you already set StartDay to GameDaysPassed.

 

I'm pretty sure GameDaysPassed doesn't just return an integer, like 1, but a decimal, like 1.06

So in effect, immediately after you set StartDay, GameDaysPassed will still be greater.

 

If you want it to wait 2 days, you want the condition to read something like

 

if GameDaysPassed - StartDay >= 2

 

Then if StartDay is 1.06, GameDaysPassed will have to be at least 3.06, making it so that you have to wait 2 in game days in order for the HouseReady variable to be set to 1.

 

Hopefully that made sense to you.

Link to comment
Share on other sites

Thanks a lot, it works perfectly. :biggrin:

 

In fact I wasn't familiar with that way of writing a condition (if GameDaysPassed - StartDay >= 2) before now . Thats definitely going to be usefull later as well.

 

Again, thanks a lot, kudos to you, and thanks for answering that quickly. :happy:

Link to comment
Share on other sites

  • Recently Browsing   0 members

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