[Script] Hexploration

1520985385

Edited 1523984845
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Hexploration v1.1 This script allows the GM to conceal areas of a hex grid with individual opaque hexes. Then characters can explore the hexes to reveal them. To create a hex-filled area, first draw a polygon containing the area you want filled with hexes. Then select the polygon and activate the 'Hexploration_fill' macro installed by this script. That's it! Further documentation is included on the script's GitHub page. The script is now available through the One-Click library. Demo: Known Issues: None Future Roadmap: Named hexes that are announced when a character reveals them. Options to change stroke and fill colors of hexes. Range option for clearing adjacent hexes. Inverted Fill.
1520986459
The Aaron
Pro
API Scripter
neat!
That's pretty darn clever.
1520992560
Gold
Pro
I'm pretty hexcited about this. Will test it out soon (within a few weeks, when practical for my games).
1521000900

Edited 1521001023
G G
Pro
Sheet Author
I've tried running this a few times, but I keep getting "Error: PathMath is not defined" It's hard to say what's going wrong. I'm just creating a polygon, then when it's complete, selecting it and clicking the macro. My map has vertical hexes. Is there anything special i have to do to set it up, or something basic I'm missing when making the polygons? More detailed error code from the log: "ReferenceError: PathMath is not defined\n     at getHexesInArea (apiscript.js:14150:20)\n     at fillArea (apiscript.js:14114:17)\n     at _.each.sel (apiscript.js:14254:13)\n     at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9)\n     at msg (apiscript.js:14252:13)\n     at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:65:16)\n     at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:70:8)\n     at /home/node/d20-api-server/api.js:1510:12\n     at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560\n     at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147)"
1521002217
The Aaron
Pro
API Scripter
I think that might be one of Stephen’s other scripts. Check the Roll20 repo?
1521002314
The Aaron
Pro
API Scripter
Yeah:   https://github.com/Roll20/roll20-api-scripts/blob/master/PathMath/1.5/PathMath.js
1521008006
G G
Pro
Sheet Author
Thanks, I found it also needs MatrixMath. Now, that i have the dependencies, it crashes after drawing a single hex. Errors in log: "⬢⬢⬢ Initialized Hexploration v1.0 ⬢⬢⬢" "Hexploration ERROR: Cannot read property 'get' of undefined" "TypeError: Cannot read property 'get' of undefined\n    at Object.persistHex (apiscript.js:1681:21)\n    at _.chain.map.hex (apiscript.js:1742:29)\n    at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:172:24)\n    at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34)\n    at fillArea (apiscript.js:1726:6)\n    at _.each.sel (apiscript.js:1863:13)\n    at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9)\n    at msg (apiscript.js:1861:13)\n    at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:65:16)\n    at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:70:8)" "Hexploration ERROR: Cannot read property 'get' of undefined" "TypeError: Cannot read property 'get' of undefined\n    at Object.persistHex (apiscript.js:1681:21)\n    at _.chain.map.hex (apiscript.js:1742:29)\n    at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:172:24)\n    at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34)\n    at fillArea (apiscript.js:1726:6)\n    at _.each.sel (apiscript.js:1863:13)\n    at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9)\n    at msg (apiscript.js:1861:13)\n    at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:65:16)\n    at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:70:8)"
1521013970
Arthur B
Pro
API Scripter
G G said: Thanks, I found it also needs MatrixMath. Now, that i have the dependencies, it crashes after drawing a single hex. Errors in log: "⬢⬢⬢ Initialized Hexploration v1.0 ⬢⬢⬢" "Hexploration ERROR: Cannot read property 'get' of undefined" "TypeError: Cannot read property 'get' of undefined\n    at Object.persistHex (apiscript.js:1681:21)\n    at _.chain.map.hex (apiscript.js:1742:29)\n    at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:172:24)\n    at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34)\n    at fillArea (apiscript.js:1726:6)\n    at _.each.sel (apiscript.js:1863:13)\n    at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9)\n    at msg (apiscript.js:1861:13)\n    at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:65:16)\n    at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:70:8)" "Hexploration ERROR: Cannot read property 'get' of undefined" "TypeError: Cannot read property 'get' of undefined\n    at Object.persistHex (apiscript.js:1681:21)\n    at _.chain.map.hex (apiscript.js:1742:29)\n    at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:172:24)\n    at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34)\n    at fillArea (apiscript.js:1726:6)\n    at _.each.sel (apiscript.js:1863:13)\n    at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9)\n    at msg (apiscript.js:1861:13)\n    at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:65:16)\n    at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:70:8)" Same here. 
1521034216

