Page 1 of 2

Getting InitTool 1.0 groups from DMGenie

Posted: Sat Feb 17, 2007 6:56 pm
by jay
I wrote a little script for DMGenie that will output the current group as an Init Tool Groups (.rpgrp) file. Just add it as one of the action buttons and it will output the XML for the group in the combatant log. Cut and paste that to a file and it can be loaded into GT.

You can get the script from the gallery: DMGenie2RPToolsGroup

The group that is created is for the default Init Tool D&D game. If anybody knows how I could write a file directly from DMGenie, I'll fix it to do that, otherwise it's cut and paste.

Posted: Mon Feb 19, 2007 1:06 pm
by jay
To add this to DMGenie as an action button do the following:
  1. Select Windows --> General Script Editor from the menu
  2. In the Source drop down select 'Action Buttons'
  3. In the Function drop down select 'ActionButton##' where ## is replaced with a number. Make sure you find one that isn't being used. Unused ones do not have any scripting between the 'Public Sub ActionButton##' and 'End Sub' lines.
  4. Set the 'Button Label' field to something so you can tell what it does like 'RPTools Group XML'. You can set the tooltip if you want.
  5. Copy the script in the code box below into the text area at the bottom of the dialog. Make sure it goes between the 'Public Sub ActionButton##' and 'End Sub' lines.
  6. Click the check syntax button to make sure you copied it right. A little message dialog should come up and say that no syntax errors were found.
  7. The button is now ready to use. It will be located on the Actions or Attacks Tabs in DMGenie. The Description and Hints text box may tell you where to look.

Code: Select all

