Jump to content

[Solution] Trick Papyrus engine into duplicating an array for you


niston

Recommended Posts

No.

 

CHRONOS is an event scheduler I wrote.

 

I created a schedule:

 

TimeOfDay=8.0, EventDataKeyword=StreetlightsEventKeyword, EventDataFloat=1.0, Description="Streetlights off"

TimeOfDay=20.0, EventDataKeyword=StreetlightsEventKeyword, EventDataFloat=0.0, Description="Steetlights on"

 

I gave this schedule to CHRONOS. It'll raise events every day at 8:00am and 8:00pm.

 

Together with some other scripts (there is a Scheduler Client Base class to inherit from and some "default scripts", to make things easy), street lights in restored Concord turn on at 8:00pm and turn off at 8:00am, if wired properly to the street lights contactor on the Workhouse. The EventDataFloat value in the above schedule determines if the contactor is being set open (1.0) or closed (0.0) through the ScheduledSetOpen "default script". The keyword is used so that many distinct clients can share a single scheduler (for example, the water tower in Concord runs off the same scheduler as the streetlights do, but it doesn't listen to StreetlightsEventKeyword).

 

So, for the Water Tower, I created another entry in the schedule:

 

TimeOfDay=23.75, EventDataKeyword=WaterTowerEventKeyword, Description="Water Tower Daily Balancing Run"

 

Since the scheduler client on the Water Tower listens to the WaterTowerEventKeyword, it'll get that event at 11:45pm, prompting it to do it's thing. The streetlights on the other hand won't care about that.

 

If you sleep/wait/fasttravel, that doesn't matter - no scheduled events are lost.

CHRONOS can even track missed events for the day it first starts up in your game. So when your schedule turns something on at 11:00am, but you first install the mod when it is 3:30pm gametime, the event that would have occurred at 11:00am will still be processed and the thing that is being controlled will turn on. To use this feature, set the Initialize parameter in the schedule entry for 11:00am to true.

 

I can also provide a Terminal in game, where you can adjust the schedule. Or a script could inject dynamic entries, perhaps of the "FireAndForget" type, which will get removed automatically from the schedule after firing once. There is an option to have a schedule entry not occur before a given amount of days has passed, so you could use this to give a deferred quest reward or whatever. Do quest now, receive extra Brahmin in 3 game days, or some such.

 

It does all this in < 1000 lines of code. With extreme accuracy. Running just one single timer, while using exactly zero Papyrus timeslices for almost all the time. And I've been testing and improving it for the past 2 years.

 

It's, in fact, a programmable timer on Buffout and Jet Fuel. Similar to CRON for Linux. Or as I like to call it: SWISS MADE precision clockwork for your mods.

Link to comment
Share on other sites

Ohhhh .....

Wow that is some next level sh!t .....

:ohmy:

So, if this uses no papyrus "execution time", is it going to be a F4SE plugin or something like that?

 

Also, all of that in < 1k lines is pretty neat!

 

 

I recently got into playing around with C++ (just writing some basic terminal - applications, and things like that) and I can confirm that those lines of code have a tendency to grow exponentially over time and that it is very hard to keep things "compact" and "low profile" ....

(Already ran out of RAM a few times by accident when messing around with multiple arrays that have 1.000.000.000 entries each ... :laugh: )

Link to comment
Share on other sites

No, this works without F4SE.

 

And I said almost no execution time. In particular: There is only processing going on the moment an event occurs. After that, the scheduler will lay completely dormant until the next event occurs - Which would be 12 hours gametime, for the example with the streetlights only. It is very Zen: Doing everything by doing mostly nothing. Or, as Scrivener07 put it: The fastest script is the one that did nothing. Pretty sure SKK would approve of this.

 

And always remember: Errors = (more code) ^ 2

Link to comment
Share on other sites

  • Recently Browsing   0 members

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