Edited 1521034269
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Oh, right. I also updated PathMath to support this script. Here's the new PathMath:  https://github.com/Cazra/roll20-api-scripts/blob/h...
1521043900
Arthur B
Pro
API Scripter
Looks great! It's working now for me. I just noticed one thing: The token that reveals hexes needs to represent a character. Most people will probably have a "party token" that doesn't represent a single character in the journal
1521044902
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Right, this is mentioned in the script's README/One-Click documentation.
1521045543
G G
Pro
Sheet Author
Okay now I have VectorMath installed too, it's working. It's pretty great. This will be a huge benefit to hexmapping exploration games.  It's a shame it doesnt work for squares, it would be a pretty useful alternative to fog of war i think for people who cant use dynamic lighting because its too demanding, or whatever. Just have a token that represents vision and move it around to clear a room.  Manual fog of war is so clunky.
1521045761
Arthur B
Pro
API Scripter
Stephen L. said: Right, this is mentioned in the script's README/One-Click documentation. Yes, I saw that afterwards. Just mentioning it because my party token on the map didn't represent a character, and I think that's the case for most people. But once I adjusted it, the script works like a charm.  Luckily, I have some travelling/hexcrawling planned for my next session, so this comes in just in time! Thanks!
1521046930

Edited 1521046981
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
G G said: Okay now I have VectorMath installed too, it's working. It's pretty great. This will be a huge benefit to hexmapping exploration games.  It's a shame it doesnt work for squares, it would be a pretty useful alternative to fog of war i think for people who cant use dynamic lighting because its too demanding, or whatever. Just have a token that represents vision and move it around to clear a room.  Manual fog of war is so clunky. I'm not sure how useful that would be for dungeon crawling since the purpose here is to reveal one tile at a time. That could get a bit tedious clearing out each tile with the light source token one at a time. Probably a better solution for that use-case would be large, polygonal fog-of-war areas that get removed as PCs step into their area.
1521125489
Ravenknight
KS Backer
Excellent! I will give it a spin this weekend for sure.
1521360917
This is great! Can it be used to reveal hexes that are one or more spaces away from the players rather than just the one they land on? 
1521366332

Edited 1521366368
G G
Pro
Sheet Author
At present it removes hexes when you move your token on top of them. That suggests an idea though: clear all hexes the token is adjacent to. I suppose you could set a range, from 0 (land on top) to whatever, but 1 would be very useful.
1521413735
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Cool idea! I'll add it to the roadmap.
1521416389
Arthur B
Pro
API Scripter
Could you add an option, where you draw a path, and the script fills the complete map EXCEPT the hexes that were covered by the path area? Like an inverted fill?
1521492418