func.AddToCombatLog "<group-set>"
func.AddToCombatLog "  <game-name>Rodinia</game-name>"
func.AddToCombatLog "  <groups>"
func.AddToCombatLog "    <group>"
func.AddToCombatLog "      <name>DMGenie Group</name>"
func.AddToCombatLog "      <combatants>"
func.GetNextCreatureInit 0
Set MyCreature = func.GetNextCreature
While (Not MyCreature Is Nothing)
  func.AddToCombatLog "        <combatant>"
  func.AddToCombatLog "          <name>" & MyCreature.Name & "</name>"
  func.AddToCombatLog "          <count>1</count>"
  func.AddToCombatLog "          <init-modifier>" & MyCreature.InitBonus & "</init-modifier>"
  func.AddToCombatLog "          <player>" & MyCreature.Desc_PlayerName & "</player>"
  func.AddToCombatLog "          <type>PC</type>"
  func.AddToCombatLog "          <token/>"
  func.AddToCombatLog "          <notes>" & MyCreature.Desc & "</notes>"
  func.AddToCombatLog "          <alignment>" & MyCreature.Alignment & "</alignment>"
  func.AddToCombatLog "          <family>" & MyCreature.RaceName & "</family> <!-- TODO: Change family to race -->"
  func.AddToCombatLog "          <size>" & MyCreature.SizeStr & "</size>"
  func.AddToCombatLog "          <ac>" & MyCreature.AC & "</ac>"
  func.AddToCombatLog "          <touchAc>" & MyCreature.ACTouch & "</touchAc>"
  func.AddToCombatLog "          <flatFootedAc>" & MyCreature.ACFF & "</flatFootedAc>"
  func.AddToCombatLog "          <speed>" & MyCreature.SpeedStr & "</speed>"
  func.AddToCombatLog "          <baseAttack>" & MyCreature.CalculateBABFromClasses() & "</baseAttack>"
  func.AddToCombatLog "          <str>" & MyCreature.Str & "</str>"
  func.AddToCombatLog "          <dex>" & MyCreature.Dex & "</dex>"
  func.AddToCombatLog "          <con>" & MyCreature.Con & "</con>"
  func.AddToCombatLog "          <int>" & MyCreature.Intel & "</int>"
  func.AddToCombatLog "          <wis>" & MyCreature.Wis & "</wis>"
  func.AddToCombatLog "          <cha>" & MyCreature.Cha & "</cha>"
  func.AddToCombatLog "          <grapple>FIXME</grapple>"
  func.AddToCombatLog "          <fortSave>" & MyCreature.FortSave & "</fortSave>"
  func.AddToCombatLog "          <reflexSave>" & MyCreature.RefSave & "</reflexSave>"
  func.AddToCombatLog "          <willSave>" & MyCreature.WillSave & "</willSave>"
  func.AddToCombatLog "          <strBonus>" & MyCreature.StrMod & "</strBonus>"
  func.AddToCombatLog "          <dexBonus>" & MyCreature.DexMod & "</dexBonus>"
  func.AddToCombatLog "          <conBonus>" & MyCreature.ConMod & "</conBonus>"
  func.AddToCombatLog "          <intBonus>" & MyCreature.IntMod & "</intBonus>"
  func.AddToCombatLog "          <wisBonus>" & MyCreature.WisMod & "</wisBonus>"
  func.AddToCombatLog "          <chaBonus>" & MyCreature.ChaMod & "</chaBonus>"
  func.AddToCombatLog "          <gender>" & MyCreature.Gender & "</gender>"
  func.AddToCombatLog "          <levels>" & MyCreature.LevelStr & "</levels>"
  func.AddToCombatLog "          <height>" & MyCreature.Height & "</height>"
  func.AddToCombatLog "          <weight>" & MyCreature.Weight & "</weight>"
  func.AddToCombatLog "          <age>" & MyCreature.Age & "</age>"
  func.AddToCombatLog "          <damageReduction>" & MyCreature.DamageReductionStr & "</damageReduction>"
  func.AddToCombatLog "          <hp>" & MyCreature.HPBase & "</hp>"
  func.AddToCombatLog "          <fortBase>" & MyCreature.FortBase & "</fortBase>"
  func.AddToCombatLog "          <fortMagic>" & MyCreature.FortBonus & "</fortMagic>"
  func.AddToCombatLog "          <reflexBase>" & MyCreature.RefBase & "</reflexBase>"
  func.AddToCombatLog "          <reflexMagic>" & MyCreature.RefBonus & "</reflexMagic>"
  func.AddToCombatLog "          <willBase>" & MyCreature.WillBase & "</willBase>"
  func.AddToCombatLog "          <willMagic>" & MyCreature.WillBonus & "</willMagic>"
  func.AddToCombatLog "          <sizeBonus>" & MyCreature.SizeStr & "</sizeBonus>"
  func.AddToCombatLog "          <armorCheckPenalty>" & MyCreature.FinalCheck & "</armorCheckPenalty>"
  Dim MySkill, i
  for i = 1 to func.GetNumberOf_Skills
    Set MySkill = func.GetSkillObj(CInt(i))
    if func.ValidSk(MySkill) then
      tag = lcase(MySkill.NameUcase)
      tag = replace(tag, "(", "")
      tag = replace(tag, ")", "")
      words = split(tag)
      if ubound(words) >= 0 then
        tag = "skill." & words(0)
        if ubound(words) > 0 then
          for j = 1 to ubound(words)
            tag = tag & func.Capital(words(j))
          next
        end if
        func.AddToCombatLog "          <" & tag & ".total>" & MyCreature.SkillTotal(i) & "</" & tag & ".total>"
        func.AddToCombatLog "          <" & tag & ".rank>" & MyCreature.SkillRanks(i) & "</" & tag & ".rank>"
        func.AddToCombatLog "          <" & tag & ".misc>" & MyCreature.SkillTotal(i) & "</" & tag & ".misc>"
      else
        func.AddToCombatLog "          <!-- skipping a skill without a name -->"
      end if
    end If
  next
  func.AddToCombatLog "        </combatant>"
  Set MyCreature = func.GetNextCreature
Wend
func.AddToCombatLog "      </combatants>"
func.AddToCombatLog "    </group>"
func.AddToCombatLog "  </groups>"
func.AddToCombatLog "</group-set>" 
Edit 05/09/2008: Added <notes> field to output
Edit 05/15/2008: Fixed problem of forum removing text after dashes.

Posted: Mon Feb 19, 2007 5:00 pm
by Fobbo
Nicely done Jay, I was thinking of this very thing but having no time nor the correct skill to create it quickly had left it alone.

We can use this for either A. putting in the group into Init tool and then dragging the tokens into Maptool or B. creating an xml import in Maptool that use the same file.

Posted: Mon Feb 19, 2007 11:53 pm
by Azhrei
Jay, can InitTool get the XML directly from the cut buffer, ie. the clipboard?

I'm thinking it would be nice for the user to highlight a chunk of text, activate the InitTool window, then type Ctrl-V (or some other keystroke), and presto! the group now exists! And the user doesn't have to go through the pain of creating a file somewhere (on the desktop?), open it, paste into it, save it, then select File->Open... in InitTool, etc.

Thanks. :)

