Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Hero Lab Forums > HL - Authoring Kit
Register FAQ Community Today's Posts Search

Notices

Reply
 
Thread Tools Display Modes
EightBitz
Senior Member
 
Join Date: May 2013
Posts: 1,458

Old August 23rd, 2016, 01:36 PM
For the content that I create, I like to have full descriptions of things. But if someone asks me to share something, doing so with full descriptions would likely infringe on someone's copyright. (It is my understanding that you can copyright content, but not mechanics.)

So I came up with a Powershell script to redact descriptions. I can keep my own files with full descriptions and use a script to redact those descriptions if I choose to share the mechanics of my work.

I have included two methods within the script to protect original files, but you should still be aware that this script is not heavily tested. I recommend using it on a copy of your original files, or to at least backup your original files. I offer no warranties or guaranties of anything. Use this at your own risk.

That being said, here's the script.

Code:
### Source Path (Edit this to your preference.)
$filepath = "C:\ProgramData\Hero Lab\data\fatecore"

### Different subfolder for modified files to protect your originals.
###    If this does not exist, the script will create it.
###    (Edit this to your preference.)
$subfolder = "No_Descriptions"

### Source File (Ediit this to your preference.)
$oldfilename = "stuntspowers.user"

### Prefix for the modified filename.
###    Additional measure to protect your original files.
###    (Edit this to your preference.)
$newfilename = "NO_DESC_" + $oldfilename

### Everything that follows is procedural code.
### DO NOT edit anything below unless you understand the code.

### Delimiters for the description text.
$firststring = "description="""
$laststring = """ "

### Create a blank array to build the content for a new file.
[array]$newfile = @()

### Read the source file.
$oldfile = Get-Content "$filepath\$oldfilename"

### For each line in the source file, find and redact the description text.
foreach ($line in $oldfile) {
   $startrange = ""
   $endrange = ""
   $startrange = $line.ToLower().IndexOf($firststring)
   if ($startrange -ge 0) {
      $startrange = $startrange + $firststring.Length
      $endrange = $line.ToLower().IndexOf($laststring, $startrange)
      $range = $endrange - $startrange
      if ($range -gt 0) {
         $description = $line.Substring($startrange,$range)
         $line = $line.Replace($description,"")
      } # if ($startrange -ge 0)
   } # if ($startrange -ge 0)
   [array]$newfile = $newfile + $line
} # foreach ($line in $oldfile)

### Check if the subfolder exists.
###    If it does not, create it.
$SubfolderExists = Test-Path "$filepath\$subfolder"
if ($SubfolderExists -eq $False) {mkdir "$filepath\$subfolder"}

### Write the redacted content to a new file in the subfolder.
$newfile | Set-Content "$filepath\$subfolder\$newfilename"
EightBitz is offline   #1 Reply With Quote
Kairos
Senior Member
Volunteer Data File Author
 
Join Date: Feb 2009
Posts: 173

Old August 25th, 2016, 03:33 PM
Very cool. Thanks for sharing.

Authoring Kit Rule Sets (now with functioning links!):

Qin: The Warring States

Doctor Who: Adventures in Time and Space

MEGS/BoH/DC Heroes (work in progress)
Kairos is offline   #2 Reply With Quote
Goreshade
Member
 
Join Date: Aug 2013
Location: CA
Posts: 42

Old August 26th, 2016, 12:02 AM
I'm just getting back into HL, but I always wondered about something like this. Might come in handy if I ever actually achieve what I am going for.
Goreshade is offline   #3 Reply With Quote
EightBitz
Senior Member
 
Join Date: May 2013
Posts: 1,458

Old August 26th, 2016, 02:27 AM
Quote:
Originally Posted by Kairos View Post
Very cool. Thanks for sharing.
Not a problem. I appreciate other people sharing their work. I'm not a whiz with data files, so I share what I can.

Next step is to go through the steps of sharing my Dresden Files stuff through a URL, now that I can easily remove all descriptions. :-)
EightBitz is offline   #4 Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 04:32 AM.


Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.