Mathias' thread is great, but I just spent about an hour thinking and typing this explanation, so I figure I might as well fire it off anyway. Hope it helps.
Initial Contexts
So, any time you start a line of code there is an initial context from which you start. In eval scripts the initial context is the thing which the eval script is running on. For expr-req scripts it is the container of the thing which it is running on (since most things are added to the hero, this is usually the hero).
If you don't need to to navigate away from the initial context, then you can omit the first part of the code fragment.
For example, if you want to add +2 to the current thing's abValue field, you could write:
Code:
this.field[abValue].value += 2
But all you need is:
Code:
field[abValue].value += 2
Setting a New Context
Obviously, the initial context isn't always going to get you where you want to go. That's when you start the code fragment off by setting the context you want to start from. The most common of these is the "hero" context, but here are a couple other ones:
actor
container
parent
gizmo
each
Some contexts are not picks, they are containers (hero, gizmo, and actor). Because of that, you can check for the presence or abscence of a Tag (or apply a tag), but there are no fields associated with such a context to be read or manipulated. For these, there are often "Helper" picks present within the container, which contain fields and can accept tags related to some aspect of the container.
For example, these are good:
Code:
if (hero.tagis[Hero.Raging] <> 0) then
~ Do something
endif
perform hero.assign[Hero.EquipShld]
perform hero.delete[Ability.cMnkAC]
But these won't work:
Code:
hero.field[tACDeflect].value += 2
hero.field[tCR].value *= 10
A note: there is such a thing as "herofield", but this is just a shortcut way of saying "hero.child[Totals].field"
For "parent", the context is set to the containing pick, so it can check/manipulate the fields on that but if used outside a gizmo it will cause errors. This is mostly used for things like item powers or rooms/teams, which are added to Custom Magic Items or Buildings/Organization gizmos respectively.
Transitioning from one Context to the next
Each "." in the code fragment is a transition to something else within that context, and then the context becomes what follows the dot. These can be chained until you are where you need to be and can do what you need to do. For example:
Code:
hero.childfound[ArmorClass].field[tACDodge].value
Means "Start at the hero context, transition to the child pick ArmorClass, transition to the field named tACDodge, then transition to the value of that field"
The last "." could also be an action like assigning or checking a tag.
Code:
perform hero.child[skClimb].assign[SkillOver.aDEX]
if (hero.child[skClimb].tagis[SkillAbil.aDEX] <> 0) then
~ Do something
endif
The difference between "child", "childfound", and "findchild".
Yay, finally the part where I answer your question!
"child" and "childfound" are mostly the same but "child" throws an error if the transitioned to pick is not present. "childfound" just stops if the pick is missing, and is the safer of the two to use, so just use that. I've never seen a place where "child" needed to be used instead of "childfound", so I am not precisely sure why we have it at all. Probably a legacy thing.
"findchild" transitions to one pick on the hero without naming a specific pick. Instead it finds a pick which meets the conditions you set in the []. The first part has to be a component (a certain type of thing), and the optional second part is a tag expression (the criteria a pick of that type must meet). I say the tag expression is optional, but that is only true when there is never more than 1 pick of that component on a hero at a time (for example, there is never more than 1 race, or 1 deity on a hero). The code you cited is one such instance.
Example:
Code:
hero.findchild[BaseWep, "wFtrGroup.Axes & Helper.MainHand & !wClass.TwoHanded"].field[dmmBonus].value += 1
BaseWep is the component for all weapons, so that translates to "Start on the hero, then find a Weapon which is a member of the Axe weapon group, currently equipped in the Main hand, but not any Two Handed weapons. If we found our target, transition to the dmmBonus field, transition to the value, and add 1"
Getting the tag expression just right is a bit tricky. If there is more than 1 pick which meets your criteria, it transitions to a random qualifying pick, if there are 0 that meet the criteria the line ends with no error (same as childfound). I reccommend extensive testing.