Page 1 of 1

I need my script to do something every 7 days

PostPosted: Sun Feb 17, 2019 1:35 am
by Ax31
Hello.
I just spent the last hour trying to get money on a chest every few days for a store, but i cant get it to do it more than once...

It's pretty simple, but it seems that the timer doesn't reset. i've tried in many different ways but it's always the same, it runs once and doesn't restart. is this even possible?
Code: Select all
begin aa_testmon

short daysPassed
short myDay
float timer

if ( daysPassed = 0 )
set myDay to Day
set daysPassed to 1
endif


if ( myDay != Day )
set timer to ( timer + 1 )
set myDay to Day
endif

if ( timer = 3 )
if ( aa_chest_TEST->GetItemCount, "gold_001" < 10000 )
aa_chest_TEST->additem, "gold_001", 180
set timer to 0
endif
endif

end

Re: I need my script to do something every 7 days

PostPosted: Sun Feb 17, 2019 6:34 am
by Leonardo
Welcome to GHF, Ax31!  :dancing-banana:

I don't know much about scripting, but I'm curious about what the "if ( timer = 3 )" line does and it seems that the variable 'timer' needs to be equal in order to excute the following lines below.

Perhaps you have one "endif" too many or one "endif" is missing.  Of course you can always check the script in MWEdit or one of the vanilla scripts just to see how it is done.

Re: I need my script to do something every 7 days

PostPosted: Sun Feb 17, 2019 10:09 am
by Ax31
HI, thanks!
timer is there as a counter, i can't even remember why timer, but i also created other variables and it made no difference, the idea is that 1 gets added everytime myday isn't the actual day, after reaching three it gives you money, it just doesn't seem to come back to zero and restart, as for mwedit, it shouldn't make  a difference as the script is too simple, but i'll try, and the link you provided is for the nif plugin. I also spent a while randomly looking through scripts to find a reference, but i couldn't. although there IS a door somewhere that opens and closes at dusk and dawn, i can't believe i can't remember the place, i need to find that script!

Re: I need my script to do something every 7 days

PostPosted: Sun Feb 17, 2019 10:09 pm
by Drakkmore
The cave of the incarnate only opens at dusk, and dawn as well as Holamayan Monastery has an activator that rises, and lowers at dusk, and dawn. I'm no good at scripting, so I can not help you there. Good luck with your script,and I hope that the place names I gave help.

Re: I need my script to do something every 7 days

PostPosted: Mon Feb 18, 2019 7:51 am
by Ax31
Hey, thank you, but if found it yesterday after scrolling through the UESP, unfortunately that script checks the hours, not days :s, anyway, the script now kind of works,KIND OF, at least enough to come up with a lore friendly excuse for it's shortcomings in the mod, thank you both still

Just in case i'll post the current script below
Code: Select all
begin aa_testmon

short myDay
short daycount

if ( daysPassed == 0 )
set myDay to Day
set daysPassed to  1
endif

if ( myDay != Day )
       set myDay to Day
set global_time to global_time + 1
endif

if ( global_time = 3 )
if ( aa_chest_TEST->GetItemCount, "gold_001" < 10000 )
       aa_chest_TEST->additem, "gold_001", 180
return
endif
endif

if ( global_time >= 3 )
set global_time to 1
endif
end


A global variable was, i think, the answer, as it it it will give money constantly until the 10000 cap, even if the last bit of the script should stop it. doing pretty much anything to this script makes it not run more than once, and even then, you need to open the chest twice, or wait a full day in front of it then open it twice, it'll (kind of) do, but the poor thing is fragile af, so please just gaze at it, no hard looks or quick scrolling, and no flash photography, please.

Re: I need my script to do something every 7 days

PostPosted: Mon Feb 18, 2019 5:16 pm
by Drakkmore
I know there re mods out there that have a NPC give the player money once every few days or so, perhaps that could be an answer. DonnerGott would have a better answer as to exactly how it could be done, I know he uses a few such mods. At any rate good luck getting it to work properly.

Re: I need my script to do something every 7 days

PostPosted: Mon Feb 18, 2019 7:21 pm
by Ax31
Mmmhh, looking into other mods sounds interesting, i'll try tomorrow after work and see what i come up with.