Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script] Time/Torch Tracker

May 15 (12 years ago)

Edited October 06 (11 years ago)

I'm planning a Dungeon Crawl Classics megadungeon game which will be heavy on exploring and resource management. I love the idea of the players wondering if they'll have time to make it back to the surface before their last torch burns out.

The script listens for "!round x" or "!turn x" and finds all the graphics named "Torch" with a light_radius greater than zero, and decrements their bar1_value, which I'm using to track burning duration, and also decreases the lighting as the torch starts to burn low (inspired by Riley's "The Light Is Closing In" script).

https://gist.github.com/bripod/5587911

Eventually I'd like to extend this to lanterns, candles, and other lighting types, and keeping track of how much time has elapsed overall, but this is what I put together so far.

May 16 (12 years ago)
Riley D.
Roll20 Team

Very cool!

sounds great, now I f I just understood anything at all about the API! :)

This is an amazing script! I think this could be interesting if you wanted a spooky atmosphere to your game.

May 17 (12 years ago)
Riley D.
Roll20 Team

OldSchoolChris said:

sounds great, now I f I just understood anything at all about the API! :)

Even if you don't know programming, you can just copy and paste his script above into your own campaign, and if you follow his instructions it will work.


I've finally got some more time to tweak this last night and I've added some new functionality to the script. And hopefully cleaned up the script some -- I'm not the world's most elegant coder, by any stretch. ;-)

I've updated the script in github, so the link above should point to the new version. 

I added: "!time" to return the total time passed; and "!time x" to reset time passed to x; and the script now uses bar2_value to turn the torches on/off (it'll only allow blank, 0, or 1 values). 

And my favorite part: if a partially-burned-out torch gets turned on, the script will correctly set the light radius based on the settings I've hard-coded in the script (which are 80% illumination at 30% burn-time remaining, 50% at 20%, and 20% at 10%, which I just picked arbitrarily, but look good to my eye). 

I still have some more ideas I'd like to incorporate (reminders to check for wandering monsters every x turns would be nice), but it's more or less ready for play now. 

OldSchoolChris said:

sounds great, now I f I just understood anything at all about the API! :)

Copying other people's work, then breaking it, and then trying to fix it, was how I learned to write code. Have at it!