Posted: Mon Feb 19, 2007 11:56 pm
by jay
I'm trying to get 1.0 ready for release so I'd like to stay away from new functionality until it is ready. I will add a tracker for it though.

Posted: Wed Feb 21, 2007 12:44 am
by jay
I just found a bug in my script. I've updated it in the code box above and removed it from the gallery.

Posted: Wed Feb 21, 2007 8:23 am
by Big_Mac
jay wrote:I just found a bug in my script. I've updated it in the code box above and removed it from the gallery.
Just remember Jay there is no such thing as bugs! :D Just :Undocumented Features that need product enhancement" :lol:

Posted: Wed Feb 21, 2007 7:41 pm
by primarch
Hi!

Assuming the code in the box above is updated, I get a runtime error 9

subscript out of range: [number 0]
line 65 column 6

I made it an action button (number 15)

Primarch

Posted: Wed Feb 21, 2007 8:57 pm
by jay
I just cut and paste it into my action button 15 and it worked correctly. Is it possible that you typed in an extra character before you saved it? Or didn't copy everything?

If that is not the problem, then you might have a skill defined in your DMGenie instance that has a blank name. I added a blank skill name to my dmgenie data and it got the same error. To see if this is the problem select Windows --> Custom Data Editor --> Skills tab. See if there is a blank line in the skill list. I'll also put a check in the next incarnation of the script that handles that.

Posted: Wed Feb 21, 2007 9:05 pm
by jay
primarch wrote:Hi!

Assuming the code in the box above is updated, I get a runtime error 9

subscript out of range: [number 0]
line 65 column 6

I made it an action button (number 15)

Primarch
I updated the script in the code box above to handle this case. It will now output a XML comment saying that it skipped a skill with a blank name. I also 'enhanced' a small 'undocumented feature' out of the script as well. I don't think it was breaking IT, but it needed 'enhancement'.

Posted: Wed Feb 21, 2007 9:46 pm
by primarch
jay wrote:
primarch wrote:Hi!

Assuming the code in the box above is updated, I get a runtime error 9

subscript out of range: [number 0]
line 65 column 6

I made it an action button (number 15)

Primarch
I updated the script in the code box above to handle this case. It will now output a XML comment saying that it skipped a skill with a blank name. I also 'enhanced' a small 'undocumented feature' out of the script as well. I don't think it was breaking IT, but it needed 'enhancement'.
Hi!

This change "fixed" it, since I no longer so an error. My newbie question is after I click my custom button, what do I do next? I open ITool and don't see anything and I don't seem to be able to find a file anywhere.

Perhaps a step by step (idiot proof) instruction is in order.

Thanks for your help!

Primarch

Posted: Wed Feb 21, 2007 10:14 pm
by jay
primarch wrote:This change "fixed" it, since I no longer so an error.
Did you have a skill with a blank name in it? Because if that isn't the case there may be some other problem.
primarch wrote:My newbie question is after I click my custom button, what do I do next? I open ITool and don't see anything and I don't seem to be able to find a file anywhere.

Perhaps a step by step (idiot proof) instruction is in order.
Here you go:
  1. In DMGenie click on the combat log, hit Ctrl-A and then Delete. This will empty out your combat log to make it easier to grab the group that is being created.
  2. Press the action button that will execute the script. It should print out a lot of XML to the combat log.
  3. Click on the combat log in DMGenie again, hit Ctrl-A and then Ctrl-C. This will copy all of the XML output by the script on to the clipboard.
  4. Open up windows Notepad, or any other simple little file editor and hit Ctrl-V. This will paste all of the XML from DMGenie into the editor.
  5. Save the file (Ctrl-S in Notepad). Give it a name that has a file type of .rpgrp.
  6. Start Init Tool and then select Tools --> Group Tool from the menu. This will pop up the Group Tool window.
  7. On the Group Tool Window select File --> Open --> Group Set...
  8. Find the file that you created above in the file dialog and press the 'Open' button. That should load your data into group tool.

Posted: Thu Feb 22, 2007 11:00 am
by dorpond
Hey Jay, this is really nice! I just tested it out and it worked well.

Do you plan on making this script grab the other custom properties like speed, attacks, qualities, etc?

This is cool!

Posted: Fri Feb 23, 2007 10:50 am
by Fobbo
Modifing the script to get that information from DM Genie shouldnt be hard.

Posted: Fri Feb 23, 2007 11:53 am
by jay
dorpond wrote:Do you plan on making this script grab the other custom properties like speed, attacks, qualities, etc?
Yes, I've not gotten around to it yet.