This project provides a state-of-the-art library for dynamic heartbeat script management. With Heartlib you can assign any script to be called by any object (creature, placeable, even item) in a loop with a custom delay. There is no need to modify this script at all. Heartbeats can be paused, stopped, their settings modified during runtime and the same script can be registered multiple times.
See readme file inside project's archive for more information and installation instruction.
A demo module is provided.
CHANGELOG
1.4 (2019-12-04)
1.3 (2019-10-15)
1.2 (2019-10-04)
1.1 (2019-09-30)
1.0 (2019-09-27)
Attachment | Size |
---|---|
![]() | 19.94 KB |
This library is farily user-proof: you should keep all heartbeats under control as long as you use HEART_RegisterHeartbeat for registration.
Using heartbeats for items is fairly unorthodox, so be careful. When two items merge into a stack, one of them is destroyed (along with any heartbeats it had). Items with different tags cannot be merged.
Every time you release something and then realize there are still things to do that you somehow missed. So here's an update. The system is hardened against errors and simplified. I don't see what functionality could be added. If you spot any bugs let me know here.
Thx NWShacker
This looks really useful. I already have several places I can use this in the mod im making... Thumbs up!
Thanks. PM me if this gives you any trouble (bug reports are best left directly on this page as comments).
A similar utility mod is almost done and will be released soon.
Version 1.2 (live today) is a critical bugfix release mostly revolving around heartbeat removal subroutines. This project is just week old, but in any case, do not use version 1.1 for module production.
I also added a gong in the demo module so you can test how the heartbeats are stopped and restarted.
Updated to version 1.3. This should be the final one for the time being.
This project has been updated. I believe this is now a complete version.
Check
source/heartlib.html
file for project's NWScript function reference.I'm thinking of adding a counter: you select how many times the heartbeat should run, perhaps like this:
By combining it with the delay, you can specify the total time the heartbeat will run.
A new version will probably appear this year. But the current one is totally functional, of course.
I am using your HeartLib in my next module (nearing release, but finishing can be hard... It's the last 1% that costs, you know). This function library works as intended, is easy to integrate and features useful options. Always good to have a system heartbeat alternative! In the past, i toyed with this pseudo-hearbeat concept, but what i came with, was much much less polished than yours. So, thanks for this excellent contribution. By the way, your counter idea would be a good improvement. I see a lot of use cases :-)
CG
P.S. : Didn't know about the fish. Neat trick...
Sorry for the late reply, CG - I have currently absolutely no time for NWN :-( Glad it works for you, though. Let me know if there are any bugs. When I get some spare time, I'll try to update it together with my other older projects. Ah, good old times when the projects had 500 code lines in total...
OK, I managed to get some free time this weekend and made progress with Heartlib 1.5.
I added total call time, total call count, stop call time and stop call count properties. They allow automatic heartbeat stop or pause.
I also fixed a race condition where wrong heartbeat ID may be reported to the called script.
Demo module is also updated - few new objects are added. I'll try to release it soon.
Anything new ?
If there is a 1.5, will it be compatible with v1.4 ? Lots of thanks.
Thanks for asking.
Perhaps 1.5 could be a small 1.4 bugfix. Then whatever comes next would be 2.0 and it would not be backward compatible. I'm still undecided about the changes. They're cool, but make the whole thing more complex.
I'm kind of swamped with other things, but I have big plans for refreshing all those projects in 2022.
Yes, i could be interested in a small backward compatible 1.4 bugfix as the current system is more than capable and i like it ;-) To this hour, heartlib seems to work flawlessly for me. I have done various systems with it, for ex. a underwater system for submerged drowning walkers and a lava walking damage handler (Maybe 2022 is the release year of my Thief Headquarters mod, who knows...). Cheers !