• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Understanding the code by example?

Mettius

Well-known member
OK, after spending most of the weekend trying to get something going for a game system not already in HL, I'm exhaused from the learning curve.
I have a very light programming background (bash scripts a plenty, and a book on Java and Python under my belt, but no seasoned programmer to be sure).

Anyway, I've been reading the wiki until my brain feels like... I don't know. But now I've had a beer and a half, and though I'm feeling better, I'm still struggling to understand some of the skeleton code (the beer will help, right?):

So I'm going to attempt to enhance my learning by deciphering the following code bit by bit. For the love of the gods, if anyone can help that would be appreciated.

Code:
  <procedure id="DshRolls" scripttype="mouseinfo"><![CDATA[
    var final as string
    var roll as string
    foreach pick in hero where "DashTacCon.Rolls"
      if (eachpick.tagis[component.Skill] <> 0) then
        roll = eachpick.field[sklRoll].text & "{text clrsecond}  (" & eachpick.field[trtFinal].text & " + " & eachpick.linkage[attribute].field[name].text & " " & eachpick.linkage[attribute].field[trtFinal].text & "){text clrreset}"
      else
        roll = "????"
        endif
      final &= eachpick.field[name].text & " {b}" & roll & "{/b}{br}"
      nexteach
    @text = "{align left}" & final
    ]]></procedure>
 
proceedure id = DshRolls : OK a unique ID for this proceedure. Got it.

scripttype="mouseinfo" : I have no idea what this means.

<![CDATA[ : This is an XML construct to deal with
conflicting reserved characters. We pretend it isn't there.

var final as string
var roll as string : We are defining variables here, "final" and "roll" they will contain string data.

foreach pick in hero where "DashTacCon.Rolls" : OK here is where I start to have trouble. hero is the character "container" we are creating, pick is... I dunno. everything with the element/thing/don'tknowtheproperterm DashTacCon.Rolls... ???
 
Last edited:
scripttype determines what types of scripts are allowed to call this procedure, because some scripts have special behaviors or options that can only be done on those types of scripts. So scripttype tells the procedure what type of script it will be used in. Here's the wiki page about procedures, which is where it lists all the scripttype options that are available.

http://hlkitwiki.wolflair.com/index.php5?title=Procedure_Element_(Data)

Here's a youtube recording of a seminar I gave at Gen Con, covering how to set up searches (like the foreach operation) in Hero Lab: https://www.youtube.com/watch?v=9UPWoih8-q8&t=161s

Post #7 in this thread is also about foreaches: http://forums.wolflair.com/showthread.php?t=21663
 
Another bit confusing me:
Code:
<inputthing
      name="Linked Attribute for Skill"
      helptext="Select the attribute used to calculate the dice pool for this skill.">
      <it_linkage compset="Attribute" linkage="attribute"/>
      </inputthing>
What does the it_linkage line do? Looks like we are digging into the Attribute compset. And assigning what?

Compset Attribute contains three components...
Code:
  <compset
    id="Attribute"
    forceunique="yes">
    <compref component="Attribute"/>
    <compref component="Trait"/>
    <compref component="CanAdvance"/>
    </compset>
...and looking inside those components (Attribute, Trait, CanAdvance), the only use of lower case "attribute" is...

Code:
<linkage linkage="attribute" optional="no"/>
 
An <inputthing> element defines a line on an editor entry. In that case, this is a place in the editor where the user is selecting which attribute to assign to the "attribute" linkage on that skill.

Try opening the editor, and create a new file. Then, go to the skills tab, and try creating a new skill. You'll see an entry with that name - "Linked Attribute for Skill", and when you try the drop-down, you'll see a list of every item from the Attribute compset. If you look at the XML generated by the editor, you'll see that what you get is:

Code:
<link linkage="attribute" thing="attrSam"/>
(if you picked the sample attribute)

So that will generate the sort of records you're seeing in the thing_skills.dat file.
 
Back
Top