Edited 1521492784
I used this last weekend for some hex crawling my group was doing.  Things went really well.  Nicely done! I edited the script to make the hexes black with dark grey outlines because I found that easier on the eyes than the built-in yellow.  Maybe the ability to customize the color would be nice. I also moved a copy of the world map from the Map layer to the GM layer, lining them up exactly.  That way, when I had it drop all the hexes on the mostly-unexplored world, I could still tell where things were since I now have a GM-only copy of the map right on top.  It made it hard for me to see the "You Are Here" token, but I already know where that is, so it was doable. I don't know if that's something you could automate with the script as well, but I would sure like it for the next world map I set up this way.
1521492552
G G
Pro
Sheet Author
That's a great idea. I find the yellow a bit too bright too.
Great!
neat trick!
1521550797
consider me a possible hexvert for this i just might be :D 
1521553304
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Adam E. said: I used this last weekend for some hex crawling my group was doing.  Things went really well.  Nicely done! I edited the script to make the hexes black with dark grey outlines because I found that easier on the eyes than the built-in yellow.  Maybe the ability to customize the color would be nice. I also moved a copy of the world map from the Map layer to the GM layer, lining them up exactly.  That way, when I had it drop all the hexes on the mostly-unexplored world, I could still tell where things were since I now have a GM-only copy of the map right on top.  It made it hard for me to see the "You Are Here" token, but I already know where that is, so it was doable. I don't know if that's something you could automate with the script as well, but I would sure like it for the next world map I set up this way. Nice trick! I already had plans to allow GMs to choose colors for their hexes in the next version, but I'll see about implementing the trick of putting the map on the GM layer too. Arthur B said: Could you add an option, where you draw a path, and the script fills the complete map EXCEPT the hexes that were covered by the path area? Like an inverted fill? Sure, I'll add that to the roadmap.
1521989413
Okra
Pro
The links seem to not work for me anymore.
1521992964
G G
Pro
Sheet Author
Looks like github might have changed its folder structure: Hexploration PathMath I think you might also need  VectorMath
1522021453

Edited 1522021479
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Sorry, I deleted my branch after it got merged into the upstream master branch. The script is now available through Roll20's One-Click library.
1522086972

Edited 1522087281
Is there an option to reveal the hexes around the token, so the party can see a bit in front of them? Or maybe perhaps a Mouse click reveal hex option? =) Scrolled up and saw it had just been asked, im a lazy idiot, nevermind me! =P
1522138331
Havoc
Pro
Sheet Author
API Scripter
"fill: '#FFFF88'," I think you should be able to add another hex number like 60 to add transparency, to create a fog of war feel.
1522154629
Havoc
Pro
Sheet Author
API Scripter
Question: Are you able to port this thing into Fog of War? To create a fog of war based on the same selection and make it disappear one by one using a token?
1522157011
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Havoc said: Question: Are you able to port this thing into Fog of War? To create a fog of war based on the same selection and make it disappear one by one using a token? No, there is currently no interface in the API to manipulate the Fog of War.
1522970664
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Update: v1.1 Version 1.1 is now available in beta from the merge request here:  https://github.com/Roll20/roll20-api-scripts/pull/... This update has the following changes: * The script now has a chat menu interface. * Implemented script configurations for hex colors. * Implemented reveal distance configuration. When a token moves, it will also reveal hexes out to this distance. * Hexes can now be named. When the named hex is revealed, it will announce that it has been discovered in the chat. * Implemented inverted fill. This works like the ordinary polygon fill, except that every hex NOT in the selected polygons is filled instead. * Requires HTML Builder script. Preview: 
That is terribly cool.
1522974724
G G
Pro
Sheet Author
Those are great improvements!
1522996580
Arthur B
Pro
API Scripter
Awesome! That will be one of my must-have scripts!
1523296581
Stephen L. said: Update: v1.1 Version 1.1 is now available in beta from the merge request here:  https://github.com/Roll20/roll20-api-scripts/pull/... This update has the following changes: * The script now has a chat menu interface. * Implemented script configurations for hex colors. * Implemented reveal distance configuration. When a token moves, it will also reveal hexes out to this distance. Splendid! Awesome work man! <3
1523788227
Ravenknight
KS Backer
Very nice Stephen! I remade the campaign map just to be able to use this script! :D
1523984884
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Glad ya'll are liking it!  Version 1.1 is now available through the Roll20 One-Click library.